Ejemplo n.º 1
0
    def setUpClass(cls):
        super(SimpleRepoCopyTest, cls).setUpClass()
        #Destination repo
        # make sure repos don't exist
        # no need to wait for repos.delete to happen
        feed = None
        dest_repo_name = cls.__name__ + '_copy'
        dest_repo1 = Repo({'id': dest_repo_name})
        dest_repo1.delete(cls.pulp)
        cls.dest_repo1, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        #2nd Destination Repo
        dest_repo_name = cls.__name__ + '_copy1'
        dest_repo2 = Repo({'id': dest_repo_name})
        dest_repo2.delete(cls.pulp)
        cls.dest_repo2, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        # Source repo
        default_repo_config = [
            repo for repo in ROLES.repos if repo.type == 'rpm'
        ][0]
        source_repo_name = cls.__name__ + '_repo'
        source_repo = Repo({'id': source_repo_name})
        source_repo.delete(cls.pulp)
        cls.source_repo, _, _ = create_yum_repo(cls.pulp, source_repo_name,
                                                default_repo_config.feed)
        Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
    def setUpClass(cls):
        super(RegRepoCopyTest, cls).setUpClass()
        
        # create repo
        cls.repo1, cls.importer1, cls.distributor1 = create_yum_repo(cls.pulp, cls.__name__ + "_repo1", feed='http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/')
        cls.repo2, cls.importer2, cls.distributor2 = create_yum_repo(cls.pulp, cls.__name__ + "_repo2", feed=None)

        # create consumer
        cls.consumer = Consumer(ROLES.consumers[0])
        setattr(cls.consumer, 'cli', Cli.ready_instance(**ROLES.consumers[0]))
