def test_positive_export_import_cv(self): """Export CV version contents in directory and Import them. :id: b08e9f24-f18e-43b7-9189-ad7b596ccb5b :steps: 1. Export whole CV version contents to a directory 3. Import those contents from some other org/satellite. :expectedresults: 1. Whole CV version contents has been exported to directory 2. All The exported contents has been imported in org/satellite. :CaseLevel: System """ ContentView.version_export({ 'export-dir': '{}'.format(self.export_dir), 'id': self.exporting_cvv_id }) exported_tar = '{0}/export-{1}.tar'.format(self.export_dir, self.exporting_cvv_id) result = ssh.command("[ -f {0} ]".format(exported_tar)) self.assertEqual(result.return_code, 0) exported_packages = Package.list({'content-view-version-id': self.exporting_cvv_id}) self.set_importing_org(self.exporting_prod, self.exporting_repo, self.exporting_cv) ContentView.version_import({ 'export-tar': exported_tar, 'organization-id': self.importing_org['id'] }) importing_cvv_id = ContentView.info({ u'id': self.importing_cv['id'] })['versions'][0]['id'] imported_packages = Package.list({'content-view-version-id': importing_cvv_id}) self.assertEqual(len(exported_packages), len(imported_packages))
def test_post_version_cv_export_import( self, request, set_importing_org, dependent_scenario_name, default_sat ): """After upgrade, content view version import and export works on the existing content view(that we created before the upgrade). :id: postupgrade-f19e4928-94db-4df6-8ce8-b5e4afe34258 :parametrized: yes :steps: 1: Export the existing content-view version. 2: Import the existing content-view version. 3: Delete the imported and exported content-vew, product, repo and organization. :expectedresults: After upgrade, 1: Content view created before upgrade should be imported and exported successfully. 2: Imported and Exported content view should be deleted successfully """ pre_test_name = dependent_scenario_name export_base = '/var/lib/pulp/katello-export/' org = entities.Organization().search(query={'search': f'name="{pre_test_name}_org"'})[0] request.addfinalizer(org.delete) product = entities.Product(organization=org).search( query={'search': f'name="{pre_test_name}_prod"'} )[0] request.addfinalizer(product.delete) exporting_cv = entities.ContentView(organization=org).search( query={'search': f'name="{pre_test_name}_cv"'} )[0] request.addfinalizer(exporting_cv.delete) exporting_cvv_id = max(cvv.id for cvv in exporting_cv.version) exporting_cvv_version = entities.ContentViewVersion(id=exporting_cvv_id).read().version ContentView.version_export({'export-dir': f'{export_base}', 'id': exporting_cvv_id}) exported_tar = f'{export_base}/export-{exporting_cv.name}-{exporting_cvv_version}.tar' result = default_sat.execute(f'[ -f {exported_tar} ]') assert result.status == 0 exported_packages = Package.list({'content-view-version-id': exporting_cvv_id}) assert len(exported_packages) > 0 importing_cv, importing_org = set_importing_org ContentView.version_import( {'export-tar': f'{exported_tar}', 'organization-id': importing_org.id} ) importing_cvv = importing_cv.read().version assert len(importing_cvv) == 1 imported_packages = Package.list({'content-view-version-id': importing_cvv[0].id}) assert len(imported_packages) > 0 assert len(exported_packages) == len(imported_packages) default_sat.execute(f'rm -rf {export_base}/*') exporting_cv_json = exporting_cv.read_json() importing_cv_json = importing_cv.read_json() exporting_cv_env_id = exporting_cv_json['environments'][0]['id'] importing_cv_env_id = importing_cv_json['environments'][0]['id'] assert exporting_cv.delete_from_environment(exporting_cv_env_id) assert importing_cv.delete_from_environment(importing_cv_env_id)
def test_post_version_cv_export_import(self): """Export and Import cv version created before upgrade :id: postupgrade-f19e4928-94db-4df6-8ce8-b5e4afe34258 :steps: Export and Import the Content Views version created before upgrade :expectedresults: Content-view created before upgrade should be exported and imported after upgrade """ prescene_dict = get_entity_data(self.__class__.__name__) exporting_cv = entities.ContentView( organization=prescene_dict['exporting_orgid']).search(query={ 'search': 'name={}'.format(prescene_dict['exporting_cvname']) })[0] exporting_cvv_id = max([cvv.id for cvv in exporting_cv.version]) exporting_cvv_version = entities.ContentViewVersion( id=exporting_cvv_id).read().version ContentView.version_export({ 'export-dir': '{}'.format(self.export_base), 'id': exporting_cvv_id }) exported_tar = '{0}/export-{1}-{2}.tar'.format(self.export_base, exporting_cv.name, exporting_cvv_version) result = ssh.command("[ -f {0} ]".format(exported_tar)) self.assertEqual(result.return_code, 0) exported_packages = Package.list( {'content-view-version-id': exporting_cvv_id}) self.assertTrue(len(exported_packages) > 0) self.set_importing_org( prescene_dict['exporting_prodname'], prescene_dict['exporting_reponame'], exporting_cv.name, ) ContentView.version_import({ 'export-tar': exported_tar, 'organization-id': self.importing_org.id }) importing_cvv = self.importing_cv.read().version self.assertTrue(len(importing_cvv) == 1) imported_packages = Package.list( {'content-view-version-id': importing_cvv[0].id}) self.assertTrue(len(imported_packages) > 0) self.assertEqual(len(exported_packages), len(imported_packages)) self.tearDownScenario()