Exemplo n.º 1
0
    def test_negative_update_inclusion(self):
        """Test: Try to update content view filter and assign incorrect
        inclusion value for it

        @Feature: Content View Filter

        @Assert: Content view filter is not updated

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'true',
            'name': cvf_name,
            'type': 'rpm',
        })
        with self.assertRaises(CLIReturnCodeError):
            ContentView.filter_update({
                'content-view-id': self.content_view['id'],
                'inclusion': 'wrong_value',
                'name': cvf_name,
            })
        cvf = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': cvf_name,
        })
        self.assertEqual(cvf['inclusion'], 'true')
    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'])
Exemplo n.º 3
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)
Exemplo n.º 4
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)
Exemplo n.º 5
0
    def test_delete_cvf_with_different_names(self, name):
        """Test: Create new content view filter and assign it to existing
        content view by id. Try to delete that filter using different value
        types as a name

        @Feature: Content View Filter

        @Assert: Content view filter deleted successfully

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'name': name,
        })
        self.assertEqual(result.return_code, 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': name,
        })
        self.assertEqual(result.return_code, 0)

        result = ContentView.filter_delete({
            u'content-view-id': self.content_view['id'],
            u'name': name,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': name,
        })
        self.assertNotEqual(result.return_code, 0)
Exemplo n.º 6
0
    def test_delete_cvf_by_id(self):
        """Test: Create new content view filter and assign it to existing
        content view by id. Try to delete that filter using its id as a
        parameter

        @Feature: Content View Filter

        @Assert: Content view filter deleted successfully

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'name': self.cvf_name,
        })
        self.assertEqual(result.return_code, 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': self.cvf_name,
        })
        self.assertEqual(result.return_code, 0)

        result = ContentView.filter_delete({
            u'id': result.stdout['filter-id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': self.cvf_name,
        })
        self.assertNotEqual(result.return_code, 0)
Exemplo n.º 7
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)
Exemplo n.º 8
0
    def test_update_cvf_with_new_repo_negative(self):
        """Test: Try to update filter and assign repository which does not
        belong to filter content view

        @Feature: Content View Filter

        @Assert: Content view filter is not updated

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'name': self.cvf_name,
            'repository-ids': self.repo['id'],
        })
        self.assertEqual(result.return_code, 0)

        new_repo = make_repository({u'product-id': self.product['id']})

        result = ContentView.filter_update({
            'content-view-id': self.content_view['id'],
            'name': self.cvf_name,
            'repository-ids': new_repo['id'],
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)
Exemplo n.º 9
0
    def test_update_cvf_with_different_names_negative(self, new_name):
        """@Test: Try to update content view filter using invalid names only

        @Feature: Content View Filter

        @Assert: Content view filter is not updated

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'name': self.cvf_name,
        })
        self.assertEqual(result.return_code, 0)

        result = ContentView.filter_update({
            'content-view-id': self.content_view['id'],
            'name': self.cvf_name,
            'new-name': new_name,
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': new_name,
        })
        self.assertNotEqual(result.return_code, 0)
Exemplo n.º 10
0
    def test_negative_create_with_same_name(self):
        """Try to create content view filter using same name twice

        @id: 7e7444f4-e2b5-406d-a210-49b4008c88d9

        @Assert: Second content view filter is not created

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'name': cvf_name,
            'organization-id': self.org['id'],
            'type': 'rpm',
        })
        with self.assertRaises(CLIReturnCodeError):
            ContentView.filter_create({
                'content-view-id':
                self.content_view['id'],
                'name':
                cvf_name,
                'organization-id':
                self.org['id'],
                'type':
                'rpm',
            })