Ejemplo n.º 3
0
    def setUpClass(cls):
        super(RegRepoCopyTest, cls).setUpClass()

        # create repo
        cls.repo1, cls.importer1, cls.distributor1 = create_yum_repo(
            cls.pulp,
            cls.__name__ + "_repo1",
            feed='http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/'
        )
        cls.repo2, cls.importer2, cls.distributor2 = create_yum_repo(
            cls.pulp, cls.__name__ + "_repo2", feed=None)

        # create consumer
        cls.consumer = Consumer(ROLES.consumers[0])
        setattr(cls.consumer, 'cli', Cli.ready_instance(**ROLES.consumers[0]))
    def setUpClass(cls):
        # set up a repo for the test cases
        super(EventListenerTest, cls).setUpClass()

        cls.repo_feed = 'https://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/'
        cls.repo, cls.importer, cls.distributor = create_yum_repo(cls.pulp, 'EventListenerRepo',
                                                        feed=cls.repo_feed)
 def test_01_repo_sync_finish(self):
     self.el.update(self.pulp, {'event_types': ['repo.sync.finish']})
     self.el.reload(self.pulp)
     with deleting(
             self.pulp,
             *create_yum_repo(
                 self.pulp,
                 'sync_error_repo',
                 feed='http://example.com/repos/none')) as (repo,
                                                            (importer,
                                                             distributor)):
         response = repo.sync(self.pulp)
         self.assertPulpOK()
         with self.assertRaises(TaskFailure):
             # make sure the sync did not succeed
             Task.wait_for_report(self.pulp, response)
         tasks = Task.from_report(self.pulp, response)
         # assert the bin contains request with a failed task in body
         self.bin.reload()
         assert self.bin.request_count == 1, 'invalid bin.request count: %s' % self.bin.request_count
         el_request = self.bin.requests[0]
         assert el_request.method == 'POST', 'invalid bin request method: %s' % el_request.method
         el_task = Task.from_call_report_data(json.loads(el_request.body))
         assert el_task.state == TASK_ERROR_STATE, 'invalid request.body:Task.state: %s' % el_task.state
         assert el_task.id in [
             task.id for task in tasks
         ], 'invalid request.body:Task.id: %s' % el_task.id
 def setUpClass(cls):
     super(ImporterDistributorTest, cls).setUpClass()
     #create repo with inporter/distributer associated
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo, _, cls.distributor = create_yum_repo(cls.pulp, **repo_config)
     cls.importer = cls.repo.get_importer(cls.pulp, "yum_importer")
     cls.repo1 = Repo(data={'id': cls.__name__ + "_repo1"})
    def setUpClass(cls):
        super(PublishGroupTest, cls).setUpClass()
        # create repo_group
        repo_group = RepoGroup(data={'id': cls.__name__ + "_repo_group"})
        response = repo_group.create(cls.pulp)
        cls.repo_group = RepoGroup.from_response(response)
        cls.repo_group1 = RepoGroup(data={'id': cls.__name__ + "_repo_group1"})

        #associate_distributor
        with cls.pulp.asserting(True):
            response = cls.repo_group.associate_distributor(
                cls.pulp,
                data={
                    'distributor_type_id': 'group_export_distributor',
                    'distributor_config': {
                        'http': False,
                        'https': False
                    },
                    'distributor_id': 'dist_1'
                })
        cls.distributor = GroupDistributor.from_response(response)
        #create repo
        repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
        cls.repo, _, _ = create_yum_repo(cls.pulp, **repo_config)
        Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
 def setUpClass(cls):
     super(ConsumerAuthTest, cls).setUpClass()
     cls.ROLES = ROLES
     cls.PROFILE = PROFILE
     cls.rsa_primary = RSA.load_key(
         '/usr/share/pulp_auto/tests/data/fake-consumer.pem')
     cls.rsa_secondary = RSA.load_key(
         '/usr/share/pulp_auto/tests/data/fake-consumer-secondary.pem')
     bio_fd = BIO.MemoryBuffer()
     cls.rsa_primary.save_pub_key_bio(bio_fd)
     cls.pub_pem_primary = bio_fd.getvalue()
     bio_fd = BIO.MemoryBuffer()
     cls.rsa_secondary.save_pub_key_bio(bio_fd)
     cls.pub_pem_secondary = bio_fd.getvalue()
     cls.repo, cls.importer, cls.distributor = create_yum_repo(
         cls.pulp,
         **[repo for repo in cls.ROLES.repos if repo.type == 'rpm'][0])
     cls.consumer = Consumer.register(cls.pulp,
                                      cls.__name__ + '_consumer',
                                      rsa_pub=cls.pub_pem_primary)
     cls.agent = Agent(pulp_auto.handler,
                       PROFILE=pulp_auto.handler.profile.PROFILE)
     cls.qpid_handle = QpidHandle(cls.ROLES.qpid.url,
                                  cls.consumer.id,
                                  auth=Authenticator(
                                      signing_key=cls.rsa_primary,
                                      verifying_key=cls.pulp.pubkey))
 def testcase_01_upload_and_download_using_dnf_rpm(self):
     # create yum-repo, -importer, -distributor
     with deleting(self.pulp,
                   *create_yum_repo(
                       self.pulp,
                       'test_22_rpm_repo_for_dnf')) as (repo,
                                                        (importer,
                                                         (distributor))):
         # create and perform an rpm url upload
         with deleting(self.pulp, upload_url_rpm(self.pulp,
                                                 self.rpm_url)) as upload:
             # assign the upload to the repo
             response = upload.import_to(self.pulp, repo)
             self.assertPulpOK()
             Task.wait_for_report(self.pulp, response)
             # check the content is accessible
             response = repo.publish(self.pulp, distributor.id)
             self.assertPulpOK()
             Task.wait_for_report(self.pulp, response)
             # fetch the package through the repo
             pulp_rpm_url = distributor.content_url(
                 self.pulp, url_basename(self.rpm_url))
             pulp_repo = distributor.content_url(self.pulp)
             with closing(temp_url(pulp_rpm_url)) as tmpfile:
                 assert url_basename(self.rpm_url).startswith(
                     rpm_metadata(tmpfile)['unit_key']['name'])
             assert "bear" == download_package_with_dnf(
                 self.pulp, pulp_repo, "bear")
 def test_02_repo_publish_finish(self):
     self.el.update(self.pulp, {'event_listener': ['repo.publish.finish']})
     self.el.reload(self.pulp)
     with deleting(
             self.pulp,
             *create_yum_repo(
                 self.pulp,
                 'publish_error_repo',
                 feed=
                 'https://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/'
             )) as (repo, (importer, distributor)):
         response = repo.publish(self.pulp, 'invalid_distributor_id')
         self.assertPulpOK()
         with self.assertRaises(TaskFailure):
             # make sure the publish task failed
             Task.wait_for_report(self.pulp, response)
         task = Task.from_report(self.pulp, response)
         # assert the bin contains a request with a fained task in body
         self.bin.reload()
         assert self.bin.request_count == 1, 'invalid bin.request_count: %s' % self.bin.request_count
         el_request = self.bin.requests[0]
         assert el_request.method == 'POST', 'invalid bin request method: %s' % el_request.method
         el_task = Task.from_call_report_data(json.loads(el_request.body))
         assert el_task.state == TASK_ERROR_STATE, 'invalid request.body:Task.state: %s' % el_task.state
         assert el_task.id in [
             task.id for task in tasks
         ], 'invalid request.body:Task.id: %s' % el_task.id
 def setUpClass(cls):
     super(ImporterDistributorTest, cls).setUpClass()
     #create repo with inporter/distributer associated
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo, _, cls.distributor = create_yum_repo(cls.pulp, **repo_config)
     cls.importer = cls.repo.get_importer(cls.pulp, "yum_importer")
     cls.repo1 = Repo(data={'id': cls.__name__ + "_repo1"})
 def testcase_03_parallel_upload_rpms(self):
     import gevent
     with deleting(self.pulp, *create_yum_repo(self.pulp, 'upload_test_rpm_repo')) as (repo, (importer, (distributor))):
         # create and perform an rpm url upload
         jobs = [gevent.spawn(lambda: self.rpm_uploader(self.pulp, url, repo, distributor)) for url in \
                         [self.rpm_url_bear, self.rpm_url_mouse]]
         gevent.joinall(jobs, raise_error=True)
