Example #1
0
    def test_add_docker_repo_to_composite_content_view(self):
        """@Test: Add one Docker-type repository to a composite content view

        @Assert: A repository is created with a Docker repository and the
        product is added to a content view which is then added to a composite
        content view.

        @Feature: Docker

        """
        self._create_and_associate_repo_with_cv()
        ContentView.publish({'id': self.content_view['id']})
        self.content_view = ContentView.info({
            'id': self.content_view['id']})
        self.assertEqual(len(self.content_view['versions']), 1)
        comp_content_view = make_content_view({
            'composite': True,
            'organization-id': self.org_id,
        })
        ContentView.update({
            'id': comp_content_view['id'],
            'component-ids': self.content_view['versions'][0]['id'],
        })
        comp_content_view = ContentView.info({
            'id': comp_content_view['id'],
        })
        self.assertIn(
            self.content_view['versions'][0]['id'],
            [component['id'] for component in comp_content_view['components']],
        )
    def test_positive_update_aks_to_chost(self):
        """Check if multiple Activation keys can be attached to a
        Content host

        @Feature: Activation key - Content host

        @Assert: Multiple Activation keys are attached to a Content host
        """
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        new_aks = [
            make_activation_key({
                u'lifecycle-environment-id': env['id'],
                u'content-view': new_cv['name'],
                u'organization-id': self.org['id'],
            })
            for _ in range(2)
        ]
        with VirtualMachine(distro='rhel65') as vm:
            vm.install_katello_ca()
            for i in range(2):
                result = vm.register_contenthost(
                    new_aks[i]['name'], self.org['label'])
                self.assertEqual(result.return_code, 0)
Example #3
0
 def setup_content_view(self, org_id, lce_id=None):
     # type: (int, int) -> Tuple[Dict, Dict]
     """Setup organization content view by adding all the repositories, publishing and promoting
     to lce if needed.
     """
     if lce_id is None:
         lce = make_lifecycle_environment({'organization-id': org_id})
     else:
         lce = LifecycleEnvironment.info({
             'id': lce_id,
             'organization-id': org_id,
         })
     content_view = make_content_view({'organization-id': org_id})
     # Add repositories to content view
     for repo in self:
         repo.add_to_content_view(org_id, content_view['id'])
     # Publish the content view
     ContentView.publish({'id': content_view['id']})
     if lce['name'] != ENVIRONMENT:
         # Get the latest content view version id
         content_view_version = ContentView.info({'id': content_view['id']
                                                  })['versions'][-1]
         # Promote content view version to lifecycle environment
         ContentView.version_promote({
             'id':
             content_view_version['id'],
             'organization-id':
             org_id,
             'to-lifecycle-environment-id':
             lce['id'],
         })
     content_view = ContentView.info({'id': content_view['id']})
     return content_view, lce
    def test_positive_update_lce(self):
        """Update Environment in an Activation key

        @Feature: Activation key - Positive Update

        @Assert: Activation key is updated
        """
        ak_env = self._make_activation_key({
            u'lifecycle-environment-id': self.get_default_env()['id'],
        })
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        ActivationKey.update({
            u'id': ak_env['id'],
            u'lifecycle-environment-id': env['id'],
            u'content-view': new_cv['name'],
            u'organization-id': self.org['id'],
        })
        updated_ak = ActivationKey.info({'id': ak_env['id']})
        self.assertEqual(updated_ak['lifecycle-environment'], env['name'])
    def setUp(self):
        """Tests for Host Collections via Hammer CLI"""
        super(HostCollectionTestCase, self).setUp()

        if HostCollectionTestCase.org is None:
            HostCollectionTestCase.org = make_org(cached=True)
        if HostCollectionTestCase.new_lifecycle is None:
            HostCollectionTestCase.new_lifecycle = make_lifecycle_environment(
                {u"organization-id": HostCollectionTestCase.org["id"]}, cached=True
            )
        if HostCollectionTestCase.library is None:
            HostCollectionTestCase.library = LifecycleEnvironment.info(
                {u"organization-id": HostCollectionTestCase.org["id"], u"name": ENVIRONMENT}
            )
        if HostCollectionTestCase.default_cv is None:
            HostCollectionTestCase.default_cv = ContentView.info(
                {u"organization-id": HostCollectionTestCase.org["id"], u"name": DEFAULT_CV}
            )
        if HostCollectionTestCase.new_cv is None:
            HostCollectionTestCase.new_cv = make_content_view({u"organization-id": HostCollectionTestCase.org["id"]})
            HostCollectionTestCase.promoted_cv = None
            cv_id = HostCollectionTestCase.new_cv["id"]
            ContentView.publish({u"id": cv_id})
            result = ContentView.version_list({u"content-view-id": cv_id})
            version_id = result[0]["id"]
            ContentView.version_promote(
                {
                    u"id": version_id,
                    u"organization-id": HostCollectionTestCase.org["id"],
                    u"to-lifecycle-environment-id": (HostCollectionTestCase.new_lifecycle["id"]),
                }
            )
            HostCollectionTestCase.promoted_cv = HostCollectionTestCase.new_cv
Example #6
0
    def test_promote_multiple_docker_repo_content_view(self):
        """@Test: Add Docker-type repository to content view and publish it.
        Then promote it to multiple available lifecycle-environments.

        @Assert: Docker-type repository is promoted to content view found in
        the specific lifecycle-environments.

        @Feature: Docker

        """
        self._create_and_associate_repo_with_cv()
        ContentView.publish({'id': self.content_view['id']})
        self.content_view = ContentView.info({
            'id': self.content_view['id']})
        self.assertEqual(len(self.content_view['versions']), 1)
        cvv = ContentView.version_info({
            'id': self.content_view['versions'][0]['id'],
        })
        self.assertEqual(len(cvv['lifecycle-environments']), 1)
        for i in range(1, randint(3, 6)):
            lce = make_lifecycle_environment({'organization-id': self.org_id})
            ContentView.version_promote({
                'id': cvv['id'],
                'lifecycle-environment-id': lce['id'],
            })
            cvv = ContentView.version_info({
                'id': self.content_view['versions'][0]['id'],
            })
            self.assertEqual(len(cvv['lifecycle-environments']), i+1)
 def setUpClass(cls):
     """Tests for Content Host via Hammer CLI"""
     super(ContentHostTestCase, cls).setUpClass()
     ContentHostTestCase.NEW_ORG = make_org(cached=True)
     ContentHostTestCase.NEW_LIFECYCLE = make_lifecycle_environment(
         {u'organization-id': ContentHostTestCase.NEW_ORG['id']},
         cached=True
     )
     ContentHostTestCase.LIBRARY = LifecycleEnvironment.info({
         u'organization-id': ContentHostTestCase.NEW_ORG['id'],
         u'name': u'Library',
     })
     ContentHostTestCase.DEFAULT_CV = ContentView.info({
         u'organization-id': ContentHostTestCase.NEW_ORG['id'],
         u'name': u'Default Organization View',
     })
     ContentHostTestCase.NEW_CV = make_content_view({
         u'organization-id': ContentHostTestCase.NEW_ORG['id'],
     })
     cv_id = ContentHostTestCase.NEW_CV['id']
     ContentView.publish({u'id': cv_id})
     version_id = ContentView.version_list({
         u'content-view-id': cv_id,
     })[0]['id']
     ContentView.version_promote({
         u'id': version_id,
         u'to-lifecycle-environment-id': ContentHostTestCase.NEW_LIFECYCLE[
             'id'
         ],
         u'organization-id': ContentHostTestCase.NEW_ORG['id']
     })
     ContentHostTestCase.PROMOTED_CV = ContentHostTestCase.NEW_CV
Example #8
0
    def test_positive_update_aks_to_chost(self):
        """@Test: Check if multiple Activation keys can be attached to a
        Content host

        @Feature: Activation key - Content host

        @Assert: Multiple Activation keys are attached to a Content host
        """
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        new_aks = [
            make_activation_key({
                u'lifecycle-environment-id': env['id'],
                u'content-view': new_cv['name'],
                u'organization-id': self.org['id'],
            })
            for _ in range(2)
        ]
        with VirtualMachine(distro='rhel65') as vm:
            vm.install_katello_ca()
            for i in range(2):
                result = vm.register_contenthost(
                    new_aks[i]['name'], self.org['label'])
                self.assertEqual(result.return_code, 0)
Example #9
0
    def test_positive_update_lce(self):
        """Update Environment in an Activation key

        :id: 55aaee60-b8c8-49f0-995a-6c526b9b653b

        :expectedresults: Activation key is updated

        :CaseLevel: Integration
        """
        ak_env = self._make_activation_key({
            u'lifecycle-environment-id': self.get_default_env()['id'],
        })
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        ActivationKey.update({
            u'id': ak_env['id'],
            u'lifecycle-environment-id': env['id'],
            u'content-view': new_cv['name'],
            u'organization-id': self.org['id'],
        })
        updated_ak = ActivationKey.info({'id': ak_env['id']})
        self.assertEqual(updated_ak['lifecycle-environment'], env['name'])