Exemplo n.º 11
0
    def test_create_cvf_with_original_packages(self):
        """Test: Create new content view filter and assign it to existing
        content view that has repository assigned to it. Enable 'original
        packages' option for that filter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has proper
        repository affected

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'inclusion': 'true',
            'name': self.cvf_name,
            'repository-ids': self.repo['id'],
            'original-packages': 'true',
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': self.cvf_name
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(
            result.stdout['repositories'][0]['name'], self.repo['name'])
Exemplo n.º 12
0
    def test_create_cvf_with_different_names(self, name):
        """Test: Create new content view filter and assign it to existing
        content view by id. Use different value types as a name and random
        filter content type as a parameter for this filter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has correct and
        expected parameters

        """
        filter_content_type = gen_choice(['rpm', 'package_group', 'erratum'])
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': filter_content_type,
            'name': name,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': name
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(result.stdout['name'], name)
        self.assertEqual(result.stdout['type'], filter_content_type)
Exemplo n.º 13
0
    def test_create_cvf_with_repo_by_name(self):
        """Test: Create new content view filter and assign it to existing
        content view that has repository assigned to it. Use that repository
        name for proper filter assignment.

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has proper
        repository affected

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'inclusion': 'false',
            'name': self.cvf_name,
            'repositories': self.repo['name'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': self.cvf_name
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(
            result.stdout['repositories'][0]['name'], self.repo['name'])
Exemplo n.º 14
0
    def test_create_cvf_with_description(self):
        """Test: Create new content view filter with description and assign it
        to existing content view.

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has proper
        description

        """
        description = gen_string('utf8')
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'description': description,
            'type': 'package_group',
            'name': self.cvf_name,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': self.cvf_name
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(result.stdout['description'], description)
Exemplo n.º 15
0
    def test_create_cvf_with_inclusions(self, inclusion):
        """Test: Create new content view filter and assign it to existing
        content view by id. Use different inclusions as a parameter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has correct and
        expected parameters

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'inclusion': inclusion,
            'name': self.cvf_name,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': self.cvf_name
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(result.stdout['inclusion'], inclusion)
Exemplo n.º 16
0
 def setUpClass(cls):
     """Create an organization, product and ostree repo."""
     super(OstreeBranchTestCase, cls).setUpClass()
     password = '******'
     cls.user = make_user({'admin': 'true', 'password': password})
     cls.user['password'] = password
     credentials = cls.get_user_credentials()
     cls.org = make_org_with_credentials(credentials=credentials)
     cls.product = make_product_with_credentials(
         {u'organization-id': cls.org['id']}, credentials)
     # Create new custom ostree repo
     cls.ostree_repo = make_repository_with_credentials(
         {
             u'product-id': cls.product['id'],
             u'content-type': u'ostree',
             u'publish-via-http': u'false',
             u'url': FEDORA27_OSTREE_REPO,
         }, credentials)
     Repository.with_user(*credentials).synchronize(
         {'id': cls.ostree_repo['id']})
     cls.cv = make_content_view(
         {
             u'organization-id': cls.org['id'],
             u'repository-ids': [cls.ostree_repo['id']],
         }, credentials)
     ContentView.with_user(*credentials).publish({u'id': cls.cv['id']})
     cls.cv = ContentView.with_user(*credentials).info(
         {u'id': cls.cv['id']})
Exemplo n.º 17
0
    def test_update_cvf_with_same_name_negative(self):
        """@Test: Try to update content view filter using name of already
        existing entity

        @Feature: Content View Filter

        @Assert: Content view filter is not updated

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'name': self.cvf_name,
        })
        self.assertEqual(result.return_code, 0)

        new_name = gen_string('alpha', 100)
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'type': 'rpm',
            'name': new_name,
        })
        self.assertEqual(result.return_code, 0)

        result = ContentView.filter_update({
            'content-view-id': self.content_view['id'],
            'name': new_name,
            'new-name': self.cvf_name,
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)
Exemplo n.º 18
0
    def test_positive_create_with_repo_by_id(self):
        """Create new content view filter and assign it to existing content
        view that has repository assigned to it. Use that repository id for
        proper filter assignment.

        @id: 6d517e09-6a6a-4eed-91fe-9459610c0062

        @Assert: Content view filter created successfully and has proper
        repository affected

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'true',
            'name': cvf_name,
            'repository-ids': self.repo['id'],
            'organization-id': self.org['id'],
            'type': 'rpm',
        })
        cvf = ContentView.filter_info({
            u'content-view-id':
            self.content_view['id'],
            u'name':
            cvf_name,
        })
        self.assertEqual(cvf['repositories'][0]['name'], self.repo['name'])
Exemplo n.º 19
0
    def test_update_cvf_with_inclusion_negative(self):
        """Test: Try to update content view filter and assign incorrect
        inclusion value for it

        @Feature: Content View Filter

        @Assert: Content view filter is not updated

        """
        result = ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'true',
            'type': 'rpm',
            'name': self.cvf_name,
        })
        self.assertEqual(result.return_code, 0)

        result = ContentView.filter_update({
            'content-view-id': self.content_view['id'],
            'name': self.cvf_name,
            'inclusion': 'wrong_value',
        })
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)

        result = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': self.cvf_name,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(result.stdout['inclusion'], 'true')
Exemplo n.º 20
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'])
Exemplo n.º 21
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'])
Exemplo n.º 22
0
    def test_cli_inc_update_noapply(self):
        """@Test: Check if cli incremental update can be done without
        actually applying it

        @Feature: Incremental Update

        @Assert: Incremental update completed with no errors and Content view
        has a newer version

        """
        # Get the content view versions and use the recent one.  API always
        # returns the versions in ascending order so it is safe to assume the
        # last one in the list is the recent

        cv_versions = self.rhel_6_partial_cv.version

        # Get the applicable errata
        errata_list = self.get_applicable_errata(self.rhel_66_repo)
        self.assertGreater(len(errata_list), 0)

        # Apply incremental update using the first applicable errata
        ContentViewCLI.version_incremental_update({
            u'content-view-version-id': cv_versions[-1].id,
            u'environment-ids': self.qe_lce.id,
            u'errata-ids': errata_list[0].id,
        })

        # Re-read the content view to get the latest versions
        self.rhel_6_partial_cv = self.rhel_6_partial_cv.read()
        self.assertGreater(
            len(self.rhel_6_partial_cv.version),
            len(cv_versions)
        )
Exemplo n.º 23
0
    def test_positive_create_with_inclusion_by_cv_id(self):
        """Create new content view filter and assign it to existing content
        view by id. Use different inclusions as a parameter

        @id: 4a18ee71-3f0d-4e8b-909e-999d722ebc0a

        @Assert: Content view filter created successfully and has correct and
        expected parameters

        """
        for inclusion in ('true', 'false'):
            with self.subTest(inclusion):
                cvf_name = gen_string('utf8')
                ContentView.filter_create({
                    'content-view-id': self.content_view['id'],
                    'inclusion': inclusion,
                    'name': cvf_name,
                    'organization-id': self.org['id'],
                    'type': 'rpm',
                })
                cvf = ContentView.filter_info({
                    u'content-view-id': self.content_view['id'],
                    u'name': cvf_name,
                })
                self.assertEqual(cvf['inclusion'], inclusion)
Exemplo n.º 24
0
    def test_add_docker_repo_to_content_view(self):
        """@Test: Add one Docker-type repository to a non-composite content view

        @Assert: A repository is created with a Docker repository and the
        product is added to a non-composite content view

        @Feature: Docker

        """
        repo = _make_docker_repo(
            make_product({'organization-id': self.org_id})['id'])
        content_view = make_content_view({
            'composite': False,
            'organization-id': self.org_id,
        })
        result = ContentView.add_repository({
            'id': content_view['id'],
            'repository-id': repo['id'],
        })
        self.assertEqual(result.return_code, 0)
        content_view = ContentView.info({'id': content_view['id']}).stdout
        self.assertIn(
            repo['id'],
            [repo_['id'] for repo_ in content_view['docker-repositories']],
        )
Exemplo n.º 25
0
    def test_add_synced_docker_repo_to_content_view(self):
        """@Test: Create and sync a Docker-type repository

        @Assert: A repository is created with a Docker repository
        and it is synchronized.

        @Feature: Docker

        """
        repo = _make_docker_repo(
            make_product({'organization-id': self.org_id})['id'])
        result = Repository.synchronize({'id': repo['id']})
        self.assertEqual(result.return_code, 0)
        repo = Repository.info({'id': repo['id']}).stdout
        self.assertGreaterEqual(
            int(repo['content-counts']['docker-images']), 1)
        content_view = make_content_view({
            'composite': False,
            'organization-id': self.org_id,
        })
        result = ContentView.add_repository({
            'id': content_view['id'],
            'repository-id': repo['id'],
        })
        self.assertEqual(result.return_code, 0)
        content_view = ContentView.info({'id': content_view['id']}).stdout
        self.assertIn(
            repo['id'],
            [repo_['id'] for repo_ in content_view['docker-repositories']],
        )
Exemplo n.º 26
0
    def test_negative_update_inclusion(self):
        """Try to update content view filter and assign incorrect inclusion
        value for it

        @Feature: Content View Filter

        @Assert: Content view filter is not updated

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'true',
            'name': cvf_name,
            'type': 'rpm',
        })
        with self.assertRaises(CLIReturnCodeError):
            ContentView.filter_update({
                'content-view-id':
                self.content_view['id'],
                'inclusion':
                'wrong_value',
                'name':
                cvf_name,
            })
        cvf = ContentView.filter_info({
            u'content-view-id':
            self.content_view['id'],
            u'name':
            cvf_name,
        })
        self.assertEqual(cvf['inclusion'], 'true')