Ejemplo n.º 13
0
 def setUpClass(cls):
     # set up the class with a repo that is synced and set up for nodes to feed from
     super(NodeTestRepo, cls).setUpClass()
     cls.node.activate(cls.pulp)
     repo_role = ROLES.repos[0]
     cls.repo, cls.importer, cls.distributor = create_yum_repo(cls.pulp, **repo_role)
     Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
     response = cls.repo.associate_distributor(cls.pulp, NodeDistributor.default().data)
     cls.node_distributor = NodeDistributor.from_response(response)
Ejemplo n.º 14
0
 def test_03_race_delete_published(self):
     # repos with associated importers/distributors are deleted asynchronously; a 409 may happen
     # see also: https://bugzilla.redhat.com/show_bug.cgi?id=1065455
     repo, _, distributor = create_yum_repo(self.pulp, **self.repo_config)
     repo.sync(self.pulp)
     repo.publish(self.pulp, distributor.id)
     with self.pulp.async():
         repo.delete(self.pulp)
         repo.delete(self.pulp)
Ejemplo n.º 15
0
 def testcase_02_upload_rpm(self):
     # create yum-repo, -importer, -distributor
     with deleting(self.pulp,
                   *create_yum_repo(
                       self.pulp,
                       'upload_test_rpm_repo')) as (repo, (importer,
                                                           (distributor))):
         # create and perform an rpm url upload
         self.rpm_uploader(self.pulp, self.rpm_url_bear, repo, distributor)
 def setUpClass(cls):
     super(ScheduledSyncTest, cls).setUpClass()
     # create and sync rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo, _, _ = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
     # create a schedule sync
     cls.importer = cls.repo.get_importer(cls.pulp, "yum_importer")
     # sync will be done every minute
     response = cls.importer.schedule_sync(cls.pulp, "PT1M")
     cls.action = ScheduledAction.from_response(response)
Ejemplo n.º 17
0
 def testcase_03_parallel_upload_rpms(self):
     import gevent
     with deleting(self.pulp,
                   *create_yum_repo(
                       self.pulp,
                       'upload_test_rpm_repo')) as (repo, (importer,
                                                           (distributor))):
         # create and perform an rpm url upload
         jobs = [gevent.spawn(lambda: self.rpm_uploader(self.pulp, url, repo, distributor)) for url in \
                         [self.rpm_url_bear, self.rpm_url_mouse]]
         gevent.joinall(jobs, raise_error=True)
Ejemplo n.º 18
0
 def setUpClass(cls):
     super(CliConsumerTest, cls).setUpClass()
     consumer_config = ROLES.consumers[0]
     # create all repos
     with cls.pulp.asserting(True):
         cls.repos = [create_yum_repo(cls.pulp, **repo) for repo in consumer_config.repos if repo.type == 'rpm']
         for repo, _, distributor in cls.repos:
             Task.wait_for_response(cls.pulp, repo.sync(cls.pulp))
             Task.wait_for_response(cls.pulp, repo.publish(cls.pulp, data={'id': distributor.id}))
     cls.consumer_cli = Cli.ready_instance(**consumer_config)
     cls.consumer = Consumer(consumer_config)