Example #10
0
 def setUpClass(cls):
     """Create necessary objects which can be re-used in tests."""
     super(DockerActivationKeyTestCase, cls).setUpClass()
     cls.org = make_org()
     cls.lce = make_lifecycle_environment({
         'organization-id': cls.org['id'],
     })
     cls.product = make_product({
         'organization-id': cls.org['id'],
     })
     cls.repo = _make_docker_repo(cls.product['id'])
     cls.content_view = make_content_view({
         'composite': False,
         'organization-id': cls.org['id'],
     })
     ContentView.add_repository({
         'id': cls.content_view['id'],
         'repository-id': cls.repo['id'],
     })
     cls.content_view = ContentView.info({
         'id': cls.content_view['id']
     })
     ContentView.publish({'id': cls.content_view['id']})
     cls.content_view = ContentView.info({
         'id': cls.content_view['id']})
     cls.cvv = ContentView.version_info({
         'id': cls.content_view['versions'][0]['id'],
     })
     ContentView.version_promote({
         'id': cls.content_view['versions'][0]['id'],
         'lifecycle-environment-id': cls.lce['id'],
     })
     cls.cvv = ContentView.version_info({
         'id': cls.content_view['versions'][0]['id'],
     })
    def test_positive_update_aks_to_chost(self):
        """Check if multiple Activation keys can be attached to a
        Content host

        @Feature: Activation key - Content host

        @Assert: Multiple Activation keys are attached to a Content host
        """
        env = make_lifecycle_environment({u"organization-id": self.org["id"]})
        new_cv = make_content_view({u"organization-id": self.org["id"]})
        ContentView.publish({u"id": new_cv["id"]})
        cvv = ContentView.info({u"id": new_cv["id"]})["versions"][0]
        ContentView.version_promote({u"id": cvv["id"], u"to-lifecycle-environment-id": env["id"]})
        new_aks = [
            make_activation_key(
                {
                    u"lifecycle-environment-id": env["id"],
                    u"content-view": new_cv["name"],
                    u"organization-id": self.org["id"],
                }
            )
            for _ in range(2)
        ]
        with VirtualMachine(distro="rhel65") as vm:
            vm.install_katello_ca()
            for i in range(2):
                result = vm.register_contenthost(new_aks[i]["name"], self.org["label"])
                self.assertEqual(result.return_code, 0)
 def setUpClass(cls):
     """Create Directory for all CV Sync Tests in /tmp"""
     super(ContentViewSync, cls).setUpClass()
     cls.exporting_org = make_org()
     cls.exporting_prod = gen_string('alpha')
     product = make_product({
         'organization-id': cls.exporting_org['id'],
         'name': cls.exporting_prod
     })
     cls.exporting_repo = gen_string('alpha')
     repo = make_repository({
         'name': cls.exporting_repo,
         'download-policy': 'immediate',
         'product-id': product['id']
     })
     Repository.synchronize({'id': repo['id']})
     cls.exporting_cv = gen_string('alpha')
     content_view = make_content_view({
         'name': cls.exporting_cv,
         'organization-id': cls.exporting_org['id']
     })
     ContentView.add_repository({
         'id': content_view['id'],
         'organization-id': cls.exporting_org['id'],
         'repository-id': repo['id']
     })
     ContentView.publish({u'id': content_view['id']})
     content_view = ContentView.info({u'id': content_view['id']})
     cls.exporting_cvv_id = content_view['versions'][0]['id']
Example #13
0
    def test_positive_sync_publish_cv(self):
        """Synchronize repository with SRPMs, add repository to content view
        and publish content view

        @id: 78cd6345-9c6c-490a-a44d-2ad64b7e959b

        @Assert: srpms can be listed in content view
        """
        repo = make_repository({
            'product-id': self.product['id'],
            'url': FAKE_YUM_SRPM_REPO,
        })
        Repository.synchronize({'id': repo['id']})
        cv = make_content_view({'organization-id': self.org['id']})
        ContentView.add_repository({
            'id': cv['id'],
            'repository-id': repo['id'],
        })
        ContentView.publish({'id': cv['id']})
        result = ssh.command(
            'ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}'
            '/1.0/custom/{}/{}/ | grep .src.rpm'.format(
                self.org['label'],
                cv['label'],
                self.product['label'],
                repo['label'],
            ))
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)
Example #14
0
 def setup_content_view(self, org_id, lce_id=None):
     # type: (int, int) -> Tuple[Dict, Dict]
     """Setup organization content view by adding all the repositories, publishing and promoting
     to lce if needed.
     """
     if lce_id is None:
         lce = make_lifecycle_environment({'organization-id': org_id})
     else:
         lce = LifecycleEnvironment.info({
             'id': lce_id,
             'organization-id': org_id,
         })
     content_view = make_content_view({'organization-id': org_id})
     # Add repositories to content view
     for repo in self:
         repo.add_to_content_view(org_id, content_view['id'])
     # Publish the content view
     ContentView.publish({'id': content_view['id']})
     if lce['name'] != ENVIRONMENT:
         # Get the latest content view version id
         content_view_version = ContentView.info({
             'id': content_view['id']
         })['versions'][-1]
         # Promote content view version to lifecycle environment
         ContentView.version_promote({
             'id': content_view_version['id'],
             'organization-id': org_id,
             'to-lifecycle-environment-id': lce['id'],
         })
     content_view = ContentView.info({'id': content_view['id']})
     return content_view, lce
Example #15
0
def setup_content(request):
    """Pytest fixture for setting up an organization, manifest, content-view,
    lifecycle environment, and activation key with subscriptions"""
    org = make_org()
    with manifests.clone() as manifest:
        upload_file(manifest.content, manifest.filename)
    new_product = make_product({'organization-id': org['id']})
    new_repo = make_repository({'product-id': new_product['id']})
    Repository.synchronize({'id': new_repo['id']})
    content_view = make_content_view({'organization-id': org['id']})
    ContentView.add_repository(
        {'id': content_view['id'], 'organization-id': org['id'], 'repository-id': new_repo['id']}
    )
    ContentView.publish({'id': content_view['id']})
    env = make_lifecycle_environment({'organization-id': org['id']})
    cvv = ContentView.info({'id': content_view['id']})['versions'][0]
    ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env['id']})
    new_ak = make_activation_key(
        {
            'lifecycle-environment-id': env['id'],
            'content-view': content_view['name'],
            'organization-id': org['id'],
            'auto-attach': False,
        }
    )
    subs_id = Subscription.list({'organization-id': org['id']}, per_page=False)
    ActivationKey.add_subscription({'id': new_ak['id'], 'subscription-id': subs_id[0]['id']})
    request.cls.setup_org = org
    request.cls.setup_new_ak = new_ak
    request.cls.setup_subs_id = subs_id
    request.cls.setup_env = env
    request.cls.setup_content_view = content_view
Example #16
0
    def test_positive_update_aks_to_chost(self):
        """Check if multiple Activation keys can be attached to a
        Content host

        :id: 24fddd9c-03ae-41a7-8649-72296cbbafdf

        :expectedresults: Multiple Activation keys are attached to a Content
            host

        :CaseLevel: System
        """
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        new_aks = [
            make_activation_key({
                u'lifecycle-environment-id': env['id'],
                u'content-view': new_cv['name'],
                u'organization-id': self.org['id'],
            })
            for _ in range(2)
        ]
        with VirtualMachine(distro=DISTRO_RHEL6) as vm:
            vm.install_katello_ca()
            for i in range(2):
                vm.register_contenthost(
                    self.org['label'], new_aks[i]['name'])
                self.assertTrue(vm.subscribed)
Example #17
0
    def test_positive_update_lce(self):
        """@Test: Update Environment in an Activation key

        @Feature: Activation key - Positive Update

        @Assert: Activation key is updated
        """
        ak_env = self._make_activation_key({
            u'lifecycle-environment-id': self.get_default_env()['id'],
        })
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        ActivationKey.update({
            u'id': ak_env['id'],
            u'lifecycle-environment-id': env['id'],
            u'content-view': new_cv['name'],
            u'organization-id': self.org['id'],
        })
        updated_ak = ActivationKey.info({'id': ak_env['id']})
        self.assertEqual(updated_ak['lifecycle-environment'], env['name'])
Example #18
0
    def test_positive_sync_publish_promote_cv(self):
        """Synchronize repository with DRPMs, add repository to content view,
        publish and promote content view to lifecycle environment

        @id: a01cb12b-d388-4902-8532-714f4e28ec56

        @Assert: drpms can be listed in content view in proper lifecycle
        environment
        """
        lce = make_lifecycle_environment({"organization-id": self.org["id"]})
        repo = make_repository({"product-id": self.product["id"], "url": FAKE_YUM_DRPM_REPO})
        Repository.synchronize({"id": repo["id"]})
        cv = make_content_view({"organization-id": self.org["id"]})
        ContentView.add_repository({"id": cv["id"], "repository-id": repo["id"]})
        ContentView.publish({"id": cv["id"]})
        content_view = ContentView.info({"id": cv["id"]})
        cvv = content_view["versions"][0]
        ContentView.version_promote({"id": cvv["id"], "to-lifecycle-environment-id": lce["id"]})
        result = ssh.command(
            "ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}"
            "/drpms/ | grep .drpm".format(
                self.org["label"], lce["label"], cv["label"], self.product["label"], repo["label"]
            )
        )
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)
Example #19
0
    def test_positive_update_lce(self):
        """Update Environment in an Activation key

        :id: 55aaee60-b8c8-49f0-995a-6c526b9b653b

        :expectedresults: Activation key is updated

        :CaseLevel: Integration
        """
        ak_env = self._make_activation_key({
            u'lifecycle-environment-id': self.get_default_env()['id'],
        })
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        ActivationKey.update({
            u'id': ak_env['id'],
            u'lifecycle-environment-id': env['id'],
            u'content-view': new_cv['name'],
            u'organization-id': self.org['id'],
        })
        updated_ak = ActivationKey.info({'id': ak_env['id']})
        self.assertEqual(updated_ak['lifecycle-environment'], env['name'])
Example #20
0
    def test_positive_update_aks_to_chost(self):
        """Check if multiple Activation keys can be attached to a
        Content host

        :id: 24fddd9c-03ae-41a7-8649-72296cbbafdf

        :expectedresults: Multiple Activation keys are attached to a Content
            host

        :CaseLevel: System
        """
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        new_aks = [
            make_activation_key({
                u'lifecycle-environment-id': env['id'],
                u'content-view': new_cv['name'],
                u'organization-id': self.org['id'],
            })
            for _ in range(2)
        ]
        with VirtualMachine(distro=DISTRO_RHEL6) as vm:
            vm.install_katello_ca()
            for i in range(2):
                vm.register_contenthost(
                    self.org['label'], new_aks[i]['name'])
                self.assertTrue(vm.subscribed)