Exemplo n.º 27
0
    def test_negative_update_with_invalid_repo_id(self):
        """Try to update filter and assign repository which does not belong to
        filter content view

        @Feature: Content View Filter

        @Assert: Content view filter is not updated

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'name': cvf_name,
            'repository-ids': self.repo['id'],
            'type': 'rpm',
        })
        new_repo = make_repository({u'product-id': self.product['id']})
        with self.assertRaises(CLIReturnCodeError):
            ContentView.filter_update({
                'content-view-id':
                self.content_view['id'],
                'name':
                cvf_name,
                'repository-ids':
                new_repo['id'],
            })
Exemplo n.º 28
0
    def test_positive_create_with_repo_by_name(self):
        """Create new content view filter and assign it to existing content
        view that has repository assigned to it. Use that repository name for
        proper filter assignment.

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has proper
        repository affected

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'false',
            'name': cvf_name,
            'repositories': self.repo['name'],
            'type': 'rpm',
        })
        cvf = ContentView.filter_info({
            u'content-view-id':
            self.content_view['id'],
            u'name':
            cvf_name,
        })
        self.assertEqual(cvf['repositories'][0]['name'], self.repo['name'])
Exemplo n.º 29
0
    def test_positive_create_with_name_by_cv_id(self):
        """Create new content view filter and assign it to existing content
        view by id. Use different value types as a name and random filter
        content type as a parameter for this filter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has correct and
        expected parameters

        """
        for name in valid_data_list():
            with self.subTest(name):
                filter_content_type = gen_choice([
                    'rpm',
                    'package_group',
                    'erratum',
                ])
                ContentView.filter_create({
                    'content-view-id':
                    self.content_view['id'],
                    'name':
                    name,
                    'type':
                    filter_content_type,
                })
                cvf = ContentView.filter_info({
                    u'content-view-id':
                    self.content_view['id'],
                    u'name':
                    name,
                })
                self.assertEqual(cvf['name'], name)
                self.assertEqual(cvf['type'], filter_content_type)