Ejemplo n.º 19
0
 def setUpClass(cls):
     super(ConsumerAgentPulpTest, cls).setUpClass()
     cls.ROLES = ROLES
     cls.PROFILE = PROFILE
     from . import ROLES as inventory_roles
     cls.repo, cls.importer, cls.distributor = create_yum_repo(cls.pulp, **[repo for repo in inventory_roles.repos if repo.type == 'rpm'][0])
     cls.consumer = Consumer.register(cls.pulp, cls.__name__ + '_consumer')
     cls.binding_data = {'repo_id': cls.repo.id, 'distributor_id': cls.distributor.id}
     cls.log.info('instantiating agent')
     cls.agent = Agent(pulp_auto.handler, PROFILE=pulp_auto.handler.profile.PROFILE)
     cls.log.info('instantiating qpid handle')
     cls.qpid_handle = QpidHandle(ROLES.qpid.url, cls.consumer.id)
Ejemplo n.º 20
0
 def setUpClass(cls):
     # set up the class with a repo that is synced and set up for nodes to feed from
     super(NodeTestRepo, cls).setUpClass()
     cls.node.activate(cls.pulp)
     repo_role = ROLES.repos[0]
     cls.repo, cls.importer, cls.distributor = create_yum_repo(
         cls.pulp, **repo_role)
     Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
     response = cls.repo.associate_distributor(
         cls.pulp,
         NodeDistributor.default().data)
     cls.node_distributor = NodeDistributor.from_response(response)
 def setUpClass(cls):
     super(ScheduledSyncTest, cls).setUpClass()
     # create and sync rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo, _, _ = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
     # create a schedule sync
     cls.importer = cls.repo.get_importer(cls.pulp, "yum_importer")
     # sync will be done every minute
     response = cls.importer.schedule_sync(cls.pulp, "PT1M")
     cls.action = ScheduledAction.from_response(response)
     cls.delta = time.time() + 120
Ejemplo n.º 22
0
 def setUpClass(cls):
     super(SimpleOrphanTest, cls).setUpClass()
     # prepare orphans by syncing and deleting a repo
     # make sure the repo is gone
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     repo = Repo(repo_config)
     repo.delete(cls.pulp)
     # create and sync repo
     cls.repo, _, _ = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
     # this is where orphans appear
     Task.wait_for_report(cls.pulp, cls.repo.delete(cls.pulp))
    def setUpClass(cls):
        super(RegRepoNoFeedTest, cls).setUpClass()
        
        # create repo
        cls.repo, cls.importer, cls.distributor = create_yum_repo(cls.pulp, cls.__name__ + "_repo", feed=None)

        # create consumer
        cls.consumer = Consumer(ROLES.consumers[0])
        setattr(cls.consumer, 'cli', Cli.ready_instance(**ROLES.consumers[0]))
        
        # rpm
        cls.rpm_url_pike = 'https://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/pike-2.2-1.noarch.rpm'
 def setUpClass(cls):
     super(ScheduledPublishTest, cls).setUpClass()
     # create and sync and publish rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo, _, cls.distributor = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
     Task.wait_for_report(cls.pulp, cls.repo.publish(cls.pulp, cls.distributor.id))
     # create a schedule publish
     cls.distributor = cls.repo.get_distributor(cls.pulp, cls.distributor.id)
     # publish will be done every minute
     response = cls.distributor.schedule_publish(cls.pulp, "PT1M")
     cls.action = ScheduledAction.from_response(response)
     cls.delta = time.time() + 120
Ejemplo n.º 25
0
 def setUpClass(cls):
     super(UnitSearchTest, cls).setUpClass()
     #create and sync puppet repo
     repo_id = cls.__name__
     queries = ['tomcat']
     cls.repo1, _, _ = create_puppet_repo(cls.pulp, repo_id, queries)
     sync_task = Task.from_response(cls.repo1.sync(cls.pulp))[0]
     sync_task.wait(cls.pulp)
     # create and sync rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo2, _, _ = create_yum_repo(cls.pulp, **repo_config)
     sync_task = Task.from_response(cls.repo2.sync(cls.pulp))[0]
     sync_task.wait(cls.pulp)
Ejemplo n.º 26
0
    def setUpClass(cls):
        super(RegRepoNoFeedTest, cls).setUpClass()

        # create repo
        cls.repo, cls.importer, cls.distributor = create_yum_repo(
            cls.pulp, cls.__name__ + "_repo", feed=None)

        # create consumer
        cls.consumer = Consumer(ROLES.consumers[0])
        setattr(cls.consumer, 'cli', Cli.ready_instance(**ROLES.consumers[0]))

        # rpm
        cls.rpm_url_pike = 'https://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/pike-2.2-1.noarch.rpm'