Example #21
0
 def setUpClass(cls):
     """Tests for Content Host via Hammer CLI"""
     super(ContentHostTestCase, cls).setUpClass()
     ContentHostTestCase.NEW_ORG = make_org(cached=True)
     ContentHostTestCase.NEW_LIFECYCLE = make_lifecycle_environment(
         {u"organization-id": ContentHostTestCase.NEW_ORG["id"]}, cached=True
     )
     ContentHostTestCase.LIBRARY = LifecycleEnvironment.info(
         {u"organization-id": ContentHostTestCase.NEW_ORG["id"], u"name": u"Library"}
     )
     ContentHostTestCase.DEFAULT_CV = ContentView.info(
         {u"organization-id": ContentHostTestCase.NEW_ORG["id"], u"name": u"Default Organization View"}
     )
     ContentHostTestCase.NEW_CV = make_content_view({u"organization-id": ContentHostTestCase.NEW_ORG["id"]})
     cv_id = ContentHostTestCase.NEW_CV["id"]
     ContentView.publish({u"id": cv_id})
     version_id = ContentView.version_list({u"content-view-id": cv_id})[0]["id"]
     ContentView.version_promote(
         {
             u"id": version_id,
             u"to-lifecycle-environment-id": ContentHostTestCase.NEW_LIFECYCLE["id"],
             u"organization-id": ContentHostTestCase.NEW_ORG["id"],
         }
     )
     ContentHostTestCase.PROMOTED_CV = ContentHostTestCase.NEW_CV
Example #22
0
    def test_positive_sync_publish_cv(self):
        """Synchronize repository with DRPMs, add repository to content view
        and publish content view

        @id: 014bfc80-4622-422e-a0ec-755b1d9f845e

        @Assert: drpms can be listed in content view
        """
        repo = make_repository({
            'product-id': self.product['id'],
            'url': FAKE_YUM_DRPM_REPO,
        })
        Repository.synchronize({'id': repo['id']})
        cv = make_content_view({'organization-id': self.org['id']})
        ContentView.add_repository({
            'id': cv['id'],
            'repository-id': repo['id'],
        })
        ContentView.publish({'id': cv['id']})
        result = ssh.command(
            'ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}'
            '/1.0/custom/{}/{}/drpms/ | grep .drpm'.format(
                self.org['label'],
                cv['label'],
                self.product['label'],
                repo['label'],
            ))
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)
Example #23
0
    def test_promote_docker_repo_composite_content_view(self):
        """@Test: Add Docker-type repository to composite content view and
        publish it. Then promote it to the next available
        lifecycle-environment.

        @Assert: Docker-type repository is promoted to content view found in
        the specific lifecycle-environment.

        @Feature: Docker

        """
        self._create_and_associate_repo_with_cv()
        ContentView.publish({'id': self.content_view['id']})
        self.content_view = ContentView.info({
            'id': self.content_view['id']})
        self.assertEqual(len(self.content_view['versions']), 1)
        comp_content_view = make_content_view({
            'composite': True,
            'organization-id': self.org_id,
        })
        ContentView.update({
            'component-ids': self.content_view['versions'][0]['id'],
            'id': comp_content_view['id'],
        })
        comp_content_view = ContentView.info({
            'id': comp_content_view['id'],
        })
        self.assertIn(
            self.content_view['versions'][0]['id'],
            [
                component['id']
                for component
                in comp_content_view['components']
            ],
        )
        ContentView.publish({'id': comp_content_view['id']})
        comp_content_view = ContentView.info({
            'id': comp_content_view['id'],
        })
        cvv = ContentView.version_info({
            'id': comp_content_view['versions'][0]['id'],
        })
        self.assertEqual(len(cvv['lifecycle-environments']), 1)
        lce = make_lifecycle_environment({'organization-id': self.org_id})
        ContentView.version_promote({
            'id': comp_content_view['versions'][0]['id'],
            'lifecycle-environment-id': lce['id'],
        })
        cvv = ContentView.version_info({
            'id': comp_content_view['versions'][0]['id'],
        })
        self.assertEqual(len(cvv['lifecycle-environments']), 2)
Example #24
0
def local_content_view(local_org):
    """Create content view, repository, and product"""
    new_product = make_product({'organization-id': local_org['id']})
    new_repo = make_repository({'product-id': new_product['id']})
    Repository.synchronize({'id': new_repo['id']})
    content_view = make_content_view({'organization-id': local_org['id']})
    ContentView.add_repository({
        'id': content_view['id'],
        'organization-id': local_org['id'],
        'repository-id': new_repo['id'],
    })
    ContentView.publish({'id': content_view['id']})
    return content_view
Example #25
0
    def test_add_docker_repo_composite_view_to_activation_key(self):
        """@Test: Add Docker-type repository to a non-composite content view
        and publish it. Then add this content view to a composite content view
        and publish it. Create an activation key and associate it with the
        composite Docker content view.

        @Assert: Docker-based content view can be added to activation key

        @Feature: Docker

        """
        comp_content_view = make_content_view({
            'composite': True,
            'organization-id': self.org['id'],
        })
        ContentView.update({
            'component-ids': self.content_view['versions'][0]['id'],
            'id': comp_content_view['id'],
        })
        comp_content_view = ContentView.info({
            'id': comp_content_view['id'],
        })
        self.assertIn(
            self.content_view['versions'][0]['id'],
            [
                component['id']
                for component
                in comp_content_view['components']
            ],
        )
        ContentView.publish({'id': comp_content_view['id']})
        comp_content_view = ContentView.info({
            'id': comp_content_view['id'],
        })
        comp_cvv = ContentView.version_info({
            'id': comp_content_view['versions'][0]['id'],
        })
        ContentView.version_promote({
            'id': comp_cvv['id'],
            'lifecycle-environment-id': self.lce['id'],
        })
        activation_key = make_activation_key({
            'content-view-id': comp_content_view['id'],
            'lifecycle-environment-id': self.lce['id'],
            'organization-id': self.org['id'],
        })
        self.assertEqual(
            activation_key['content-view'], comp_content_view['name'])
 def setUpClass(cls):
     """Create an organization, product and ostree repo."""
     super(OstreeBranchTestCase, cls).setUpClass()
     cls.org = make_org()
     cls.product = make_product({u'organization-id': cls.org['id']})
     # Create new custom ostree repo
     cls.ostree_repo = make_repository({
         u'product-id': cls.product['id'],
         u'content-type': u'ostree',
         u'publish-via-http': u'false',
         u'url': FEDORA23_OSTREE_REPO,
     })
     Repository.synchronize({'id': cls.ostree_repo['id']})
     cls.cv = make_content_view({u'organization-id': cls.org['id']})
     ContentView.publish({u'id': cls.cv['id']})
     cls.cv = ContentView.info({u'id': cls.cv['id']})
Example #27
0
 def setUpClass(cls):
     """Create an organization, product and ostree repo."""
     super(OstreeBranchTestCase, cls).setUpClass()
     cls.org = make_org()
     cls.product = make_product({u'organization-id': cls.org['id']})
     # Create new custom ostree repo
     cls.ostree_repo = make_repository({
         u'product-id': cls.product['id'],
         u'content-type': u'ostree',
         u'publish-via-http': u'false',
         u'url': FEDORA23_OSTREE_REPO,
     })
     Repository.synchronize({'id': cls.ostree_repo['id']})
     cls.cv = make_content_view({u'organization-id': cls.org['id']})
     ContentView.publish({u'id': cls.cv['id']})
     cls.cv = ContentView.info({u'id': cls.cv['id']})
Example #28
0
    def test_add_multiple_docker_repos_to_composite_content_view(self):
        """@Test: Add multiple Docker-type repositories to a composite
        content view.

        @Assert: One repository is created with a Docker image and the
        product is added to a random number of content views which are then
        added to a composite content view.

        @Feature: Docker

        """
        cv_versions = []
        product = make_product({'organization-id': self.org_id})
        for _ in range(randint(2, 5)):
            content_view = make_content_view({
                'composite': False,
                'organization-id': self.org_id,
            })
            repo = _make_docker_repo(product['id'])
            ContentView.add_repository({
                'id': content_view['id'],
                'repository-id': repo['id'],
            })
            ContentView.publish({'id': content_view['id']})
            content_view = ContentView.info({'id': content_view['id']})
            self.assertEqual(len(content_view['versions']), 1)
            cv_versions.append(content_view['versions'][0])
        comp_content_view = make_content_view({
            'composite': True,
            'organization-id': self.org_id,
        })
        ContentView.update({
            'component-ids': [cv_version['id'] for cv_version in cv_versions],
            'id': comp_content_view['id'],
        })
        comp_content_view = ContentView.info({
            'id': comp_content_view['id'],
        })
        for cv_version in cv_versions:
            self.assertIn(
                cv_version['id'],
                [
                    component['id']
                    for component
                    in comp_content_view['components']
                ],
            )
Example #29
0
def cv_publish_promote(cv, org, lce):
    """Publish and promote a new version into the given lifecycle environment.

    :param cv: content view
    :type cv: entities.ContentView
    :param org: organization
    :type org: entities.Organization
    :param lce: lifecycle environment
    :type lce: entities.LifecycleEnvironment
    """
    ContentView.publish({'id': cv.id})
    cvv = ContentView.info({'id': cv.id})['versions'][-1]
    ContentView.version_promote({
        'id': cvv['id'],
        'organization-id': org.id,
        'to-lifecycle-environment-id': lce.id,
    })
Example #30
0
    def test_publish_once_docker_repo_content_view(self):
        """@Test: Add Docker-type repository to content view and publish
        it once.

        @Assert: One repository is created with a Docker image and the product
        is added to a content view which is then published only once.

        @Feature: Docker

        """
        self._create_and_associate_repo_with_cv()
        self.assertEqual(len(self.content_view['versions']), 0)
        ContentView.publish({'id': self.content_view['id']})
        self.content_view = ContentView.info({
            'id': self.content_view['id'],
        })
        self.assertEqual(len(self.content_view['versions']), 1)
Example #31
0
    def setUp(self):  # noqa
        """Tests for Host Collections via Hammer CLI"""

        super(TestHostCollection, self).setUp()

        if TestHostCollection.org is None:
            TestHostCollection.org = make_org(cached=True)
        if TestHostCollection.new_lifecycle is None:
            TestHostCollection.new_lifecycle = make_lifecycle_environment(
                {u'organization-id': TestHostCollection.org['id']},
                cached=True)
        if TestHostCollection.library is None:
            library_result = LifecycleEnvironment.info({
                u'organization-id':
                TestHostCollection.org['id'],
                u'name':
                u'Library'
            })
            TestHostCollection.library = library_result.stdout
        if TestHostCollection.default_cv is None:
            cv_result = ContentView.info({
                u'organization-id':
                TestHostCollection.org['id'],
                u'name':
                u'Default Organization View'
            })
            TestHostCollection.default_cv = cv_result.stdout
        if TestHostCollection.new_cv is None:
            TestHostCollection.new_cv = make_content_view(
                {u'organization-id': TestHostCollection.org['id']})
            TestHostCollection.promoted_cv = None
            cv_id = TestHostCollection.new_cv['id']
            ContentView.publish({u'id': cv_id})
            result = ContentView.version_list({u'content-view-id': cv_id})
            version_id = result.stdout[0]['id']
            promotion = ContentView.version_promote({
                u'id':
                version_id,
                u'to-lifecycle-environment-id':
                (TestHostCollection.new_lifecycle['id']),
                u'organization-id':
                TestHostCollection.org['id']
            })
            if promotion.stderr == []:
                TestHostCollection.promoted_cv = TestHostCollection.new_cv
