def test_positive_include_exclude_module_stream_filter( self, content_view_module_stream): """Verify Include and Exclude Errata filter(modular errata) automatically force the copy of the module streams associated to it. :id: 20540722-b163-4ebb-b18d-351444ef0c86 :steps: 1. Create Include Errata filter 2. Publish content view, Verify errata and stream count. 3. Delete Filter (As we can not update the filter inclusion type) 4. Create Exclude Errata filter 5. Publish content view, Verify errata and stream count :expectedresults: Module Stream count changes automatically after including or excluding modular errata :CaseLevel: Integration """ content_view = content_view_module_stream cv_filter = entities.ErratumContentViewFilter( content_view=content_view, inclusion=True, ).create() errata = entities.Errata().search(query={ 'search': f'errata_id="{settings.repos.module_stream_0.errata[2]}"' })[0] entities.ContentViewFilterRule(content_view_filter=cv_filter, errata=errata).create() content_view.publish() content_view = content_view.read() content_view_version_info = content_view.version[0].read() # verify the module_stream_count and errata_count for Exclude Filter assert content_view_version_info.module_stream_count == 2 assert content_view_version_info.errata_counts['total'] == 1 # delete the previous content_view_filter cv_filter.delete() cv_filter = entities.ErratumContentViewFilter( content_view=content_view, inclusion=False, ).create() errata = entities.Errata().search(query={ 'search': f'errata_id="{settings.repos.module_stream_0.errata[2]}"' })[0] entities.ContentViewFilterRule(content_view_filter=cv_filter, errata=errata).create() content_view.publish() content_view_version_info = content_view.read().version[1].read() # verify the module_stream_count and errata_count for Include Filter assert content_view_version_info.module_stream_count == 5 assert content_view_version_info.errata_counts['total'] == 5
def test_positive_multi_level_filters(self): """Verify promotion of Content View and Verify count after applying multi_filters (errata and module stream) :id: aeaf2ac7-eda2-4f07-a1dd-fe6057934697 :expectedresults: Verify module stream and errata count should correct :CaseLevel: Integration """ # apply include errata filter cv_filter = entities.ErratumContentViewFilter( content_view=self.content_view, inclusion=True).create() errata = entities.Errata().search( query={'search': f'errata_id="{FAKE_0_MODULAR_ERRATA_ID}"'})[0] entities.ContentViewFilterRule(content_view_filter=cv_filter, errata=errata).create() # apply exclude module filter cv_filter = entities.ModuleStreamContentViewFilter( content_view=self.content_view, inclusion=False).create() module_streams = entities.ModuleStream().search( query={'search': 'name="{}"'.format('walrus')}) entities.ContentViewFilterRule(content_view_filter=cv_filter, module_stream=module_streams).create() self.content_view.publish() content_view = self.content_view.read() content_view_version_info = content_view.read().version[0].read() # verify the module_stream_count and errata_count for Include Filter assert content_view_version_info.module_stream_count == 2 assert content_view_version_info.errata_counts['total'] == 1
def test_positive_search_erratum(self): """Search for an erratum content view filter's rules. @Assert: The search completes with no errors. @Feature: Content View Filter """ cv_filter = entities.ErratumContentViewFilter( content_view=self.content_view).create() entities.ContentViewFilterRule(content_view_filter=cv_filter).search()
def test_positive_search_erratum(self): """Search for an erratum content view filter's rules. @id: 6a86060f-6b4f-4688-8ea9-c198e0aeb3f6 @Assert: The search completes with no errors. """ cv_filter = entities.ErratumContentViewFilter( content_view=self.content_view ).create() entities.ContentViewFilterRule(content_view_filter=cv_filter).search()
def test_positive_search_erratum(self): """Search for an erratum content view filter's rules. :id: 6a86060f-6b4f-4688-8ea9-c198e0aeb3f6 :expectedresults: The search completes with no errors. :CaseImportance: Critical """ cv_filter = entities.ErratumContentViewFilter( content_view=self.content_view).create() entities.ContentViewFilterRule(content_view_filter=cv_filter).search()
def test_positive_create_erratum_with_name(self, name, content_view): """Create new erratum content filter using different inputs as a name :id: f78a133f-441f-4fcc-b292-b9eed228d755 :parametrized: yes :expectedresults: Content view filter created successfully and has correct name and type :CaseLevel: Integration """ cvf = entities.ErratumContentViewFilter(content_view=content_view, name=name).create() assert cvf.name == name assert cvf.type == 'erratum'
def test_positive_create_erratum_with_name(self): """Create new erratum content filter using different inputs as a name :id: f78a133f-441f-4fcc-b292-b9eed228d755 :expectedresults: Content view filter created successfully and has correct name and type :CaseLevel: Integration """ for name in valid_data_list(): with self.subTest(name): cvf = entities.ErratumContentViewFilter( content_view=self.content_view, name=name).create() self.assertEqual(cvf.name, name) self.assertEqual(cvf.type, 'erratum')
def test_positive_create_erratum_with_name(self): """Create new erratum content filter using different inputs as a name @Assert: Content view filter created successfully and has correct name and type @Feature: Content View Filter - Create """ for name in valid_data_list(): with self.subTest(name): cvf = entities.ErratumContentViewFilter( content_view=self.content_view, name=name, ).create() self.assertEqual(cvf.name, name) self.assertEqual(cvf.type, 'erratum')
def test_positive_create_date_filter_rule_without_type(self): """Create content view erratum filter rule with start/end date and without type specified via API and make sure it's accessible via UI :id: 5a5cd6e7-8711-47c2-878d-4c0a18bf3b0e :BZ: 1386688 :CaseImportance: Critical :expectedresults: filter rule is accessible via UI, type is set to all possible errata types and all the rest fields are correctly populated """ start_date = date.today().strftime('%Y-%m-%d') end_date = (date.today() + timedelta(days=5)).strftime('%Y-%m-%d') # default date type on UI is 'updated', so we'll use different one date_type = FILTER_ERRATA_DATE['issued'] content_view = entities.ContentView( organization=self.organization).create() cvf = entities.ErratumContentViewFilter( content_view=content_view).create() cvfr = entities.ContentViewFilterRule( end_date=end_date, content_view_filter=cvf, date_type=date_type, start_date=start_date, ).create() self.assertEqual(set(cvfr.types), set(FILTER_ERRATA_TYPE.values())) with Session(self) as session: session.nav.go_to_select_org(self.organization.name) result = self.content_views.fetch_erratum_date_range_filter_values( content_view.name, cvf.name) self.assertEqual(set(result['types']), set(FILTER_ERRATA_TYPE.values())) self.assertEqual(result['date_type'], date_type) self.assertEqual(result['start_date'], start_date) self.assertEqual(result['end_date'], end_date)
def test_positive_filtered_errata_status_installable_param( session, errata_status_installable): """Filter errata for specific content view and verify that host that was registered using that content view has different states in correspondence to filtered errata and `errata status installable` settings flag value :id: ed94cf34-b8b9-4411-8edc-5e210ea6af4f :Steps: 1. Prepare setup: Create Lifecycle Environment, Content View, Activation Key and all necessary repos 2. Register Content Host using created data 3. Create necessary Content View Filter and Rule for repository errata 4. Publish and Promote Content View to a new version. 5. Go to created Host page and check its properties 6. Change 'errata status installable' flag in the settings and check host properties once more :expectedresults: Check that 'errata status installable' flag works as intended :BZ: 1368254 :CaseLevel: System """ org = entities.Organization().create() lce = entities.LifecycleEnvironment(organization=org).create() repos_collection = RepositoryCollection( distro=DISTRO_RHEL7, repositories=[ SatelliteToolsRepository(), # As Satellite Tools may be added as custom repo and to have a "Fully entitled" host, # force the host to consume an RH product with adding a cdn repo. RHELAnsibleEngineRepository(cdn=True), YumRepository(url=CUSTOM_REPO_URL), ], ) repos_collection.setup_content(org.id, lce.id, upload_manifest=True) with VirtualMachine(distro=repos_collection.distro) as client: repos_collection.setup_virtual_machine(client) assert _install_client_package(client, FAKE_1_CUSTOM_PACKAGE, errata_applicability=True) # Adding content view filter and content view filter rule to exclude errata for the # installed package. content_view = entities.ContentView( id=repos_collection.setup_content_data['content_view'] ['id']).read() cv_filter = entities.ErratumContentViewFilter( content_view=content_view, inclusion=False).create() errata = entities.Errata( content_view_version=content_view.version[-1]).search(query=dict( search=f'errata_id="{CUSTOM_REPO_ERRATA_ID}"'))[0] entities.ContentViewFilterRule(content_view_filter=cv_filter, errata=errata).create() content_view.publish() content_view = content_view.read() content_view_version = content_view.version[-1] promote(content_view_version, lce.id) with session: session.organization.select(org_name=org.name) _set_setting_value(errata_status_installable, True) expected_values = { 'Status': 'OK', 'Errata': 'All errata applied', 'Subscription': 'Fully entitled', } host_details_values = session.host.get_details(client.hostname) actual_values = { key: value for key, value in host_details_values['properties'] ['properties_table'].items() if key in expected_values } for key in actual_values: assert expected_values[key] in actual_values[ key], 'Expected text not found' _set_setting_value(errata_status_installable, False) expected_values = { 'Status': 'Error', 'Errata': 'Security errata applicable', 'Subscription': 'Fully entitled', } # navigate to host main page by making a search, to refresh the host details page session.host.search(client.hostname) host_details_values = session.host.get_details(client.hostname) actual_values = { key: value for key, value in host_details_values['properties'] ['properties_table'].items() if key in expected_values } for key in actual_values: assert expected_values[key] in actual_values[ key], 'Expected text not found'
def setUp(self): """Creates the pre-requisites for the Incremental updates that used per each test""" super(IncrementalUpdateTestCase, self).setUp() # Create content view that will be used filtered erratas self.rhel_6_partial_cv = entities.ContentView( organization=self.org, name=gen_alpha(), repository=[self.rhva_6_repo, self.rhel6_sat6tools_repo]).create() # Create a content view filter to filter out errata rhel_6_partial_cvf = entities.ErratumContentViewFilter( content_view=self.rhel_6_partial_cv, type='erratum', name='rhel_6_partial_cv_filter', repository=[self.rhva_6_repo]).create() # Create a content view filter rule - filtering out errata in the last # 365 days start_date = (date.today() - timedelta(days=365)).strftime('%Y-%m-%d') entities.ContentViewFilterRule( content_view_filter=rhel_6_partial_cvf, types=['security', 'enhancement', 'bugfix'], start_date=start_date, end_date=date.today().strftime('%Y-%m-%d')).create() # Publish content view and re-read it self.rhel_6_partial_cv.publish() self.rhel_6_partial_cv = self.rhel_6_partial_cv.read() # Promote content view to 'DEV' and 'QE' assert len(self.rhel_6_partial_cv.version) == 1 for env in (self.dev_lce, self.qe_lce): promote(self.rhel_6_partial_cv.version[0], env.id) # Create host collection self.rhel_6_partial_hc = entities.HostCollection(organization=self.org, name=gen_alpha(), max_hosts=5).create() # Create activation key for content view kwargs = {'organization': self.org, 'environment': self.qe_lce.id} rhel_6_partial_ak = entities.ActivationKey( name=gen_alpha(), content_view=self.rhel_6_partial_cv, host_collection=[self.rhel_6_partial_hc], **kwargs).create() # Assign subscription to activation key. Fetch available subscriptions subs = entities.Subscription(organization=self.org).search() assert len(subs) > 0 # Add subscription to activation key sub_found = False for sub in subs: if sub.read_json()['product_name'] == DEFAULT_SUBSCRIPTION_NAME: rhel_6_partial_ak.add_subscriptions( data={u'subscription_id': sub.id}) sub_found = True assert sub_found # Enable product content in activation key rhel_6_partial_ak.content_override( data={ 'content_override': { u'content_label': REPOS['rhst6']['id'], u'value': u'1' } }) # Create client machine and register it to satellite with # rhel_6_partial_ak self.vm = VirtualMachine(distro=DISTRO_RHEL6, tag='incupdate') self.addCleanup(vm_cleanup, self.vm) self.setup_vm(self.vm, rhel_6_partial_ak.name, self.org.label) self.vm.enable_repo(REPOS['rhva6']['id']) timestamp = datetime.utcnow() self.vm.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE)) # Find the content host and ensure that tasks started by package # installation has finished host = entities.Host().search( query={'search': 'name={}'.format(self.vm.hostname)}) wait_for_tasks( search_query='label = Actions::Katello::Host::UploadPackageProfile' ' and resource_id = {}' ' and started_at >= "{}"'.format(host[0].id, timestamp)) # Force host to generate or refresh errata applicability call_entity_method_with_timeout(host[0].errata_applicability, timeout=600)