Ejemplo n.º 27
0
    def setUpClass(cls):
        super(CliConsumerTest, cls).setUpClass()
        # create all repos
        # get repo configs across all consumers
        repo_configs = sum([consumer.repos for consumer in ROLES.consumers],
                           [])
        # filter&uniq repo configs
        repo_configs = {
            repo.id: repo
            for repo in repo_configs if repo.type == 'rpm'
        }.values()
        with cls.pulp.asserting(True):
            cls.repos = [
                create_yum_repo(cls.pulp, **repo_config)
                for repo_config in repo_configs
            ]

        # sync&publish all repos
        with cls.pulp.asserting(True):
            task_reports = [repo.sync(cls.pulp) for repo, _, _ in cls.repos]
        Task.wait_for_reports(cls.pulp, task_reports)

        with cls.pulp.asserting(True):
            task_reports = [
                repo.publish(cls.pulp, distributor.id)
                for repo, _, distributor in cls.repos
            ]
        Task.wait_for_reports(cls.pulp, task_reports)

        # create all consumers
        # gather all consumers
        consumer_configs = {
            consumer.id: consumer
            for consumer in ROLES.consumers
        }
        with cls.pulp.asserting(True):
            cls.consumers = [
                Consumer(consumer_config)
                for consumer_config in consumer_configs.values()
            ]

        # set up consumer cli & link repos
        for consumer in cls.consumers:
            setattr(consumer, 'cli',
                    Cli.ready_instance(**consumer_configs[consumer.id]))
            setattr(
                consumer, 'repos',
                filter(
                    lambda (repo, importer, distributor):
                    any(repo.id == repo_config.id for repo_config in
                        consumer_configs[consumer.id].repos), cls.repos))
 def setUpClass(cls):
     super(PuppetCopyRepoTest, cls).setUpClass()
     repo_id = cls.__name__
     queries = ['tomcat']
     # create source repo and sync it to have modules fetched
     cls.source_repo, _, _ = create_puppet_repo(cls.pulp, repo_id, queries)
     Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
     # create two destinations repos for copy purpose
     cls.dest_repo1, _, _ = create_puppet_repo(cls.pulp, repo_id + '1', feed=None)
     cls.dest_repo2, _, _ = create_puppet_repo(cls.pulp, repo_id + '2', feed=None)
     # create data for repo
     cls.invalid_repo = Repo(data={'id': cls.__name__ + "_invalidrepo"})
     # create yum repo
     cls.yumrepo, _, _ = create_yum_repo(cls.pulp, repo_id + 'yum', feed=None)
Ejemplo n.º 29
0
    def setUpClass(cls):
        super(SimpleRepoCopyTest, cls).setUpClass()
        #Destination repo
        feed = None
        dest_repo_name = cls.__name__ + '_copy'
        dest_repo1 = Repo({'id': dest_repo_name})
        dest_repo1.delete(cls.pulp)
        cls.dest_repo1, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        #2nd Destination Repo
        dest_repo_name = cls.__name__ + '_copy1'
        dest_repo2 = Repo({'id': dest_repo_name})
        dest_repo2.delete(cls.pulp)
        cls.dest_repo2, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        # Source repo
        default_repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
        source_repo_name = cls.__name__ + '_repo'
        source_repo = Repo({'id': source_repo_name})
        source_repo.delete(cls.pulp)
        cls.source_repo, _, _ = create_yum_repo(cls.pulp, source_repo_name, default_repo_config.feed)
        sync_task = Task.from_response(cls.source_repo.sync(cls.pulp))[0]
        sync_task.wait(cls.pulp)
Ejemplo n.º 30
0
 def setUpClass(cls):
     super(PuppetCopyRepoTest, cls).setUpClass()
     repo_id = cls.__name__
     queries = ['tomcat']
     # create source repo and sync it to have modules fetched
     cls.source_repo, _, _ = create_puppet_repo(cls.pulp, repo_id, queries)
     Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
     # create two destinations repos for copy purpose
     cls.dest_repo1, _, _ = create_puppet_repo(cls.pulp, repo_id + '1', feed=None)
     cls.dest_repo2, _, _ = create_puppet_repo(cls.pulp, repo_id + '2', feed=None)
     # create data for repo
     cls.invalid_repo = Repo(data={'id': cls.__name__ + "_invalidrepo"})
     # create yum repo
     cls.yumrepo, _, _ = create_yum_repo(cls.pulp, repo_id + 'yum', feed=None)