Example #32
0
    def setUp(self):  # noqa
        """Tests for Content Host via Hammer CLI"""

        super(TestContentHost, self).setUp()

        if TestContentHost.NEW_ORG is None:
            TestContentHost.NEW_ORG = make_org(cached=True)
        if TestContentHost.NEW_LIFECYCLE is None:
            TestContentHost.NEW_LIFECYCLE = make_lifecycle_environment(
                {u'organization-id': TestContentHost.NEW_ORG['id']},
                cached=True)
        if TestContentHost.LIBRARY is None:
            library_result = LifecycleEnvironment.info({
                u'organization-id':
                TestContentHost.NEW_ORG['id'],
                u'name':
                u'Library'
            })
            TestContentHost.LIBRARY = library_result.stdout
        if TestContentHost.DEFAULT_CV is None:
            cv_result = ContentView.info({
                u'organization-id':
                TestContentHost.NEW_ORG['id'],
                u'name':
                u'Default Organization View'
            })
            TestContentHost.DEFAULT_CV = cv_result.stdout
        if TestContentHost.NEW_CV is None:
            TestContentHost.NEW_CV = make_content_view(
                {u'organization-id': TestContentHost.NEW_ORG['id']})
            TestContentHost.PROMOTED_CV = None
            cv_id = TestContentHost.NEW_CV['id']
            ContentView.publish({u'id': cv_id})
            result = ContentView.version_list({u'content-view-id': cv_id})
            version_id = result.stdout[0]['id']
            promotion = ContentView.version_promote({
                u'id':
                version_id,
                u'to-lifecycle-environment-id':
                TestContentHost.NEW_LIFECYCLE['id'],
                u'organization-id':
                TestContentHost.NEW_ORG['id']
            })
            if promotion.stderr == []:
                TestContentHost.PROMOTED_CV = TestContentHost.NEW_CV
Example #33
0
def test_positive_validate_inherited_cv_lce(session, module_host_template):
    """Create a host with hostgroup specified via CLI. Make sure host
    inherited hostgroup's lifecycle environment, content view and both
    fields are properly reflected via WebUI.

    :id: c83f6819-2649-4a8b-bb1d-ce93b2243765

    :expectedresults: Host's lifecycle environment and content view match
        the ones specified in hostgroup.

    :CaseLevel: Integration

    :BZ: 1391656
    """
    lce = make_lifecycle_environment({'organization-id': module_host_template.organization.id})
    content_view = make_content_view({'organization-id': module_host_template.organization.id})
    ContentView.publish({'id': content_view['id']})
    version_id = ContentView.version_list({'content-view-id': content_view['id']})[0]['id']
    ContentView.version_promote({
        'id': version_id,
        'to-lifecycle-environment-id': lce['id'],
        'organization-id': module_host_template.organization.id,
    })
    hostgroup = make_hostgroup({
        'content-view-id': content_view['id'],
        'lifecycle-environment-id': lce['id'],
        'organization-ids': module_host_template.organization.id,
    })
    puppet_proxy = Proxy.list({'search': 'name = {0}'.format(settings.server.hostname)})[0]
    host = make_host({
        'architecture-id': module_host_template.architecture.id,
        'domain-id': module_host_template.domain.id,
        'environment-id': module_host_template.environment.id,
        'hostgroup-id': hostgroup['id'],
        'location-id': module_host_template.location.id,
        'medium-id': module_host_template.medium.id,
        'operatingsystem-id': module_host_template.operatingsystem.id,
        'organization-id': module_host_template.organization.id,
        'partition-table-id': module_host_template.ptable.id,
        'puppet-proxy-id': puppet_proxy['id'],
    })
    with session:
        values = session.host.read(host['name'], ['host.lce', 'host.content_view'])
        assert values['host']['lce'] == lce['name']
        assert values['host']['content_view'] == content_view['name']
Example #34
0
    def test_positive_usage_limit(self):
        """Test that Usage limit actually limits usage

        :id: 00ded856-e939-4140-ac84-91b6a8643623

        :Steps:

            1. Create Activation key
            2. Update Usage Limit to a finite number
            3. Register Content hosts to match the Usage Limit
            4. Attempt to register an other Content host after reaching the
               Usage Limit

        :expectedresults: Content host Registration fails. Appropriate error
            shown

        :CaseLevel: System
        """
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        new_ak = make_activation_key({
            u'lifecycle-environment-id': env['id'],
            u'content-view': new_cv['name'],
            u'organization-id': self.org['id'],
            u'max-hosts': '1',
        })
        with VirtualMachine(distro=DISTRO_RHEL6) as vm1:
            with VirtualMachine(distro=DISTRO_RHEL6) as vm2:
                vm1.install_katello_ca()
                result = vm1.register_contenthost(
                    self.org['label'], new_ak['name'])
                self.assertTrue(vm1.subscribed)
                vm2.install_katello_ca()
                result = vm2.register_contenthost(
                    self.org['label'], new_ak['name'])
                self.assertFalse(vm2.subscribed)
                self.assertEqual(result.return_code, 70)
                self.assertGreater(len(result.stderr), 0)
Example #35
0
    def test_remove_docker_repo_to_activation_key(self):
        """@Test: Add Docker-type repository to a non-composite content view
        and publish it. Create an activation key and associate it with the
        Docker content view. Then remove this content view from the activation
        key.

        @Assert: Docker-based content view can be added and then removed
        from the activation key.

        @Feature: Docker

        """
        activation_key = make_activation_key({
            'content-view-id': self.content_view['id'],
            'lifecycle-environment-id': self.lce['id'],
            'organization-id': self.org['id'],
        })
        self.assertEqual(
            activation_key['content-view'], self.content_view['name'])

        # Create another content view replace with
        another_cv = make_content_view({
            'composite': False,
            'organization-id': self.org['id'],
        })
        ContentView.publish({'id': another_cv['id']})
        another_cv = ContentView.info({
            'id': another_cv['id']})
        ContentView.version_promote({
            'id': another_cv['versions'][0]['id'],
            'lifecycle-environment-id': self.lce['id'],
        })

        ActivationKey.update({
            'id': activation_key['id'],
            'organization-id': self.org['id'],
            'content-view-id': another_cv['id'],
        })
        activation_key = ActivationKey.info({
            'id': activation_key['id'],
        })
        self.assertNotEqual(
            activation_key['content-view'], self.content_view['name'])
Example #36
0
    def test_publish_multiple_docker_repo_composite_content_view(self):
        """@Test: Add Docker-type repository to content view and publish it
        multiple times.

        @Assert: One repository is created with a Docker image and the product
        is added to a content view which is then added to a composite content
        view which is then published multiple times.

        @Feature: Docker

        """
        self._create_and_associate_repo_with_cv()
        self.assertEqual(len(self.content_view['versions']), 0)
        ContentView.publish({'id': self.content_view['id']})
        self.content_view = ContentView.info({
            'id': self.content_view['id']})
        self.assertEqual(len(self.content_view['versions']), 1)
        comp_content_view = make_content_view({
            'composite': True,
            'organization-id': self.org_id,
        })
        ContentView.update({
            'component-ids': self.content_view['versions'][0]['id'],
            'id': comp_content_view['id'],
        })
        comp_content_view = ContentView.info({
            'id': comp_content_view['id'],
        })
        self.assertIn(
            self.content_view['versions'][0]['id'],
            [
                component['id']
                for component
                in comp_content_view['components']
            ],
        )
        publish_amount = randint(2, 5)
        for _ in range(publish_amount):
            ContentView.publish({'id': comp_content_view['id']})
        comp_content_view = ContentView.info({
            'id': comp_content_view['id'],
        })
        self.assertEqual(len(comp_content_view['versions']), publish_amount)
Example #37
0
    def test_publish_multiple_docker_repo_content_view(self):
        """@Test: Add Docker-type repository to content view and publish it
        multiple times.

        @Assert: One repository is created with a Docker image and the product
        is added to a content view which is then published multiple times.

        @Feature: Docker

        """
        self._create_and_associate_repo_with_cv()
        self.assertEqual(len(self.content_view['versions']), 0)
        publish_amount = randint(2, 5)
        for _ in range(publish_amount):
            ContentView.publish({'id': self.content_view['id']})
        self.content_view = ContentView.info({
            'id': self.content_view['id'],
        })
        self.assertEqual(len(self.content_view['versions']), publish_amount)
Example #38
0
    def setUp(self):
        """
        Tests for Content Host via Hammer CLI
        """

        super(TestContentHost, self).setUp()

        if TestContentHost.NEW_ORG is None:
            TestContentHost.NEW_ORG = make_org()
        if TestContentHost.NEW_LIFECYCLE is None:
            TestContentHost.NEW_LIFECYCLE = make_lifecycle_environment(
                {u'organization-id': TestContentHost.NEW_ORG['id']}
            )
        if TestContentHost.LIBRARY is None:
            library_result = LifecycleEnvironment.info(
                {u'organization-id': TestContentHost.NEW_ORG['id'],
                 u'name': u'Library'}
            )
            TestContentHost.LIBRARY = library_result.stdout
        if TestContentHost.DEFAULT_CV is None:
            cv_result = ContentView.info(
                {u'organization-id': TestContentHost.NEW_ORG['id'],
                 u'name': u'Default Organization View'}
            )
            TestContentHost.DEFAULT_CV = cv_result.stdout
        if TestContentHost.NEW_CV is None:
            TestContentHost.NEW_CV = make_content_view(
                {u'organization-id': TestContentHost.NEW_ORG['id']}
            )
            TestContentHost.PROMOTED_CV = None
            cv_id = TestContentHost.NEW_CV['id']
            ContentView.publish({u'id': cv_id})
            result = ContentView.version_list({u'content-view-id': cv_id})
            version_id = result.stdout[0]['id']
            promotion = ContentView.version_promote({
                u'id': version_id,
                u'lifecycle-environment-id': TestContentHost.NEW_LIFECYCLE[
                    'id'],
                u'organization-id': TestContentHost.NEW_ORG['id']
            })
            if promotion.stderr == []:
                TestContentHost.PROMOTED_CV = TestContentHost.NEW_CV