Exemplo n.º 30
0
    def test_positive_create_with_original_pkgs(self):
        """Test: Create new content view filter and assign it to existing
        content view that has repository assigned to it. Enable 'original
        packages' option for that filter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has proper
        repository affected

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'true',
            'name': cvf_name,
            'original-packages': 'true',
            'repository-ids': self.repo['id'],
            'type': 'rpm',
        })
        cvf = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': cvf_name,
        })
        self.assertEqual(cvf['repositories'][0]['name'], self.repo['name'])
Exemplo n.º 31
0
    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)
Exemplo n.º 32
0
    def test_positive_noapply_cli(self):
        """Check if cli incremental update can be done without
        actually applying it

        :id: f25b0919-74cb-4e2c-829e-482558990b3c

        :expectedresults: Incremental update completed with no errors and
            Content view has a newer version

        :CaseLevel: System
        """
        # Get the content view versions and use the recent one.  API always
        # returns the versions in ascending order so it is safe to assume the
        # last one in the list is the recent

        cv_versions = self.rhel_6_partial_cv.version

        # Get the applicable errata
        errata_list = self.get_applicable_errata(self.rhva_6_repo)
        self.assertGreater(len(errata_list), 0)

        # Apply incremental update using the first applicable errata
        ContentViewCLI.version_incremental_update({
            u'content-view-version-id': cv_versions[-1].id,
            u'lifecycle-environment-ids': self.qe_lce.id,
            u'errata-ids': errata_list[0].id,
        })

        # Re-read the content view to get the latest versions
        self.rhel_6_partial_cv = self.rhel_6_partial_cv.read()
        self.assertGreater(
            len(self.rhel_6_partial_cv.version),
            len(cv_versions)
        )
Exemplo n.º 33
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)
Exemplo n.º 34
0
    def test_negative_update_inclusion(self):
        """Try to update content view filter and assign incorrect inclusion
        value for it

        @id: 760400a8-49a5-4a31-924c-c232cb22ddad

        @Assert: Content view filter is not updated

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'true',
            'name': cvf_name,
            'organization-id': self.org['id'],
            'type': 'rpm',
        })
        with self.assertRaises(CLIReturnCodeError):
            ContentView.filter_update({
                'content-view-id': self.content_view['id'],
                'inclusion': 'wrong_value',
                'name': cvf_name,
            })
        cvf = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': cvf_name,
        })
        self.assertEqual(cvf['inclusion'], 'true')
Exemplo n.º 35
0
    def test_positive_update_name(self):
        """Create new content view filter and assign it to existing content
        view by id. Try to update that filter using different value types as a
        name

        @id: 70ba8916-5898-4911-9de8-21d2e0fb3df9

        @Assert: Content view filter updated successfully and has proper and
        expected name


        @CaseLevel: Integration
        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'name': cvf_name,
            'organization-id': self.org['id'],
            'type': 'rpm',
        })
        for new_name in valid_data_list():
            with self.subTest(new_name):
                ContentView.filter_update({
                    'content-view-id': self.content_view['id'],
                    'name': cvf_name,
                    'new-name': new_name,
                    'organization-id': self.org['id'],
                })
                cvf = ContentView.filter_info({
                    u'content-view-id': self.content_view['id'],
                    u'name': new_name,
                })
                self.assertEqual(cvf['name'], new_name)
                cvf_name = new_name  # updating cvf name for next iteration
Exemplo n.º 36
0
    def test_positive_create_with_repo_by_id(self):
        """Create new content view filter and assign it to existing content
        view that has repository assigned to it. Use that repository id for
        proper filter assignment.

        @id: 6d517e09-6a6a-4eed-91fe-9459610c0062

        @Assert: Content view filter created successfully and has proper
        repository affected

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'true',
            'name': cvf_name,
            'repository-ids': self.repo['id'],
            'organization-id': self.org['id'],
            'type': 'rpm',
        })
        cvf = ContentView.filter_info({
            u'content-view-id': self.content_view['id'],
            u'name': cvf_name,
        })
        self.assertEqual(cvf['repositories'][0]['name'], self.repo['name'])
Exemplo n.º 37
0
    def test_positivec_create_with_inclusion_by_cv_id(self):
        """Create new content view filter and assign it to existing content
        view by id. Use different inclusions as a parameter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has correct and
        expected parameters

        """
        for inclusion in ('true', 'false'):
            with self.subTest(inclusion):
                cvf_name = gen_string('utf8')
                ContentView.filter_create({
                    'content-view-id':
                    self.content_view['id'],
                    'inclusion':
                    inclusion,
                    'name':
                    cvf_name,
                    'type':
                    'rpm',
                })
                cvf = ContentView.filter_info({
                    u'content-view-id':
                    self.content_view['id'],
                    u'name':
                    cvf_name,
                })
                self.assertEqual(cvf['inclusion'], inclusion)
Exemplo n.º 38
0
    def test_positive_update_name(self):
        """Test: Create new content view filter and assign it to existing
        content view by id. Try to update that filter using different value
        types as a name

        @Feature: Content View Filter

        @Assert: Content view filter updated successfully and has proper and
        expected name

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'name': cvf_name,
            'type': 'rpm',
        })
        for new_name in valid_data_list():
            with self.subTest(new_name):
                ContentView.filter_update({
                    'content-view-id': self.content_view['id'],
                    'name': cvf_name,
                    'new-name': new_name,
                })
                cvf = ContentView.filter_info({
                    u'content-view-id': self.content_view['id'],
                    u'name': new_name,
                })
                self.assertEqual(cvf['name'], new_name)
                cvf_name = new_name  # updating cvf name for next iteration
Exemplo n.º 39
0
    def test_positive_create_with_description_by_cv_id(self):
        """Create new content view filter with description and assign it to
        existing content view.

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has proper
        description

        """
        description = gen_string('utf8')
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'description': description,
            'name': cvf_name,
            'type': 'package_group',
        })
        cvf = ContentView.filter_info({
            u'content-view-id':
            self.content_view['id'],
            u'name':
            cvf_name,
        })
        self.assertEqual(cvf['description'], description)
Exemplo n.º 40
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']
Exemplo n.º 41
0
    def test_positive_create_with_original_pkgs(self):
        """Create new content view filter and assign it to existing content
        view that has repository assigned to it. Enable 'original packages'
        option for that filter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has proper
        repository affected

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'inclusion': 'true',
            'name': cvf_name,
            'original-packages': 'true',
            'repository-ids': self.repo['id'],
            'type': 'rpm',
        })
        cvf = ContentView.filter_info({
            u'content-view-id':
            self.content_view['id'],
            u'name':
            cvf_name,
        })
        self.assertEqual(cvf['repositories'][0]['name'], self.repo['name'])