Ejemplo n.º 31
0
 def setUpClass(cls):
     super(UnitSearchTest, cls).setUpClass()
     #create and sync puppet repo
     repo_id = cls.__name__
     queries = ['jenkins']
     # make sure we run clean
     response = Repo({'id': repo_id}).delete(cls.pulp)
     if response == ResponseLike(202):
         Task.wait_for_report(cls.pulp, response)
     cls.repo1, _, _ = create_puppet_repo(cls.pulp, repo_id, queries)
     Task.wait_for_report(cls.pulp, cls.repo1.sync(cls.pulp))
     # create and sync rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo2, _, _ = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo2.sync(cls.pulp))
    def setUpClass(cls):
        super(SimpleRepoCopyTest, cls).setUpClass()
        #Destination repo
        # make sure repos don't exist
        # no need to wait for repos.delete to happen
        feed = None
        dest_repo_name = cls.__name__ + '_copy'
        dest_repo1 = Repo({'id': dest_repo_name})
        dest_repo1.delete(cls.pulp)
        cls.dest_repo1, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        #2nd Destination Repo
        dest_repo_name = cls.__name__ + '_copy1'
        dest_repo2 = Repo({'id': dest_repo_name})
        dest_repo2.delete(cls.pulp)
        cls.dest_repo2, _, _ = create_yum_repo(cls.pulp, dest_repo_name, feed)

        # Source repo
        default_repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
        source_repo_name = cls.__name__ + '_repo'
        source_repo = Repo({'id': source_repo_name})
        source_repo.delete(cls.pulp)
        cls.source_repo, _, _ = create_yum_repo(cls.pulp, source_repo_name, default_repo_config.feed)
        Task.wait_for_report(cls.pulp, cls.source_repo.sync(cls.pulp))
 def test_01(self):
     errors = 0
     # change the range to 300-600 and run it separately from the rest of testcases
     for i in xrange(3):
         with self.agent.catching(True), self.agent.running(self.qpid_handle, frequency=10):
             try:
                 self.bindRepo()
                 self._tearDown()
             except (TaskFailure, TaskTimeoutError) as error:
                 print '> ',
                 errors += 1
                 print error
         self.repo, self.importer, self.distributor = create_yum_repo(self.pulp, **[repo for repo in self.ROLES.repos if repo.type == 'rpm'][0])
         print i
     print "errors", errors
 def setUpClass(cls):
     super(ScheduledPublishTest, cls).setUpClass()
     # create and sync and publish rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == 'rpm'][0]
     cls.repo, _, cls.distributor = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
     Task.wait_for_report(cls.pulp,
                          cls.repo.publish(cls.pulp, cls.distributor.id))
     # create a schedule publish
     cls.distributor = cls.repo.get_distributor(cls.pulp,
                                                cls.distributor.id)
     # publish will be done every minute
     response = cls.distributor.schedule_publish(cls.pulp, "PT1M")
     cls.action = ScheduledAction.from_response(response)
     cls.delta = time.time() + 120
Ejemplo n.º 35
0
 def setUpClass(cls):
     super(UnitSearchTest, cls).setUpClass()
     # create and sync puppet repo
     repo_id = cls.__name__
     queries = ["jenkins"]
     # make sure we run clean
     response = Repo({"id": repo_id}).delete(cls.pulp)
     if response == ResponseLike(202):
         Task.wait_for_report(cls.pulp, response)
     cls.repo1, _, _ = create_puppet_repo(cls.pulp, repo_id, queries)
     Task.wait_for_report(cls.pulp, cls.repo1.sync(cls.pulp))
     # create and sync rpm repo
     repo_config = [repo for repo in ROLES.repos if repo.type == "rpm"][0]
     cls.repo2, _, _ = create_yum_repo(cls.pulp, **repo_config)
     Task.wait_for_report(cls.pulp, cls.repo2.sync(cls.pulp))