Example #39
0
    def setUp(self):
        """Tests for Host Collections via Hammer CLI"""
        super(HostCollectionTestCase, self).setUp()

        if HostCollectionTestCase.org is None:
            HostCollectionTestCase.org = make_org(cached=True)
        if HostCollectionTestCase.new_lifecycle is None:
            HostCollectionTestCase.new_lifecycle = make_lifecycle_environment(
                {u'organization-id': HostCollectionTestCase.org['id']},
                cached=True)
        if HostCollectionTestCase.library is None:
            HostCollectionTestCase.library = LifecycleEnvironment.info({
                u'organization-id':
                HostCollectionTestCase.org['id'],
                u'name':
                ENVIRONMENT,
            })
        if HostCollectionTestCase.default_cv is None:
            HostCollectionTestCase.default_cv = ContentView.info({
                u'organization-id':
                HostCollectionTestCase.org['id'],
                u'name':
                DEFAULT_CV
            })
        if HostCollectionTestCase.new_cv is None:
            HostCollectionTestCase.new_cv = make_content_view(
                {u'organization-id': HostCollectionTestCase.org['id']})
            HostCollectionTestCase.promoted_cv = None
            cv_id = HostCollectionTestCase.new_cv['id']
            ContentView.publish({u'id': cv_id})
            result = ContentView.version_list({u'content-view-id': cv_id})
            version_id = result[0]['id']
            ContentView.version_promote({
                u'id':
                version_id,
                u'organization-id':
                HostCollectionTestCase.org['id'],
                u'to-lifecycle-environment-id':
                (HostCollectionTestCase.new_lifecycle['id']),
            })
            HostCollectionTestCase.promoted_cv = HostCollectionTestCase.new_cv
Example #40
0
    def test_cv_preupgrade_scenario(self):
        """This is pre-upgrade scenario test to verify if we can create a
         content-view with various repositories.

         :id: a4ebbfa1-106a-4962-9c7c-082833879ae8

         :steps:
           1. Create custom yum, puppet and file repositories.
           2. Create content-view.
           3. Add yum, file repositories and puppet module to content view.
           4. Publish content-view.

         :expectedresults: content-view created with various repositories.
         """
        self.setupScenario()
        file_repo = self.make_file_repository_upload_contents()
        content_view = make_content_view(
            {
                'name': self.cv_name,
                'organization-id': self.org['id'],
                'repository-ids': [self.yum_repo1['id'], file_repo['id']],
            }
        )
        content_view = ContentView.info({'id': content_view['id']})
        self.assertEqual(
            content_view['yum-repositories'][0]['name'],
            self.yum_repo1['name'],
            'Repo was not associated to CV',
        )
        ContentView.puppet_module_add(
            {
                'content-view-id': content_view['id'],
                'name': self.puppet_module['name'],
                'author': self.puppet_module['author'],
            }
        )
        content_view = ContentView.info({'id': content_view['id']})
        self.assertGreater(len(content_view['puppet-modules']), 0)
        ContentView.publish({'id': content_view['id']})
        cv = ContentView.info({'id': content_view['id']})
        self.assertEqual(len(cv['versions']), 1)
Example #41
0
    def test_positive_usage_limit(self):
        """@Test: Test that Usage limit actually limits usage

        @Feature: Activation key - Usage limit

        @Steps:

        1. Create Activation key
        2. Update Usage Limit to a finite number
        3. Register Content hosts to match the Usage Limit
        4. Attempt to register an other Content host after reaching the Usage
           Limit

        @Assert: Content host Registration fails. Appropriate error shown
        """
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        new_ak = make_activation_key({
            u'lifecycle-environment-id': env['id'],
            u'content-view': new_cv['name'],
            u'organization-id': self.org['id'],
            u'unlimited-content-hosts': '0',
            u'max-content-hosts': '1',
        })
        with VirtualMachine(distro='rhel65') as vm1:
            with VirtualMachine(distro='rhel65') as vm2:
                vm1.install_katello_ca()
                result = vm1.register_contenthost(
                    new_ak['name'], self.org['label'])
                self.assertEqual(result.return_code, 0)
                vm2.install_katello_ca()
                result = vm2.register_contenthost(
                    new_ak['name'], self.org['label'])
                self.assertEqual(result.return_code, 255)
                self.assertGreater(len(result.stderr), 0)
Example #42
0
    def test_positive_sync_publish_cv(self):
        """Synchronize repository with DRPMs, add repository to content view
        and publish content view

        @id: 014bfc80-4622-422e-a0ec-755b1d9f845e

        @Assert: drpms can be listed in content view
        """
        repo = make_repository({"product-id": self.product["id"], "url": FAKE_YUM_DRPM_REPO})
        Repository.synchronize({"id": repo["id"]})
        cv = make_content_view({"organization-id": self.org["id"]})
        ContentView.add_repository({"id": cv["id"], "repository-id": repo["id"]})
        ContentView.publish({"id": cv["id"]})
        result = ssh.command(
            "ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}"
            "/1.0/custom/{}/{}/drpms/ | grep .drpm".format(
                self.org["label"], cv["label"], self.product["label"], repo["label"]
            )
        )
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)
Example #43
0
    def test_positive_sync_publish_cv(self):
        """Synchronize repository with SRPMs, add repository to content view
        and publish content view

        @id: 78cd6345-9c6c-490a-a44d-2ad64b7e959b

        @Assert: srpms can be listed in content view
        """
        repo = make_repository({"product-id": self.product["id"], "url": FAKE_YUM_SRPM_REPO})
        Repository.synchronize({"id": repo["id"]})
        cv = make_content_view({"organization-id": self.org["id"]})
        ContentView.add_repository({"id": cv["id"], "repository-id": repo["id"]})
        ContentView.publish({"id": cv["id"]})
        result = ssh.command(
            "ls /var/lib/pulp/published/yum/https/repos/{}/content_views/{}"
            "/1.0/custom/{}/{}/ | grep .src.rpm".format(
                self.org["label"], cv["label"], self.product["label"], repo["label"]
            )
        )
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)
    def test_positive_usage_limit(self):
        """Test that Usage limit actually limits usage

        @Feature: Activation key - Usage limit

        @Steps:

        1. Create Activation key
        2. Update Usage Limit to a finite number
        3. Register Content hosts to match the Usage Limit
        4. Attempt to register an other Content host after reaching the Usage
           Limit

        @Assert: Content host Registration fails. Appropriate error shown
        """
        env = make_lifecycle_environment({u'organization-id': self.org['id']})
        new_cv = make_content_view({u'organization-id': self.org['id']})
        ContentView.publish({u'id': new_cv['id']})
        cvv = ContentView.info({u'id': new_cv['id']})['versions'][0]
        ContentView.version_promote({
            u'id': cvv['id'],
            u'to-lifecycle-environment-id': env['id'],
        })
        new_ak = make_activation_key({
            u'lifecycle-environment-id': env['id'],
            u'content-view': new_cv['name'],
            u'organization-id': self.org['id'],
            u'max-content-hosts': '1',
        })
        with VirtualMachine(distro='rhel65') as vm1:
            with VirtualMachine(distro='rhel65') as vm2:
                vm1.install_katello_ca()
                result = vm1.register_contenthost(
                    new_ak['name'], self.org['label'])
                self.assertEqual(result.return_code, 0)
                vm2.install_katello_ca()
                result = vm2.register_contenthost(
                    new_ak['name'], self.org['label'])
                self.assertEqual(result.return_code, 255)
                self.assertGreater(len(result.stderr), 0)
Example #45
0
    def setUp(self):  # noqa
        """Tests for Host Collections via Hammer CLI"""

        super(TestHostCollection, self).setUp()

        if TestHostCollection.org is None:
            TestHostCollection.org = make_org(cached=True)
        if TestHostCollection.new_lifecycle is None:
            TestHostCollection.new_lifecycle = make_lifecycle_environment(
                {u'organization-id': TestHostCollection.org['id']},
                cached=True)
        if TestHostCollection.library is None:
            library_result = LifecycleEnvironment.info(
                {u'organization-id': TestHostCollection.org['id'],
                 u'name': u'Library'}
            )
            TestHostCollection.library = library_result.stdout
        if TestHostCollection.default_cv is None:
            cv_result = ContentView.info(
                {u'organization-id': TestHostCollection.org['id'],
                 u'name': u'Default Organization View'}
            )
            TestHostCollection.default_cv = cv_result.stdout
        if TestHostCollection.new_cv is None:
            TestHostCollection.new_cv = make_content_view(
                {u'organization-id': TestHostCollection.org['id']}
            )
            TestHostCollection.promoted_cv = None
            cv_id = TestHostCollection.new_cv['id']
            ContentView.publish({u'id': cv_id})
            result = ContentView.version_list({u'content-view-id': cv_id})
            version_id = result.stdout[0]['id']
            promotion = ContentView.version_promote({
                u'id': version_id,
                u'to-lifecycle-environment-id': (
                    TestHostCollection.new_lifecycle['id']),
                u'organization-id': TestHostCollection.org['id']
            })
            if promotion.stderr == []:
                TestHostCollection.promoted_cv = TestHostCollection.new_cv
    def test_positive_usage_limit(self):
        """Test that Usage limit actually limits usage

        @Feature: Activation key - Usage limit

        @Steps:

        1. Create Activation key
        2. Update Usage Limit to a finite number
        3. Register Content hosts to match the Usage Limit
        4. Attempt to register an other Content host after reaching the Usage
           Limit

        @Assert: Content host Registration fails. Appropriate error shown
        """
        env = make_lifecycle_environment({u"organization-id": self.org["id"]})
        new_cv = make_content_view({u"organization-id": self.org["id"]})
        ContentView.publish({u"id": new_cv["id"]})
        cvv = ContentView.info({u"id": new_cv["id"]})["versions"][0]
        ContentView.version_promote({u"id": cvv["id"], u"to-lifecycle-environment-id": env["id"]})
        new_ak = make_activation_key(
            {
                u"lifecycle-environment-id": env["id"],
                u"content-view": new_cv["name"],
                u"organization-id": self.org["id"],
                u"unlimited-content-hosts": "0",
                u"max-content-hosts": "1",
            }
        )
        with VirtualMachine(distro="rhel65") as vm1:
            with VirtualMachine(distro="rhel65") as vm2:
                vm1.install_katello_ca()
                result = vm1.register_contenthost(new_ak["name"], self.org["label"])
                self.assertEqual(result.return_code, 0)
                vm2.install_katello_ca()
                result = vm2.register_contenthost(new_ak["name"], self.org["label"])
                self.assertEqual(result.return_code, 255)
                self.assertGreater(len(result.stderr), 0)
