def test_07_sync_repo(self): x = Repo.get(self.pulp, self.repo.id).data['content_unit_counts']['puppet_module'] response = self.repo.sync(self.pulp) self.assertPulp(code=202) Task.wait_for_report(self.pulp, response) y = Repo.get(self.pulp, self.repo.id).data['content_unit_counts']['puppet_module'] #FIXME result can change with time as number of modules is not constant! #check that the second i.e. updated query was also processed. self.assertTrue(x != y)
def test_02_copy_repo1_to_repo2(self): with self.pulp.asserting(True): response = self.repo2.copy(self.pulp, self.repo1.id, data={}) Task.wait_for_report(self.pulp, response) #check that the number of modules are the same repo1 = Repo.get(self.pulp, self.repo1.id) repo2 = Repo.get(self.pulp, self.repo2.id) self.assertEqual(repo1.data['content_unit_counts'], repo2.data['content_unit_counts'])
def test_02_get_repo(self): repo = Repo.get(self.pulp, self.repo.id) self.assertEqual(repo.id, self.repo.id) self.repo.reload(self.pulp) self.assertEqual(self.repo, repo) #get unexistant repo with self.assertRaises(AssertionError): Repo.get(self.pulp, 'some_id') self.assertPulp(code=404)
def test_02_copy_repo_to_repo_copy_and_publish(self): with self.pulp.asserting(True): response = self.repo_copy.copy(self.pulp, self.repo.id, data={}) Task.wait_for_report(self.pulp, response) #check that the number of modules are the same repo = Repo.get(self.pulp, self.repo.id) repo_copy = Repo.get(self.pulp, self.repo_copy.id) self.assertEqual(repo.data['content_unit_counts'], repo_copy.data['content_unit_counts']) with self.pulp.asserting(True): response = self.repo_copy.publish(self.pulp, self.distributor_copy.id) Task.wait_for_report(self.pulp, response)
def test_04_check_update_was_correct(self): self.assertEqual( Repo.get(self.pulp, self.repo.id).data['display_name'], "NewName") importer = self.repo.get_importer(self.pulp, "yum_importer") self.assertEqual(importer.data["config"]["num_units"], 6) distributor = self.repo.get_distributor(self.pulp, "yum_distributor") self.assertEqual(distributor.data["config"]["relative_url"], "my_url")
def test_04_update_repo(self): display_name = 'A %s repo' % self.__class__.__name__ self.repo |= {'display_name': display_name} self.repo.delta_update(self.pulp) self.assertPulp(code=200) self.assertEqual( Repo.get(self.pulp, self.repo.id).data['display_name'], display_name)
def pulp_repo_url(pulp, repo_id, distributor_type_id='yum_distributor'): '''return repo content url for given repo id or None''' repo = Repo.get(pulp, repo_id) # this should at most 1 item (for any given type) distributors = [distributor for distributor in repo.list_distributors(pulp) \ if distributor['distributor_type_id'] == distributor_type_id] if not distributors: return None return Distributor(data=distributors[0]).content_url(pulp)
def test_04_check_that_one_iso(self): # check that there is precisly one module dest_repo2 = Repo.get(self.pulp, self.dest_repo2.id) self.assertEqual(dest_repo2.data["content_unit_counts"]["iso"], 1) # check that one exact module copied i.e. perform the search by modules name response = self.dest_repo2.within_repo_search( self.pulp, data={"criteria": {"type_ids": ["iso"], "filters": {"unit": {"name": "test.iso"}}}} ) self.assertPulp(code=200) result = Association.from_response(response) # this means that only one module found with that name self.assertTrue(len(result) == 1)
def test_03_search_erratum(self): unit = ErratumUnit.search(self.pulp, data={ "criteria": { "filters": {}, "fields": ["name", "_content_type_id"] } }) repo2 = Repo.get(self.pulp, self.repo2.id) # assert that number of errata _eq_ to the number repo contains self.assertEqual(len(unit), repo2.data['content_unit_counts']['erratum'])
def test_04_check_that_one_module(self): # check that there is precisly one module dest_repo2 = Repo.get(self.pulp, self.dest_repo2.id) self.assertEqual(dest_repo2.data['content_unit_counts']['puppet_module'], 1) # check that one exact module copied i.e. perform the search by modules name response = self.dest_repo2.within_repo_search( self.pulp, data={"criteria": {"type_ids": ["puppet_module"], "filters": {"unit": {"name": "tomcat7_rhel"}}}} ) self.assertPulp(code=200) result = Association.from_response(response) # this means that only one module found with that name self.assertTrue(len(result) == 1)
def test_06_child_repo_content(self): # access the content of the pulp_child node # please note when the repo is created on the other node, # the distributor id used by default is yum_distributor # make sure the repo was published on the child node # the repo ID and distributor ID are the same on both the nodes child_repo = Repo.get(self.pulp_child, self.repo.id) response = child_repo.publish(self.pulp_child, self.distributor.id) assert response == ResponseLike(202), 'wrong response from the child node: %s' % response Task.wait_for_report(self.pulp_child, response) # fetch the repo content url on the child node repo_url = pulp_repo_url(self.pulp_child, self.repo.id) assert repo_url, 'invalid repo id on pulp_child node' # try accessing the content on the child node pkg_name = download_package_with_dnf(self.pulp_child, repo_url, 'bear') assert pkg_name == 'bear', 'not able to acces bear rpm on the child node'
def test_06_child_repo_content(self): # access the content of the pulp_child node # please note when the repo is created on the other node, # the distributor id used by default is yum_distributor # make sure the repo was published on the child node # the repo ID and distributor ID are the same on both the nodes child_repo = Repo.get(self.pulp_child, self.repo.id) response = child_repo.publish(self.pulp_child, self.distributor.id) assert response == ResponseLike( 202), 'wrong response from the child node: %s' % response Task.wait_for_report(self.pulp_child, response) # fetch the repo content url on the child node repo_url = pulp_repo_url(self.pulp_child, self.repo.id) assert repo_url, 'invalid repo id on pulp_child node' # try accessing the content on the child node pkg_name = download_package_with_dnf(self.pulp_child, repo_url, 'bear') assert pkg_name == 'bear', 'not able to acces bear rpm on the child node'
def test_03_search_erratum(self): unit = ErratumUnit.search(self.pulp, data={"criteria": {"filters": {}, "fields": ["name", "_content_type_id"]}}) repo2 = Repo.get(self.pulp, self.repo2.id) # assert that number of errata _eq_ to the number repo contains self.assertEqual(len(unit), repo2.data['content_unit_counts']['erratum'])
def test_04_update_repo(self): display_name = 'A %s repo' % self.__class__.__name__ self.repo |= {'display_name': display_name} self.repo.update(self.pulp) self.assertPulp(code=200) self.assertEqual(Repo.get(self.pulp, self.repo.id).data['display_name'], display_name)
def test_02_get_repo(self): repo = Repo.get(self.pulp, self.repo.id) self.assertEqual(repo.id, self.repo.id) self.repo.reload(self.pulp) self.assertEqual(self.repo, repo)
def test_02_check_all_iso_copied(self): source_repo = Repo.get(self.pulp, self.source_repo.id) dest_repo1 = Repo.get(self.pulp, self.dest_repo1.id) #check that the number of puppet modules are the same self.assertEqual(source_repo.data['content_unit_counts'], dest_repo1.data['content_unit_counts'])
def test_04_check_update_was_correct(self): self.assertEqual(Repo.get(self.pulp, self.repo.id).data['display_name'], "NewName") importer = self.repo.get_importer(self.pulp, "yum_importer") self.assertEqual(importer.data["config"]["num_units"], 6) distributor = self.repo.get_distributor(self.pulp, "yum_distributor") self.assertEqual(distributor.data["config"]["relative_url"], "my_url")