Ejemplo n.º 36
0
 def setUpClass(cls):
     super(ConsumerAgentPulpTest, cls).setUpClass()
     cls.ROLES = ROLES
     cls.PROFILE = PROFILE
     from . import ROLES as inventory_roles
     cls.repo, cls.importer, cls.distributor = create_yum_repo(cls.pulp, **[repo for repo in inventory_roles.repos if repo.type == 'rpm'][0])
     cls.rsa = RSA.load_key('./tests/data/fake-consumer.pem')
     bio_fd = BIO.MemoryBuffer()
     cls.rsa.save_pub_key_bio(bio_fd)
     cls.rsa_pub_pem = bio_fd.getvalue()
     cls.consumer = Consumer.register(cls.pulp, cls.__name__ + '_consumer', rsa_pub=cls.rsa_pub_pem)
     #cls.binding_data = {'repo_id': cls.repo.id, 'distributor_id': cls.distributor.id}
     cls.log.info('instantiating agent')
     cls.agent = Agent(pulp_auto.handler, PROFILE=pulp_auto.handler.profile.PROFILE)
     cls.log.info('instantiating qpid handle')
     cls.qpid_handle = QpidHandle(ROLES.qpid.url, cls.consumer.id, auth=Authenticator(signing_key=cls.rsa, verifying_key=cls.pulp.pubkey))
 def setUpClass(cls):
     super(ConsumerAuthTest, cls).setUpClass()
     cls.ROLES = ROLES
     cls.PROFILE = PROFILE
     cls.rsa_primary = RSA.load_key('/usr/share/pulp_auto/tests/data/fake-consumer.pem')
     cls.rsa_secondary = RSA.load_key('/usr/share/pulp_auto/tests/data/fake-consumer-secondary.pem')
     bio_fd = BIO.MemoryBuffer()
     cls.rsa_primary.save_pub_key_bio(bio_fd)
     cls.pub_pem_primary = bio_fd.getvalue()
     bio_fd = BIO.MemoryBuffer()
     cls.rsa_secondary.save_pub_key_bio(bio_fd)
     cls.pub_pem_secondary = bio_fd.getvalue()
     cls.repo, cls.importer, cls.distributor = create_yum_repo(cls.pulp, **[repo for repo in cls.ROLES.repos if repo.type == 'rpm'][0])
     cls.consumer = Consumer.register(cls.pulp, cls.__name__ + '_consumer', rsa_pub=cls.pub_pem_primary)
     cls.agent = Agent(pulp_auto.handler, PROFILE=pulp_auto.handler.profile.PROFILE)
     cls.qpid_handle = QpidHandle(cls.ROLES.qpid.url, cls.consumer.id, auth=Authenticator(signing_key=cls.rsa_primary, verifying_key=cls.pulp.pubkey))
 def test_01(self):
     errors = 0
     # change the range to 300-600 and run it separately from the rest of testcases
     for i in xrange(3):
         with self.agent.catching(True), self.agent.running(
                 self.qpid_handle, frequency=10):
             try:
                 self.bindRepo()
                 self._tearDown()
             except (TaskFailure, TaskTimeoutError) as error:
                 print '> ',
                 errors += 1
                 print error
         self.repo, self.importer, self.distributor = create_yum_repo(
             self.pulp,
             **[repo for repo in self.ROLES.repos if repo.type == 'rpm'][0])
         print i
     print "errors", errors
 def testcase_01_upload_and_download_using_dnf_rpm(self):
     # create yum-repo, -importer, -distributor
     with deleting(self.pulp, *create_yum_repo(self.pulp, 'test_22_rpm_repo_for_dnf')) as (repo, (importer, (distributor))):
         # create and perform an rpm url upload
         with deleting(self.pulp, upload_url_rpm(self.pulp, self.rpm_url)) as upload:
             # assign the upload to the repo
             response = upload.import_to(self.pulp, repo)
             self.assertPulpOK()
             Task.wait_for_report(self.pulp, response)
             # check the content is accessible
             response = repo.publish(self.pulp, distributor.id)
             self.assertPulpOK()
             Task.wait_for_report(self.pulp, response)
             # fetch the package through the repo
             pulp_rpm_url = distributor.content_url(self.pulp, url_basename(self.rpm_url))
             pulp_repo = distributor.content_url(self.pulp)
             with closing(temp_url(pulp_rpm_url)) as tmpfile:
                 assert url_basename(self.rpm_url).startswith(rpm_metadata(tmpfile)['unit_key']['name'])
             assert "bear" == download_package_with_dnf(self.pulp, pulp_repo, "bear")
 def _test_02_repo_publish_finish(self):
     self.el.update(self.pulp, {'event_listener': ['repo.publish.finish']})
     self.el.reload(self.pulp)
     with deleting(self.pulp, *create_yum_repo(self.pulp, 'publish_error_repo',
                 feed='https://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/')) as (repo, (importer, distributor)):
         response = repo.publish(self.pulp, 'invalid_distributor_id')
         self.assertPulpOK()
         with self.assertRaises(TaskFailure):
             # make sure the publish task failed
             Task.wait_for_report(self.pulp, response)
         task = Task.from_report(self.pulp, response)
         # assert the bin contains a request with a fained task in body
         self.bin.reload()
         assert self.bin.request_count == 1, 'invalid bin.request_count: %s' % self.bin.request_count
         el_request = self.bin.requests[0]
         assert el_request.method == 'POST', 'invalid bin request method: %s' % el_request.method
         el_task = Task.from_call_report_data(json.loads(el_request.body))
         assert el_task.state == TASK_ERROR_STATE, 'invalid request.body:Task.state: %s' % el_task.state
         assert el_task.id in [task.id for task in tasks], 'invalid request.body:Task.id: %s' % el_task.id
 def test_01_repo_sync_finish(self):
     self.el.update(self.pulp, {'event_types': ['repo.sync.finish']})
     self.el.reload(self.pulp)
     with deleting(self.pulp, *create_yum_repo(self.pulp, 'sync_error_repo',
                 feed='http://example.com/repos/none')) as (repo, (importer, distributor)):
         response = repo.sync(self.pulp)
         self.assertPulpOK()
         with self.assertRaises(TaskFailure):
             # make sure the sync did not succeed
             Task.wait_for_report(self.pulp, response)
         tasks = Task.from_report(self.pulp, response)
         # assert the bin contains request with a failed task in body
         self.bin.reload()
         assert self.bin.request_count == 1, 'invalid bin.request count: %s' % self.bin.request_count
         el_request = self.bin.requests[0]
         assert el_request.method == 'POST', 'invalid bin request method: %s' % el_request.method
         el_task = Task.from_call_report_data(json.loads(el_request.body))
         assert el_task.state == TASK_ERROR_STATE, 'invalid request.body:Task.state: %s' % el_task.state
         assert el_task.id in [task.id for task in tasks], 'invalid request.body:Task.id: %s' % el_task.id
    def setUpClass(cls):
        super(PublishGroupTest, cls).setUpClass()
        # create repo_group
        repo_group = RepoGroup(data={"id": cls.__name__ + "_repo_group"})
        response = repo_group.create(cls.pulp)
        cls.repo_group = RepoGroup.from_response(response)
        cls.repo_group1 = RepoGroup(data={"id": cls.__name__ + "_repo_group1"})

        # associate_distributor
        with cls.pulp.asserting(True):
            response = cls.repo_group.associate_distributor(
                cls.pulp,
                data={
                    "distributor_type_id": "group_export_distributor",
                    "distributor_config": {"http": False, "https": False},
                    "distributor_id": "dist_1",
                },
            )
        cls.distributor = GroupDistributor.from_response(response)
        # create repo
        repo_config = [repo for repo in ROLES.repos if repo.type == "rpm"][0]
        cls.repo, _, _ = create_yum_repo(cls.pulp, **repo_config)
        Task.wait_for_report(cls.pulp, cls.repo.sync(cls.pulp))
    def setUpClass(cls):
        super(CliConsumerTest, cls).setUpClass()
        # create all repos
        # get repo configs across all consumers
        repo_configs = sum([consumer.repos for consumer in ROLES.consumers], [])
        # filter&uniq repo configs
        repo_configs = {repo.id: repo for repo in repo_configs if repo.type == 'rpm'}.values()
        with cls.pulp.asserting(True):
            cls.repos = [ create_yum_repo(cls.pulp, **repo_config) for repo_config in repo_configs ]

        # sync&publish all repos
        with cls.pulp.asserting(True):
            task_reports = [repo.sync(cls.pulp) for repo, _, _ in cls.repos]
        Task.wait_for_reports(cls.pulp, task_reports)

        with cls.pulp.asserting(True):
            task_reports = [ repo.publish(cls.pulp, distributor.id) for repo, _, distributor in cls.repos]
        Task.wait_for_reports(cls.pulp, task_reports)

        # create all consumers
        # gather all consumers
        consumer_configs = {consumer.id: consumer for consumer in ROLES.consumers}
        with cls.pulp.asserting(True):
            cls.consumers = [Consumer(consumer_config) for consumer_config in consumer_configs.values()]

        # set up consumer cli & link repos
        for consumer in cls.consumers:
            setattr(consumer, 'cli', Cli.ready_instance(**consumer_configs[consumer.id]))
            setattr(
                consumer,
                'repos',
                filter(
                    lambda (repo, importer, distributor): any(repo.id == repo_config.id for repo_config in consumer_configs[consumer.id].repos),
                    cls.repos
                )
            )
 def testcase_02_upload_rpm(self):
     # create yum-repo, -importer, -distributor
     with deleting(self.pulp, *create_yum_repo(self.pulp, 'upload_test_rpm_repo')) as (repo, (importer, (distributor))):
         # create and perform an rpm url upload
         self.rpm_uploader(self.pulp, self.rpm_url_bear, repo, distributor)