Exemplo n.º 42
0
    def set_importing_org(self, product, repo, cv):
        """Sets same CV, product and repository in importing organization as
        exporting organization

        :param str product: The product name same as exporting product
        :param str repo: The repo name same as exporting repo
        :param str cv: The cv name same as exporting cv
        """
        self.importing_org = make_org()
        importing_prod = make_product({
            'organization-id': self.importing_org['id'],
            'name': product
        })
        importing_repo = make_repository({
            'name': repo,
            'download-policy': 'immediate',
            'product-id': importing_prod['id']
        })
        self.importing_cv = make_content_view({
            'name': cv,
            'organization-id': self.importing_org['id']
        })
        ContentView.add_repository({
            'id': self.importing_cv['id'],
            'organization-id': self.importing_org['id'],
            'repository-id': importing_repo['id']
        })
Exemplo n.º 43
0
    def test_positive_update_name(self):
        """Create new content view filter and assign it to existing content
        view by id. Try to update that filter using different value types as a
        name

        @Feature: Content View Filter

        @Assert: Content view filter updated successfully and has proper and
        expected name

        """
        cvf_name = gen_string('utf8')
        ContentView.filter_create({
            'content-view-id': self.content_view['id'],
            'name': cvf_name,
            'type': 'rpm',
        })
        for new_name in valid_data_list():
            with self.subTest(new_name):
                ContentView.filter_update({
                    'content-view-id':
                    self.content_view['id'],
                    'name':
                    cvf_name,
                    'new-name':
                    new_name,
                })
                cvf = ContentView.filter_info({
                    u'content-view-id':
                    self.content_view['id'],
                    u'name':
                    new_name,
                })
                self.assertEqual(cvf['name'], new_name)
                cvf_name = new_name  # updating cvf name for next iteration
Exemplo n.º 44
0
    def test_positive_export_import_cv(self):
        """Export CV version contents in directory and Import them.

        :id: b08e9f24-f18e-43b7-9189-ad7b596ccb5b

        :steps:

            1. Export whole CV version contents to a directory
            3. Import those contents from some other org/satellite.

        :expectedresults:

            1. Whole CV version contents has been exported to directory
            2. All The exported contents has been imported in org/satellite.

        :CaseLevel: System
        """
        ContentView.version_export({
            'export-dir': '{}'.format(self.export_dir),
            'id': self.exporting_cvv_id
        })
        exported_tar = '{0}/export-{1}.tar'.format(self.export_dir, self.exporting_cvv_id)
        result = ssh.command("[ -f {0} ]".format(exported_tar))
        self.assertEqual(result.return_code, 0)
        exported_packages = Package.list({'content-view-version-id': self.exporting_cvv_id})
        self.set_importing_org(self.exporting_prod, self.exporting_repo, self.exporting_cv)
        ContentView.version_import({
            'export-tar': exported_tar,
            'organization-id': self.importing_org['id']
        })
        importing_cvv_id = ContentView.info({
            u'id': self.importing_cv['id']
        })['versions'][0]['id']
        imported_packages = Package.list({'content-view-version-id': importing_cvv_id})
        self.assertEqual(len(exported_packages), len(imported_packages))
Exemplo n.º 45
0
    def test_positive_create_with_content_type_by_cv_id(self):
        """Create new content view filter and assign it to existing content
        view by id. Use different content types as a parameter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has correct and
        expected parameters

        """
        for filter_content_type in ('rpm', 'package_group', 'erratum'):
            with self.subTest(filter_content_type):
                cvf_name = gen_string('utf8')
                ContentView.filter_create({
                    'content-view-id':
                    self.content_view['id'],
                    'name':
                    cvf_name,
                    'type':
                    filter_content_type,
                })
                cvf = ContentView.filter_info({
                    u'content-view-id':
                    self.content_view['id'],
                    u'name':
                    cvf_name,
                })
                self.assertEqual(cvf['type'], filter_content_type)
Exemplo n.º 46
0
    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)
Exemplo n.º 47
0
def ostree_repo_with_user(ostree_user_credentials):
    """Create an user, organization, product and ostree repo,
    sync ostree repo for particular user,
    create content view and publish it for particular user
    """
    org = make_org_with_credentials(credentials=ostree_user_credentials)
    product = make_product_with_credentials(
        {'organization-id': org['id']}, ostree_user_credentials
    )
    # Create new custom ostree repo
    ostree_repo = make_repository_with_credentials(
        {
            'product-id': product['id'],
            'content-type': 'ostree',
            'publish-via-http': 'false',
            'url': OSTREE_REPO,
        },
        ostree_user_credentials,
    )
    Repository.with_user(*ostree_user_credentials).synchronize({'id': ostree_repo['id']})
    cv = make_content_view(
        {'organization-id': org['id'], 'repository-ids': [ostree_repo['id']]},
        ostree_user_credentials,
    )
    ContentView.with_user(*ostree_user_credentials).publish({'id': cv['id']})
    cv = ContentView.with_user(*ostree_user_credentials).info({'id': cv['id']})
    return {'cv': cv, 'org': org, 'ostree_repo': ostree_repo, 'product': product}