Example #47
0
    def test_positive_sync_publish_promote_cv(self):
        """Synchronize repository with DRPMs, add repository to content view,
        publish and promote content view to lifecycle environment

        @id: a01cb12b-d388-4902-8532-714f4e28ec56

        @Assert: drpms can be listed in content view in proper lifecycle
        environment
        """
        lce = make_lifecycle_environment({'organization-id': self.org['id']})
        repo = make_repository({
            'product-id': self.product['id'],
            'url': FAKE_YUM_DRPM_REPO,
        })
        Repository.synchronize({'id': repo['id']})
        cv = make_content_view({'organization-id': self.org['id']})
        ContentView.add_repository({
            'id': cv['id'],
            'repository-id': repo['id'],
        })
        ContentView.publish({'id': cv['id']})
        content_view = ContentView.info({'id': cv['id']})
        cvv = content_view['versions'][0]
        ContentView.version_promote({
            'id': cvv['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        result = ssh.command(
            'ls /var/lib/pulp/published/yum/https/repos/{}/{}/{}/custom/{}/{}'
            '/drpms/ | grep .drpm'.format(
                self.org['label'],
                lce['label'],
                cv['label'],
                self.product['label'],
                repo['label'],
            ))
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)
Example #48
0
    def test_positive_validate_inherited_cv_lce(self):
        """Create a host with hostgroup specified via CLI. Make sure host
        inherited hostgroup's lifecycle environment, content view and both
        fields are properly reflected via WebUI

        :id: c83f6819-2649-4a8b-bb1d-ce93b2243765

        :expectedresults: Host's lifecycle environment and content view match
            the ones specified in hostgroup

        :CaseLevel: Integration

        :BZ: 1391656
        """
        host = entities.Host()
        host.create_missing()

        new_lce = cli_factory.make_lifecycle_environment(
            {'organization-id': host.organization.id})
        new_cv = cli_factory.make_content_view(
            {'organization-id': host.organization.id})
        cli_ContentView.publish({'id': new_cv['id']})
        version_id = cli_ContentView.version_list({
            'content-view-id':
            new_cv['id'],
        })[0]['id']
        cli_ContentView.version_promote({
            'id':
            version_id,
            'to-lifecycle-environment-id':
            new_lce['id'],
            'organization-id':
            host.organization.id,
        })
        hostgroup = cli_factory.make_hostgroup({
            'content-view-id':
            new_cv['id'],
            'lifecycle-environment-id':
            new_lce['id'],
            'organization-ids':
            host.organization.id,
        })
        puppet_proxy = cli_Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]

        cli_factory.make_host({
            'architecture-id': host.architecture.id,
            'domain-id': host.domain.id,
            'environment-id': host.environment.id,
            'hostgroup-id': hostgroup['id'],
            'location-id': host.location.id,
            'medium-id': host.medium.id,
            'name': host.name,
            'operatingsystem-id': host.operatingsystem.id,
            'organization-id': host.organization.id,
            'partition-table-id': host.ptable.id,
            'puppet-proxy-id': puppet_proxy['id'],
        })

        with Session(self.browser) as session:
            set_context(session, host.organization.name, host.location.name)
            result = self.hosts.fetch_host_parameters(
                host.name,
                host.domain.name,
                [['Host', 'Lifecycle Environment'], ['Host', 'Content View']],
            )
            self.assertEqual(result['Lifecycle Environment'], new_lce['name'])
            self.assertEqual(result['Content View'], new_cv['name'])
Example #49
0
    def test_cv_postupgrade_scenario(self):
        """This is post-upgrade scenario test to verify if we can update
         content-view created in pre-upgrade scenario with various repositories.

         :id: a4ebbfa1-106a-4962-9c7c-082833879ae8

         :steps:
           1. Remove yum repository which was added to content-view before upgrade.
           2. Create new yum repository and add it to content-view.
           3. Remove puppet module which was added to content-view before upgrade.
           4. Add another puppet module to content-view
           5. Publish content-view

         :expectedresults: content-view updated with various repositories.
        """
        product_id = Repository.info({
            'name': self.yum_repo1_name,
            'organization': self.org_name,
            'product': self.product_name
        })['product']['id']
        ContentView.remove_repository({
            'organization': self.org_name,
            'name': self.cv_name,
            'repository': self.yum_repo1_name
        })
        content_view = ContentView.info({
            'name': self.cv_name,
            'organization': self.org_name
        })
        self.assertNotIn(self.yum_repo1_name, content_view['yum-repositories'])
        yum_repo2 = make_repository({
            'name': self.yum_repo2_name,
            'organization': self.org_name,
            'content-type': 'yum',
            'product-id': product_id,
            'url': FAKE_2_YUM_REPO
        })
        Repository.synchronize({
            'id': yum_repo2['id'],
            'organization': self.org_name
        })
        ContentView.add_repository({
            'name': self.cv_name,
            'organization': self.org_name,
            'product': self.product_name,
            'repository-id': yum_repo2['id']
        })
        content_view = ContentView.info({
            'name': self.cv_name,
            'organization': self.org_name
        })
        self.assertEqual(
            content_view['yum-repositories'][0]['name'],
            self.yum_repo2_name,
            'Repo was not associated to CV',
        )
        ContentView.puppet_module_remove({
            'organization': self.org_name,
            'content-view': self.cv_name,
            'name': self.puppet_module_name,
            'author': self.puppet_module_author,
        })
        content_view = ContentView.info({
            'name': self.cv_name,
            'organization': self.org_name
        })
        self.assertEqual(len(content_view['puppet-modules']), 0)
        module = {'name': 'versioned', 'version': '2.2.2'}
        puppet_module = PuppetModule.list(
            {'search':
             'name={name} and version={version}'.format(**module)})[0]
        ContentView.puppet_module_add({
            'organization': self.org_name,
            'content-view': self.cv_name,
            'name': puppet_module['name'],
            'author': puppet_module['author'],
        })
        content_view = ContentView.info({'id': content_view['id']})
        self.assertGreater(len(content_view['puppet-modules']), 0)
        ContentView.publish({
            'name': self.cv_name,
            'organization': self.org_name
        })
        content_view = ContentView.info({
            'name': self.cv_name,
            'organization': self.org_name
        })
        self.assertEqual(len(content_view['versions']), 2)
Example #50
0
    def setUpClass(cls):
        """Setup must ensure there is an Org with Golden Ticket enabled.


        Option 1) SQL::

            UPDATE
                 cp_owner
            SET
                 content_access_mode = 'org_environment',
                 content_access_mode_list='entitlement,org_environment'
            WHERE account='{org.label}';

        Option 2) manifest::

            Change manifest file as it looks like:

                Consumer:
                    Name: ExampleCorp
                    UUID: c319a1d8-4b30-44cd-b2cf-2ccba4b9a8db
                    Content Access Mode: org_environment
                    Type: satellite

        :steps:

            1. Create a new organization.
            2. Use either option 1 or option 2 (described above) to activate
               the Golden Ticket.
            3. Create a Product and CV for org.
            4. Add a repository pointing to a real repo which requires a
               RedHat subscription to access.
            5. Create Content Host and assign that gated repos to it.
            6. Sync the gated repository.
        """
        super(ContentAccessTestCase, cls).setUpClass()
        # Create Organization
        cls.org = make_org()
        # upload organization manifest with org environment access enabled
        cls.manifest = manifests.clone(org_environment_access=True)
        manifests.upload_manifest_locked(cls.org['id'],
                                         cls.manifest,
                                         interface=manifests.INTERFACE_CLI)
        # Create repositories
        cls.repos = [
            # Red Hat Enterprise Linux 7
            {
                'product': PRDS['rhel'],
                'repository-set': REPOSET['rhel7'],
                'repository': REPOS['rhel7']['name'],
                'repository-id': REPOS['rhel7']['id'],
                'releasever': REPOS['rhel7']['releasever'],
                'arch': REPOS['rhel7']['arch'],
                'cdn': True,
            },
            # Red Hat Satellite Tools
            {
                'product': PRDS['rhel'],
                'repository-set': REPOSET['rhst7'],
                'repository': REPOS['rhst7']['name'],
                'repository-id': REPOS['rhst7']['id'],
                'url': settings.sattools_repo['rhel7'],
                'cdn': bool(settings.cdn
                            or not settings.sattools_repo['rhel7']),
            },
        ]
        cls.custom_product, cls.repos_info = setup_cdn_and_custom_repositories(
            cls.org['id'], cls.repos)
        # Create a content view
        content_view = make_content_view({u'organization-id': cls.org['id']})
        # Add repositories to content view
        for repo_info in cls.repos_info:
            ContentView.add_repository({
                u'id': content_view['id'],
                u'organization-id': cls.org['id'],
                u'repository-id': repo_info['id'],
            })
        # Publish the content view
        ContentView.publish({u'id': content_view['id']})
        cls.content_view = ContentView.info({u'id': content_view['id']})
Example #51
0
    def test_positive_show_count_on_chost_details_page(self):
        """Errata count on Content host Details page

        @id: 388229da-2b0b-41aa-a457-9b5ecbf3df4b

        @Setup:

        1. Errata synced on satellite server.
        2. Some content hosts are present.

        @Steps:

        1. Go to Hosts -> Content Hosts -> Select Content Host -> Details page.

        @Assert:

        1. The errata section should be displayed with Security, Bugfix,
        Enhancement types.
        2. The number should link to the errata details page, filtered  by
        type.

        @CaseLevel: System
        """
        org = entities.Organization().create()
        env = entities.LifecycleEnvironment(organization=org).create()
        content_view = entities.ContentView(organization=org).create()
        activation_key = entities.ActivationKey(
            environment=env,
            organization=org,
        ).create()
        setup_org_for_a_rh_repo({
            'product': PRDS['rhel'],
            'repository-set': REPOSET['rhst6'],
            'repository': REPOS['rhst6']['name'],
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        setup_org_for_a_custom_repo({
            'url': CUSTOM_REPO_URL,
            'organization-id': org.id,
            'content-view-id': content_view.id,
            'lifecycle-environment-id': env.id,
            'activationkey-id': activation_key.id,
        })
        RepositorySet.enable({
            'basearch': DEFAULT_ARCHITECTURE,
            'name': REPOSET['rhva6'],
            'organization-id': org.id,
            'product': PRDS['rhel'],
            'releasever': DEFAULT_RELEASE_VERSION,
        })
        rhel_repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'organization-id': org.id,
            'product': PRDS['rhel'],
        })
        Repository.synchronize({
            'name': REPOS['rhva6']['name'],
            'organization-id': org.id,
            'product': PRDS['rhel'],
        })
        ContentView.add_repository({
            'id': content_view.id,
            'organization-id': org.id,
            'repository-id': rhel_repo['id'],
        })
        ContentView.publish({'id': content_view.id})
        cvv = ContentView.info({'id': content_view.id})['versions'][-1]
        ContentView.version_promote({
            'id': cvv['id'],
            'organization-id': org.id,
            'to-lifecycle-environment-id': env.id,
        })
        with VirtualMachine(distro='rhel67') as client:
            client.install_katello_ca()
            result = client.register_contenthost(
                org.label,
                activation_key.name,
            )
            self.assertEqual(result.return_code, 0)
            client.enable_repo(REPOS['rhst6']['id'])
            client.enable_repo(REPOS['rhva6']['id'])
            client.install_katello_agent()
            with Session(self.browser) as session:
                session.nav.go_to_select_org(org.name)
                result = self.contenthost.fetch_errata_counts(
                    client.hostname, details_page=True)
                for errata in ('security', 'bug_fix', 'enhancement'):
                    self.assertEqual(result[errata]['value'], 0)
                    self.assertEqual(result[errata]['color'], 'black')
                client.run('yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
                result = self.contenthost.fetch_errata_counts(
                    client.hostname, details_page=True)
                self.assertEqual(result['security']['value'], 1)
                self.assertEqual(result['security']['color'], 'red')
                client.run('yum install -y {0}'.format(REAL_0_RH_PACKAGE))
                result = self.contenthost.fetch_errata_counts(
                    client.hostname, details_page=True)
                for errata in ('bug_fix', 'enhancement'):
                    self.assertEqual(result[errata]['value'], 1)
                    self.assertEqual(result[errata]['color'], 'yellow')
Example #52
0
    def test_positive_create_with_synced_content(self):
        """Check if hostgroup with synced kickstart repository can be created

        :id: 7c51ac72-359c-488a-8658-88b5a94d7e7a

        :customerscenario: true

        :expectedresults: Hostgroup should be created and has proper
            installation content id present

        :BZ: 1415707

        :CaseLevel: Integration
        """
        # Check whether path to kickstart media is set
        if settings.rhel6_os is None:
            raise ValueError(
                'Installation media path is not set in properties file')
        # Common entities
        org = make_org()
        lce = make_lifecycle_environment({'organization-id': org['id']})
        product = make_product({'organization-id': org['id']})
        repo = make_repository({
            u'url': settings.rhel6_os,
            u'product-id': product['id'],
            u'content-type': u'yum',
        })
        Repository.synchronize({'id': repo['id']})

        cv = make_content_view({
            'organization-id': org['id'],
            'repository-ids': [repo['id']],
        })
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        cvv = cv['versions'][0]
        ContentView.version_promote({
            'id': cvv['id'],
            'to-lifecycle-environment-id': lce['id'],
        })

        # Get the Partition table ID
        ptable = PartitionTable.info({'name': DEFAULT_PTABLE})

        # Get the arch ID
        arch = Architecture.list(
            {'search': 'name={0}'.format(DEFAULT_ARCHITECTURE)})[0]

        # Get the OS ID
        os = OperatingSys.list({
            'search':
            'name="RedHat" AND major="{0}" OR major="{1}"'.format(
                RHEL_6_MAJOR_VERSION, RHEL_7_MAJOR_VERSION)
        })[0]

        # Update the OS with found arch and ptable
        OperatingSys.update({
            'id': os['id'],
            'architectures': arch['name'],
            'partition-tables': ptable['name'],
        })
        proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]

        # Search for proper installation repository id
        synced_repo = Repository.list({
            'content-view-version-id': cvv['id'],
            'organization-id': org['id'],
            'environment-id': lce['id'],
        })[0]
        hostgroup = make_hostgroup({
            'lifecycle-environment-id':
            lce['id'],
            'puppet-proxy-id':
            proxy['id'],
            'puppet-ca-proxy-id':
            proxy['id'],
            'content-source-id':
            proxy['id'],
            'content-view-id':
            cv['id'],
            'organization-ids':
            org['id'],
            'architecture-id':
            arch['id'],
            'partition-table-id':
            ptable['id'],
            'operatingsystem-id':
            os['id'],
            'kickstart-repository-id':
            synced_repo['id'],
        })
        hg = HostGroup.info({'id': hostgroup['id']}, output_format='json')
        self.assertEqual(hg['kickstart-repository']['id'], synced_repo['id'])