Exemplo n.º 48
0
    def test_positive_create_with_name_by_cv_id(self):
        """Test: Create new content view filter and assign it to existing
        content view by id. Use different value types as a name and random
        filter content type as a parameter for this filter

        @Feature: Content View Filter

        @Assert: Content view filter created successfully and has correct and
        expected parameters

        """
        for name in valid_data_list():
            with self.subTest(name):
                filter_content_type = gen_choice([
                    'rpm',
                    'package_group',
                    'erratum',
                ])
                ContentView.filter_create({
                    'content-view-id': self.content_view['id'],
                    'name': name,
                    'type': filter_content_type,
                })
                cvf = ContentView.filter_info({
                    u'content-view-id': self.content_view['id'],
                    u'name': name,
                })
                self.assertEqual(cvf['name'], name)
                self.assertEqual(cvf['type'], filter_content_type)
Exemplo n.º 49
0
    def test_add_multiple_docker_repos_to_content_view(self):
        """@Test: Add multiple Docker-type repositories to a
        non-composite content view.

        @Assert: Repositories are created with Docker images and the
        product is added to a non-composite content view.

        @Feature: Docker

        """
        product = make_product({'organization-id': self.org_id})
        repos = [
            _make_docker_repo(product['id'])
            for _
            in range(randint(2, 5))
        ]
        content_view = make_content_view({
            'composite': False,
            'organization-id': self.org_id,
        })
        for repo in repos:
            result = ContentView.add_repository({
                'id': content_view['id'],
                'repository-id': repo['id'],
            })
            self.assertEqual(result.return_code, 0)
        content_view = ContentView.info({'id': content_view['id']}).stdout
        self.assertEqual(
            set([repo['id'] for repo in repos]),
            set([repo['id'] for repo in content_view['docker-repositories']]),
        )
Exemplo n.º 50
0
    def test_positive_noapply_cli(self):
        """Check if cli incremental update can be done without
        actually applying it

        @Feature: Incremental Update

        @Assert: Incremental update completed with no errors and Content view
        has a newer version

        """
        # Get the content view versions and use the recent one.  API always
        # returns the versions in ascending order so it is safe to assume the
        # last one in the list is the recent

        cv_versions = self.rhel_6_partial_cv.version

        # Get the applicable errata
        errata_list = self.get_applicable_errata(self.rhel_66_repo)
        self.assertGreater(len(errata_list), 0)

        # Apply incremental update using the first applicable errata
        ContentViewCLI.version_incremental_update({
            u'content-view-version-id':
            cv_versions[-1].id,
            u'environment-ids':
            self.qe_lce.id,
            u'errata-ids':
            errata_list[0].id,
        })

        # Re-read the content view to get the latest versions
        self.rhel_6_partial_cv = self.rhel_6_partial_cv.read()
        self.assertGreater(len(self.rhel_6_partial_cv.version),
                           len(cv_versions))
Exemplo n.º 51
0
    def test_positive_noapply_cli(self):
        """Check if cli incremental update can be done without
        actually applying it

        :id: f25b0919-74cb-4e2c-829e-482558990b3c

        :expectedresults: Incremental update completed with no errors and
            Content view has a newer version

        :CaseLevel: System
        """
        # Get the content view versions and use the recent one.  API always
        # returns the versions in ascending order so it is safe to assume the
        # last one in the list is the recent

        cv_versions = self.rhel_6_partial_cv.version

        # Get the applicable errata
        errata_list = self.get_applicable_errata(self.rhva_6_repo)
        self.assertGreater(len(errata_list), 0)

        # Apply incremental update using the first applicable errata
        ContentViewCLI.version_incremental_update({
            u'content-view-version-id': cv_versions[-1].id,
            u'lifecycle-environment-ids': self.qe_lce.id,
            u'errata-ids': errata_list[0].id,
        })

        # Re-read the content view to get the latest versions
        self.rhel_6_partial_cv = self.rhel_6_partial_cv.read()
        self.assertGreater(
            len(self.rhel_6_partial_cv.version),
            len(cv_versions)
        )
Exemplo n.º 52
0
    def test_post_version_cv_export_import(
        self, request, set_importing_org, dependent_scenario_name, default_sat
    ):
        """After upgrade, content view version import and export works on the existing content
         view(that we created before the upgrade).

        :id: postupgrade-f19e4928-94db-4df6-8ce8-b5e4afe34258

        :parametrized: yes

        :steps:
            1: Export the existing content-view version.
            2: Import the existing content-view version.
            3: Delete the imported and exported content-vew, product, repo and organization.

        :expectedresults: After upgrade,
            1: Content view created before upgrade should be imported and exported successfully.
            2: Imported and Exported content view should be deleted successfully
        """
        pre_test_name = dependent_scenario_name
        export_base = '/var/lib/pulp/katello-export/'
        org = entities.Organization().search(query={'search': f'name="{pre_test_name}_org"'})[0]
        request.addfinalizer(org.delete)
        product = entities.Product(organization=org).search(
            query={'search': f'name="{pre_test_name}_prod"'}
        )[0]
        request.addfinalizer(product.delete)
        exporting_cv = entities.ContentView(organization=org).search(
            query={'search': f'name="{pre_test_name}_cv"'}
        )[0]
        request.addfinalizer(exporting_cv.delete)

        exporting_cvv_id = max(cvv.id for cvv in exporting_cv.version)
        exporting_cvv_version = entities.ContentViewVersion(id=exporting_cvv_id).read().version

        ContentView.version_export({'export-dir': f'{export_base}', 'id': exporting_cvv_id})
        exported_tar = f'{export_base}/export-{exporting_cv.name}-{exporting_cvv_version}.tar'

        result = default_sat.execute(f'[ -f {exported_tar} ]')
        assert result.status == 0

        exported_packages = Package.list({'content-view-version-id': exporting_cvv_id})
        assert len(exported_packages) > 0
        importing_cv, importing_org = set_importing_org
        ContentView.version_import(
            {'export-tar': f'{exported_tar}', 'organization-id': importing_org.id}
        )
        importing_cvv = importing_cv.read().version
        assert len(importing_cvv) == 1
        imported_packages = Package.list({'content-view-version-id': importing_cvv[0].id})
        assert len(imported_packages) > 0
        assert len(exported_packages) == len(imported_packages)
        default_sat.execute(f'rm -rf {export_base}/*')
        exporting_cv_json = exporting_cv.read_json()
        importing_cv_json = importing_cv.read_json()
        exporting_cv_env_id = exporting_cv_json['environments'][0]['id']
        importing_cv_env_id = importing_cv_json['environments'][0]['id']
        assert exporting_cv.delete_from_environment(exporting_cv_env_id)
        assert importing_cv.delete_from_environment(importing_cv_env_id)
Exemplo n.º 53
0
    def test_positive_chost_previous_env(self):
        """Check if the applicable errata are available from the content
        host's previous environment

        :id: 78110ba8-3942-46dd-8c14-bffa1dbd5195

        :Setup:

            1. Make sure multiple environments are present.
            2. Content host's previous environments have additional errata.

        :Steps: Go to Content Hosts -> Select content host -> Errata Tab ->
            Select Previous environments.

        :expectedresults: The errata from previous environments are displayed.

        :CaseLevel: System
        """
        with VirtualMachine(distro=DISTRO_RHEL7) as client:
                client.install_katello_ca()
                client.register_contenthost(
                    self.session_org.label,
                    self.activation_key.name,
                )
                self.assertTrue(client.subscribed)
                client.enable_repo(REPOS['rhst7']['id'])
                client.install_katello_agent()
                client.run(
                    'yum install -y {0}'.format(FAKE_1_CUSTOM_PACKAGE))
                last_env_id = max(
                    lce.id
                    for lce
                    in entities.LifecycleEnvironment(
                        organization=self.session_org).search()
                )
                new_env = entities.LifecycleEnvironment(
                    organization=self.session_org,
                    prior=last_env_id,
                ).create()
                cvv = ContentView.info({
                    'id': self.content_view.id})['versions'][-1]
                ContentView.version_promote({
                    'id': cvv['id'],
                    'organization-id': self.session_org.id,
                    'to-lifecycle-environment-id': new_env.id,
                })
                Host.update({
                    'name': client.hostname,
                    'lifecycle-environment-id': new_env.id,
                    'organization-id': self.session_org.id,
                })
                with Session(self):
                    self.assertIsNotNone(
                        self.contenthost.errata_search(
                            client.hostname,
                            CUSTOM_REPO_ERRATA_ID,
                            environment_name=self.env.name,
                        )
                    )
Exemplo n.º 54
0
 def add_to_content_view(self, organization_id, content_view_id):
     # type: (int, int) -> None
     """Associate repository content to content-view"""
     ContentView.add_repository({
         'id': content_view_id,
         'organization-id': organization_id,
         'repository-id': self._repo_info['id'],
     })
Exemplo n.º 55
0
 def add_to_content_view(self, organization_id, content_view_id):
     # type: (int, int) -> None
     """Associate repository content to content-view"""
     options = {'content-view-id': content_view_id, 'organization-id': organization_id}
     for puppet_module in self.puppet_modules:
         module_options = options.copy()
         module_options.update(puppet_module)
         ContentView.puppet_module_add(module_options)
Exemplo n.º 56
0
    def test_cv_preupgrade_scenario(self, request):
        """Pre-upgrade scenario that creates content-view with various repositories.

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

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

        :expectedresults: Content-view created with various repositories.
        """
        test_name = request.node.name
        puppet_module = {'name': 'versioned', 'version': '3.3.3'}
        org = entities.Organization(name=f'{request.node.name}_org').create()
        product = entities.Product(organization=org,
                                   name=f'{request.node.name}_prod').create()
        yum_repository = entities.Repository(product=product,
                                             name=f'{test_name}_yum_repo',
                                             url=FAKE_1_YUM_REPO).create()
        entities.Repository.sync(yum_repository)
        puppet_repository = entities.Repository(
            product=product,
            name=f'{request.node.name}_puppet_repo',
            content_type="puppet",
            url=CUSTOM_PUPPET_REPO,
        ).create()
        entities.Repository.sync(puppet_repository)
        puppet_module_list = PuppetModule.list({
            'search':
            'name={name} and version={version}'.format(**puppet_module)
        })[0]

        file_repository = entities.Repository(product=product,
                                              name=f'{test_name}_file_repo',
                                              content_type="file").create()

        remote_file_path = f"/tmp/{RPM_TO_UPLOAD}"

        ssh.upload_file(local_file=get_data_file(RPM_TO_UPLOAD),
                        remote_file=remote_file_path)
        with open(f'{get_data_file(RPM_TO_UPLOAD)}', "rb") as content:
            file_repository.upload_content(files={'content': content})
        assert RPM_TO_UPLOAD in file_repository.files()["results"][0]['name']
        cv = entities.ContentView(name=f"{test_name}_cv",
                                  organization=org).create()
        cv.repository = [yum_repository, file_repository]
        cv.update(['repository'])
        ContentView.puppet_module_add({
            'content-view-id': cv.id,
            'name': puppet_module_list['name'],
            'author': puppet_module_list['author'],
        })
        cv.publish()
        assert len(cv.puppet_module) == 0
        assert len(cv.read_json()['versions']) == 1