Example #53
0
    def test_positive_create_with_multiple_entities_ids(self):
        """Check if hostgroup with multiple options ids can be created

        :id: 6277613b-0ece-4dee-b9d8-504f8299ac38

        :expectedresults: Hostgroup should be created and has all defined
            entities assigned

        :BZ: 1395254, 1313056

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        make_hostgroup_params = {
            'location-ids': loc['id'],
            'environment-id': env['id'],
            'lifecycle-environment-id': lce['id'],
            'puppet-proxy-id': proxy['id'],
            'puppet-ca-proxy-id': proxy['id'],
            'content-source-id': proxy['id'],
            'content-view-id': cv['id'],
            'domain-id': domain['id'],
            'subnet-id': subnet['id'],
            'organization-ids': org['id'],
            'architecture-id': arch['id'],
            'partition-table-id': ptable['id'],
            'medium-id': media['id'],
            'operatingsystem-id': os['id'],
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertEqual(cv['id'], hostgroup['content-view']['id'])
        self.assertEqual(lce['id'], hostgroup['lifecycle-environment']['id'])
        self.assertEqual(proxy['id'], hostgroup['content-source']['id'])
        # get the json output format
        hostgroup = HostGroup.info({'id': hostgroup['id']},
                                   output_format='json')
        self.assertIn(org['id'], hostgroup['organizations'][0]['id'])
        self.assertIn(loc['id'], hostgroup['locations'][0]['id'])
        self.assertEqual(env['id'], hostgroup['puppet-environment']['id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-master-proxy']['id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-ca-proxy']['id'])
        self.assertEqual(domain['id'], hostgroup['network']['domain']['id'])
        self.assertEqual(subnet['id'],
                         hostgroup['network']['subnet-ipv4']['id'])
        self.assertEqual(arch['id'],
                         hostgroup['operating-system']['architecture']['id'])
        self.assertEqual(
            ptable['id'],
            hostgroup['operating-system']['partition-table']['id'])
        self.assertEqual(media['id'],
                         hostgroup['operating-system']['medium']['id'])
        self.assertEqual(
            os['id'], hostgroup['operating-system']['operating-system']['id'])
Example #54
0
    def test_positive_create_with_multiple_entities_name(self):
        """Check if hostgroup with multiple options name can be created

        :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

        :expectedresults: Hostgroup should be created and has all defined
            entities assigned

        :BZ: 1395254, 1313056

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        os_full_name = "{0} {1}.{2}".format(os['name'], os['major-version'],
                                            os['minor-version'])
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'organizations': org['name'],
            'locations': loc['name'],
            'environment': env['name'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy': proxy['name'],
            'puppet-ca-proxy': proxy['name'],
            'content-source-id': proxy['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem': os_full_name,
            'query-organization': org['name']
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertIn(org['name'], hostgroup['organizations'])
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['puppet-environment'])
        self.assertEqual(proxy['name'], hostgroup['puppet-master-proxy'])
        self.assertEqual(proxy['name'], hostgroup['puppet-ca-proxy'])
        self.assertEqual(domain['name'], hostgroup['network']['domain'])
        self.assertEqual(subnet['name'], hostgroup['network']['subnet-ipv4'])
        self.assertEqual(arch['name'],
                         hostgroup['operating-system']['architecture'])
        self.assertEqual(ptable['name'],
                         hostgroup['operating-system']['partition-table'])
        self.assertEqual(media['name'],
                         hostgroup['operating-system']['medium'])
        self.assertEqual(os_full_name,
                         hostgroup['operating-system']['operating-system'])
        self.assertEqual(cv['name'], hostgroup['content-view']['name'])
        self.assertEqual(lce['name'],
                         hostgroup['lifecycle-environment']['name'])
        self.assertEqual(proxy['name'], hostgroup['content-source']['name'])
Example #55
0
    def test_positive_create_with_multiple_entities_and_delete(self):
        """Check if hostgroup with multiple options can be created and deleted

        :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

        :expectedresults: Hostgroup should be created, has all defined
            entities assigned and deleted

        :BZ: 1395254, 1313056

        :CaseLevel: Integration

        :CaseImportance: Critical
        """
        # Common entities
        name = valid_hostgroups_list()[0]
        loc = make_location()
        org = make_org()
        orgs = [org, self.org]
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id']
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id']
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id']
        })
        os_full_name = "{0} {1}.{2}".format(os['name'], os['major-version'],
                                            os['minor-version'])
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'name': name,
            'organization-ids': [org['id'] for org in orgs],
            'locations': loc['name'],
            'environment': env['name'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy': self.content_source['name'],
            'puppet-ca-proxy': self.content_source['name'],
            'content-source-id': self.content_source['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem': os_full_name,
            'puppet-classes': self.puppet_classes[0]['name'],
            'query-organization': org['name'],
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertEqual(hostgroup['name'], name)
        self.assertEqual(set(org['name'] for org in orgs),
                         set(hostgroup['organizations']))
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['puppet-environment'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['puppet-master-proxy'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['puppet-ca-proxy'])
        self.assertEqual(domain['name'], hostgroup['network']['domain'])
        self.assertEqual(subnet['name'], hostgroup['network']['subnet-ipv4'])
        self.assertEqual(arch['name'],
                         hostgroup['operating-system']['architecture'])
        self.assertEqual(ptable['name'],
                         hostgroup['operating-system']['partition-table'])
        self.assertEqual(media['name'],
                         hostgroup['operating-system']['medium'])
        self.assertEqual(os_full_name,
                         hostgroup['operating-system']['operating-system'])
        self.assertEqual(cv['name'], hostgroup['content-view']['name'])
        self.assertEqual(lce['name'],
                         hostgroup['lifecycle-environment']['name'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['content-source']['name'])
        self.assertIn(self.puppet_classes[0]['name'],
                      hostgroup['puppetclasses'])
        # delete hostgroup
        HostGroup.delete({'id': hostgroup['id']})
        with self.assertRaises(CLIReturnCodeError):
            HostGroup.info({'id': hostgroup['id']})
Example #56
0
def test_positive_create_with_multiple_entities_and_delete(
        module_puppet_org, puppet_content_source, puppet_classes,
        session_puppet_enabled_sat):
    """Check if hostgroup with multiple options can be created and deleted

    :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

    :expectedresults: Hostgroup should be created, has all defined
        entities assigned and deleted

    :BZ: 1395254, 1313056

    :CaseLevel: Integration

    :CaseImportance: Critical
    """
    with session_puppet_enabled_sat:
        # Common entities
        name = valid_hostgroups_list()[0]
        loc = make_location()
        org_2 = entities.Organization().create()
        orgs = [module_puppet_org, org_2]
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org_2.id
        })
        lce = make_lifecycle_environment({'organization-id': org_2.id})
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org_2.id})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id']
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org_2.id
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org_2.id
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org_2.id
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id']
        })
        os_full_name = "{} {}.{}".format(os['name'], os['major-version'],
                                         os['minor-version'])
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org_2.id,
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'name': name,
            'organization-ids': [org.id for org in orgs],
            'locations': loc['name'],
            'puppet-environment': env['name'],
            'lifecycle-environment-id': lce['id'],
            'puppet-proxy': puppet_content_source['name'],
            'puppet-ca-proxy': puppet_content_source['name'],
            'content-source-id': puppet_content_source['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem': os_full_name,
            'puppet-classes': puppet_classes[0]['name'],
            'query-organization': org_2.name,
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        assert hostgroup['name'] == name
        assert {org.name for org in orgs} == set(hostgroup['organizations'])
        assert loc['name'] in hostgroup['locations']
        assert env['name'] == hostgroup['puppet-environment']
        assert puppet_content_source['name'] == hostgroup[
            'puppet-master-proxy']
        assert puppet_content_source['name'] == hostgroup['puppet-ca-proxy']
        assert domain['name'] == hostgroup['network']['domain']
        assert subnet['name'] == hostgroup['network']['subnet-ipv4']
        assert arch['name'] == hostgroup['operating-system']['architecture']
        assert ptable['name'] == hostgroup['operating-system'][
            'partition-table']
        assert media['name'] == hostgroup['operating-system']['medium']
        assert os_full_name == hostgroup['operating-system'][
            'operating-system']
        assert cv['name'] == hostgroup['content-view']['name']
        assert lce['name'] == hostgroup['lifecycle-environment']['name']
        assert puppet_content_source['name'] == hostgroup['content-source'][
            'name']
        assert puppet_classes[0]['name'] in hostgroup['puppetclasses']
        # delete hostgroup
        HostGroup.delete({'id': hostgroup['id']})
        with pytest.raises(CLIReturnCodeError):
            HostGroup.info({'id': hostgroup['id']})
Example #57
0
    def test_positive_create_with_multiple_entities(self):
        """Check if hostgroup with multiple options can be created

        :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

        :expectedresults: Hostgroup should be created and has all defined
            entities assigned

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        puppet_proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })

        make_hostgroup_params = {
            'location-ids': loc['id'],
            'environment-id': env['id'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy-id': puppet_proxy['id'],
            'puppet-ca-proxy-id': puppet_proxy['id'],
            'content-view-id': cv['id'],
            'domain-id': domain['id'],
            'subnet-id': subnet['id'],
            'organization-ids': org['id'],
            'architecture-id': arch['id'],
            'partition-table-id': ptable['id'],
            'medium-id': media['id'],
            'operatingsystem-id': os['id'],
        }
        # If bug is open provide LCE id as parameter
        # because LCE name cause errors
        if bz_bug_is_open(1395254):
            make_hostgroup_params.pop('lifecycle-environment')
            make_hostgroup_params['lifecycle-environment-id'] = lce['id']

        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertIn(org['name'], hostgroup['organizations'])
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['environment'])
        self.assertEqual(puppet_proxy['id'],
                         hostgroup['puppet-master-proxy-id'])
        self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
        self.assertEqual(domain['name'], hostgroup['domain'])
        self.assertEqual(subnet['name'], hostgroup['subnet'])
        self.assertEqual(arch['name'], hostgroup['architecture'])
        self.assertEqual(ptable['name'], hostgroup['partition-table'])
        self.assertEqual(media['name'], hostgroup['medium'])
        self.assertEqual(
            "{0} {1}.{2}".format(os['name'], os['major-version'],
                                 os['minor-version']),
            hostgroup['operating-system'])
        if not bz_bug_is_open('1313056'):
            self.assertEqual(cv['name'], hostgroup['content-view'])
            self.assertEqual(lce['name'], hostgroup['lifecycle-environment'])
Example #58
0
    def test_positive_end_to_end(self):
        """Perform end to end smoke tests using RH repos.

        1. Create new organization and environment
        2. Upload manifest
        3. Sync a RedHat repository
        4. Create content-view
        5. Add repository to contet-view
        6. Promote/publish content-view
        7. Create an activation-key
        8. Add product to activation-key
        9. Create new virtualmachine
        10. Pull rpm from Foreman server and install on client
        11. Register client with foreman server using activation-key
        12. Install rpm on client

        @Feature: Smoke test

        @Assert: All tests should succeed and Content should be successfully
        fetched by client

        """
        # Product, RepoSet and repository variables
        rhel_product_name = PRDS['rhel']
        rhel_repo_set = REPOSET['rhva6']
        rhel_repo_name = REPOS['rhva6']['name']
        org_name = random.choice(generate_strings_list())
        # Create new org and environment
        new_org = make_org({u'name': org_name})
        new_env = make_lifecycle_environment({
            u'organization-id': new_org['id'],
        })
        # Clone manifest and upload it
        with manifests.clone() as manifest:
            ssh.upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': new_org['id'],
        })
        # Enable repo from Repository Set
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': rhel_repo_set,
            u'organization-id': new_org['id'],
            u'product': rhel_product_name,
            u'releasever': '6Server',
        })
        # Fetch repository info
        rhel_repo = Repository.info({
            u'name': rhel_repo_name,
            u'organization-id': new_org['id'],
            u'product': rhel_product_name,
        })
        # Synchronize the repository
        Repository.synchronize({
            u'name': rhel_repo_name,
            u'organization-id': new_org['id'],
            u'product': rhel_product_name,
        })
        # Create CV and associate repo to it
        new_cv = make_content_view({u'organization-id': new_org['id']})
        ContentView.add_repository({
            u'id': new_cv['id'],
            u'organization-id': new_org['id'],
            u'repository-id': rhel_repo['id'],
        })
        # Publish a version1 of CV
        ContentView.publish({u'id': new_cv['id']})
        # Get the CV info
        version1_id = ContentView.info({u'id':
                                        new_cv['id']})['versions'][0]['id']
        # Store the version1 id
        # Promotion of version1 to next env
        ContentView.version_promote({
            u'id':
            version1_id,
            u'to-lifecycle-environment-id':
            new_env['id'],
        })
        # Create activation key
        activation_key = make_activation_key({
            u'content-view':
            new_cv['name'],
            u'lifecycle-environment-id':
            new_env['id'],
            u'organization-id':
            new_org['id'],
        })
        # List the subscriptions in given org
        result = Subscription.list({u'organization-id': new_org['id']},
                                   per_page=False)
        self.assertGreater(len(result), 0)
        # Get the subscription ID from subscriptions list
        subscription_quantity = 0
        for subscription in result:
            if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME:
                subscription_id = subscription['id']
                subscription_quantity = int(subscription['quantity'])
        self.assertGreater(subscription_quantity, 0)
        # Add the subscriptions to activation-key
        ActivationKey.add_subscription({
            u'id': activation_key['id'],
            u'quantity': 1,
            u'subscription-id': subscription_id,
        })
        # Enable product content
        ActivationKey.content_override({
            u'content-label': 'rhel-6-server-rhev-agent-rpms',
            u'id': activation_key['id'],
            u'organization-id': new_org['id'],
            u'value': '1',
        })
        # Create VM
        package_name = "python-kitchen"
        server_name = settings.server.hostname
        with VirtualMachine(distro='rhel66') as vm:
            # Download and Install rpm
            result = vm.run(
                "wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/"
                .format(server_name))
            self.assertEqual(result.return_code, 0)
            result = vm.run('rpm -i katello-ca-consumer*.noarch.rpm')
            self.assertEqual(result.return_code, 0)
            # Register client with foreman server using activation-key
            result = vm.run(
                u'subscription-manager register --activationkey {0} '
                '--org {1} --force'.format(activation_key['name'],
                                           new_org['label']))
            self.assertEqual(result.return_code, 0)
            # Install contents from sat6 server
            result = vm.run('yum install -y {0}'.format(package_name))
            self.assertEqual(result.return_code, 0)
            # Verify if package is installed by query it
            result = vm.run('rpm -q {0}'.format(package_name))
            self.assertEqual(result.return_code, 0)