Exemplo n.º 57
0
    def test_positive_update_repo_with_same_type(self, module_org,
                                                 module_product, sync_repo,
                                                 content_view):
        """Create new content view filter and apply it to existing content view
        that has repository assigned to it. Try to update that filter and
        change affected repository on another one.

        :id: b2f444fd-e65e-41ba-9941-620d3cdb260f

        :expectedresults: Content view filter updated successfully and has new
            repository affected

        :CaseLevel: Integration

        :CaseImportance: Critical
        """
        cvf_name = gen_string('utf8')
        ContentView.filter.create(
            {
                'content-view-id': content_view['id'],
                'name': cvf_name,
                'repository-ids': sync_repo['id'],
                'type': 'rpm',
            }, )
        cvf = ContentView.filter.info({
            'content-view-id': content_view['id'],
            'name': cvf_name
        })
        assert len(cvf['repositories']) == 1
        assert cvf['repositories'][0]['name'] == sync_repo['name']

        new_repo = make_repository(
            {
                'organization-id': module_org.id,
                'product-id': module_product.id
            }, )
        ContentView.add_repository({
            'id': content_view['id'],
            'repository-id': new_repo['id']
        })

        ContentView.filter.update({
            'content-view-id': content_view['id'],
            'name': cvf_name,
            'repository-ids': new_repo['id'],
        })

        cvf = ContentView.filter.info({
            'content-view-id': content_view['id'],
            'name': cvf_name
        })
        assert len(cvf['repositories']) == 1
        assert cvf['repositories'][0]['name'] != sync_repo['name']
        assert cvf['repositories'][0]['name'] == new_repo['name']
Exemplo n.º 58
0
    def test_positive_update_repo_with_different_type(self):
        """Create new content view filter and apply it to existing content view
        that has repository assigned to it. Try to update that filter and
        change affected repository on another one. That new repository should
        have another type from initial one (e.g. yum->docker)

        @id: cf3daa0d-e918-4330-95ad-f88933579829

        @Assert: Content view filter updated successfully and has new
        repository affected


        @CaseLevel: Integration
        """
        cvf_name = gen_string('utf8')
        ContentView.filter.create({
            'content-view-id': self.content_view['id'],
            'name': cvf_name,
            'repository-ids': self.repo['id'],
            'type': 'rpm',
        })
        cvf = ContentView.filter.info({
            u'content-view-id':
            self.content_view['id'],
            u'name':
            cvf_name,
        })
        self.assertEqual(len(cvf['repositories']), 1)
        self.assertEqual(cvf['repositories'][0]['name'], self.repo['name'])
        docker_repo = make_repository({
            u'content-type': u'docker',
            u'docker-upstream-name': u'busybox',
            u'product-id': self.product['id'],
            u'url': DOCKER_REGISTRY_HUB,
        })
        ContentView.add_repository({
            u'id': self.content_view['id'],
            u'repository-id': docker_repo['id'],
        })
        ContentView.filter.update({
            'content-view-id': self.content_view['id'],
            'name': cvf_name,
            'repository-ids': docker_repo['id'],
        })
        cvf = ContentView.filter.info({
            u'content-view-id':
            self.content_view['id'],
            u'name':
            cvf_name,
        })
        self.assertEqual(len(cvf['repositories']), 1)
        self.assertNotEqual(cvf['repositories'][0]['name'], self.repo['name'])
        self.assertEqual(cvf['repositories'][0]['name'], docker_repo['name'])
Exemplo n.º 59
0
    def test_positive_update_repo_with_different_type(self, module_org,
                                                      module_product,
                                                      sync_repo, content_view):
        """Create new content view filter and apply it to existing content view
        that has repository assigned to it. Try to update that filter and
        change affected repository on another one. That new repository should
        have another type from initial one (e.g. yum->docker)

        :id: cf3daa0d-e918-4330-95ad-f88933579829

        :expectedresults: Content view filter updated successfully and has new
            repository affected

        :CaseLevel: Integration
        """
        cvf_name = gen_string('utf8')
        ContentView.filter.create(
            {
                'content-view-id': content_view['id'],
                'name': cvf_name,
                'repository-ids': sync_repo['id'],
                'type': 'rpm',
            }, )
        cvf = ContentView.filter.info({
            'content-view-id': content_view['id'],
            'name': cvf_name
        })
        assert len(cvf['repositories']) == 1
        assert cvf['repositories'][0]['name'] == sync_repo['name']
        docker_repo = make_repository(
            {
                'content-type': 'docker',
                'docker-upstream-name': 'busybox',
                'organization-id': module_org.id,
                'product-id': module_product.id,
                'url': DOCKER_REGISTRY_HUB,
            }, )
        ContentView.add_repository({
            'id': content_view['id'],
            'repository-id': docker_repo['id']
        })
        ContentView.filter.update({
            'content-view-id': content_view['id'],
            'name': cvf_name,
            'repository-ids': docker_repo['id'],
        })
        cvf = ContentView.filter.info({
            'content-view-id': content_view['id'],
            'name': cvf_name
        })
        assert len(cvf['repositories']) == 1
        assert cvf['repositories'][0]['name'] != sync_repo['name']
        assert cvf['repositories'][0]['name'] == docker_repo['name']
Exemplo n.º 60
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