def test_positive_content_override(self):
        """Positive content override

        @Feature: Activation key copy

        @Steps:

        1. Create activation key and add content
        2. Get the first product's label
        3. Override the product's content enabled state
        4. Verify that the command succeeded

        @BZ: 1180282

        @Assert: Activation key content override was successful
        """
        result = setup_org_for_a_custom_repo({u"url": FAKE_0_YUM_REPO, u"organization-id": self.org["id"]})
        content = ActivationKey.product_content({u"id": result["activationkey-id"], u"organization-id": self.org["id"]})
        for override_value in (u"1", u"0"):
            with self.subTest(override_value):
                ActivationKey.content_override(
                    {
                        u"content-label": content[0]["label"],
                        u"id": result["activationkey-id"],
                        u"organization-id": self.org["id"],
                        u"value": override_value,
                    }
                )
                # Retrieve the product content enabled flag
                content = ActivationKey.product_content(
                    {u"id": result["activationkey-id"], u"organization-id": self.org["id"]}
                )
                self.assertEqual(content[0]["enabled?"], override_value)
    def test_positive_content_override(self):
        """Positive content override

        :id: a4912cc0-3bf7-4e90-bb51-ec88b2fad227

        :Steps:

            1. Create activation key and add content
            2. Get the first product's label
            3. Override the product's content enabled state
            4. Verify that the command succeeded

        :expectedresults: Activation key content override was successful

        :CaseLevel: System
        """
        result = setup_org_for_a_custom_repo({
            u'url':
            FAKE_0_YUM_REPO,
            u'organization-id':
            self.org['id'],
        })
        content = ActivationKey.product_content({
            u'id':
            result['activationkey-id'],
            u'organization-id':
            self.org['id'],
        })
        for override_value in (True, False):
            with self.subTest(override_value):
                ActivationKey.content_override({
                    u'content-label':
                    content[0]['label'],
                    u'id':
                    result['activationkey-id'],
                    u'organization-id':
                    self.org['id'],
                    u'value':
                    int(override_value),
                })
                # Retrieve the product content enabled flag
                content = ActivationKey.product_content({
                    u'id':
                    result['activationkey-id'],
                    u'organization-id':
                    self.org['id'],
                })
                self.assertEqual(content[0]['enabled?'],
                                 str(override_value).lower())
    def test_positive_content_override(self):
        """Positive content override

        :id: a4912cc0-3bf7-4e90-bb51-ec88b2fad227

        :Steps:

            1. Create activation key and add content
            2. Get the first product's label
            3. Override the product's content enabled state
            4. Verify that the command succeeded

        :expectedresults: Activation key content override was successful

        :CaseLevel: System
        """
        result = setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': self.org['id'],
        })
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': self.org['id'],
        })
        for override_value in (True, False):
            with self.subTest(override_value):
                ActivationKey.content_override({
                    u'content-label': content[0]['label'],
                    u'id': result['activationkey-id'],
                    u'organization-id': self.org['id'],
                    u'value': int(override_value),
                })
                # Retrieve the product content enabled flag
                content = ActivationKey.product_content({
                    u'id': result['activationkey-id'],
                    u'organization-id': self.org['id'],
                })
                self.assertEqual(
                    content[0]['override'],
                    'enabled:{}'.format(int(override_value))
                )
    def test_positive_content_override(self):
        """@Test: Positive content override

        @Feature: Activation key copy

        @Steps:

        1. Create activation key and add content
        2. Get the first product's label
        3. Override the product's content enabled state
        4. Verify that the command succeeded

        @BZ: 1180282

        @Assert: Activation key content override was successful
        """
        result = setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': self.org['id'],
        })
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': self.org['id'],
        })
        for override_value in (u'1', u'0'):
            with self.subTest(override_value):
                ActivationKey.content_override({
                    u'content-label': content[0]['label'],
                    u'id': result['activationkey-id'],
                    u'organization-id': self.org['id'],
                    u'value': override_value,
                })
                # Retrieve the product content enabled flag
                content = ActivationKey.product_content({
                    u'id': result['activationkey-id'],
                    u'organization-id': self.org['id'],
                })
                self.assertEqual(content[0]['enabled?'], override_value)
    def test_positive_content_override(self):
        """Positive content override

        @Feature: Activation key copy

        @Steps:

        1. Create activation key and add content
        2. Get the first product's label
        3. Override the product's content enabled state
        4. Verify that the command succeeded

        @BZ: 1180282

        @Assert: Activation key content override was successful
        """
        result = setup_org_for_a_custom_repo({
            u'url': FAKE_0_YUM_REPO,
            u'organization-id': self.org['id'],
        })
        content = ActivationKey.product_content({
            u'id': result['activationkey-id'],
            u'organization-id': self.org['id'],
        })
        for override_value in (u'1', u'0'):
            with self.subTest(override_value):
                ActivationKey.content_override({
                    u'content-label': content[0]['label'],
                    u'id': result['activationkey-id'],
                    u'organization-id': self.org['id'],
                    u'value': override_value,
                })
                # Retrieve the product content enabled flag
                content = ActivationKey.product_content({
                    u'id': result['activationkey-id'],
                    u'organization-id': self.org['id'],
                })
                self.assertEqual(content[0]['enabled?'], override_value)
    def test_positive_content_override(self):
        """@Test: Positive content override

        @Feature: Activation key copy

        @Steps:

        1. Create activation key and add content
        2. Get the first product's label
        3. Override the product's content enablement
        4. Verify that the command succeeded

        @BZ: 1180282

        @Assert: Activation key content override was successful

        """
        if self.pub_key is None:
            self._make_public_key()
        result = ActivationKey.product_content({
            u'id': self.pub_key['key_id'],
            u'organization-id': self.pub_key['org_id'],
        })
        for override_value in (u'1', u'0'):
            with self.subTest(override_value):
                result = ActivationKey.content_override({
                    u'content-label': result[0]['label'],
                    u'id': self.pub_key['key_id'],
                    u'organization-id': self.pub_key['org_id'],
                    u'value': override_value,
                })
                # Retrieve the product content enabled flag
                result = ActivationKey.product_content({
                    u'id': self.pub_key['key_id'],
                    u'organization-id': self.pub_key['org_id'],
                })
                self.assertEqual(result[0]['enabled?'], override_value)
    def test_positive_content_override(self):
        """@Test: Positive content override

        @Feature: Activation key copy

        @Steps:

        1. Create activation key and add content
        2. Get the first product's label
        3. Override the product's content enablement
        4. Verify that the command succeeded

        @Assert: Activation key content override was successful

        """
        if not bz_bug_is_open(1180282):
            self.fail(
                'BZ 1180282 has been closed. This test should be updated to'
                'verify value change via product-content.'
            )
        if self.pub_key is None:
            self._make_public_key()
        result = ActivationKey.product_content({
            u'id': self.pub_key['key_id'],
            u'organization-id': self.pub_key['org_id'],
        })
        product_label = result[3].split('|')[5].replace(' ', '')
        for override_value in (u'1', u'0'):
            with self.subTest(override_value):
                result = ActivationKey.content_override({
                    u'content-label': product_label,
                    u'id': self.pub_key['key_id'],
                    u'organization-id': self.pub_key['org_id'],
                    u'value': override_value,
                })
                self.assertIn(result[0], 'Updated content override')
Exemple #8
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)
Exemple #9
0
    def test_end_to_end(self):
        """@Test: 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
        manifest = manifests.clone()
        ssh.upload_file(manifest, remote_file=manifest)
        Subscription.upload({
            u'file': manifest,
            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
        )
        # Get the subscription ID from subscriptions list
        for subscription in result:
            if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME:
                subscription_id = subscription['id']
                subscription_quantity = int(subscription['quantity'])
        self.assertGreater(int(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 = conf.properties['main.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)
Exemple #10
0
    def test_end_to_end(self):
        """@Test: 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 = "Red Hat Enterprise Linux Server"
        rhel_repo_set = "Red Hat Enterprise Virtualization Agents " "for RHEL 6 Server (RPMs)"
        rhel_repo_name = "Red Hat Enterprise Virtualization Agents " "for RHEL 6 Server " "RPMs x86_64 6Server"
        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"], u"name": gen_alphanumeric()})
        # Clone manifest and upload it
        manifest = manifests.clone()
        ssh.upload_file(manifest, remote_file=manifest)
        result = Subscription.upload({u"file": manifest, u"organization-id": new_org["id"]})
        self.assertEqual(result.return_code, 0)
        # Enable repo from Repository Set
        result = RepositorySet.enable(
            {
                u"name": rhel_repo_set,
                u"organization-id": new_org["id"],
                u"product": rhel_product_name,
                u"releasever": "6Server",
                u"basearch": "x86_64",
            }
        )
        self.assertEqual(result.return_code, 0)
        # Fetch repository info
        result = Repository.info(
            {u"name": rhel_repo_name, u"product": rhel_product_name, u"organization-id": new_org["id"]}
        )
        rhel_repo = result.stdout
        # Synchronize the repository
        result = Repository.synchronize(
            {u"name": rhel_repo_name, u"organization-id": new_org["id"], u"product": rhel_product_name}
        )
        self.assertEqual(result.return_code, 0)
        # Create CV and associate repo to it
        new_cv = make_content_view({u"organization-id": new_org["id"]})
        result = ContentView.add_repository(
            {u"id": new_cv["id"], u"repository-id": rhel_repo["id"], u"organization-id": new_org["id"]}
        )
        self.assertEqual(result.return_code, 0)
        # Publish a version1 of CV
        result = ContentView.publish({u"id": new_cv["id"]})
        self.assertEqual(result.return_code, 0)
        # Get the CV info
        result = ContentView.info({u"id": new_cv["id"]})
        self.assertEqual(result.return_code, 0)
        # Store the version1 id
        version1_id = result.stdout["versions"][0]["id"]
        # Promotion of version1 to next env
        result = ContentView.version_promote({u"id": version1_id, u"to-lifecycle-environment-id": new_env["id"]})
        self.assertEqual(result.return_code, 0)
        # Create activation key
        activation_key = make_activation_key(
            {
                u"name": gen_alphanumeric(),
                u"lifecycle-environment-id": new_env["id"],
                u"organization-id": new_org["id"],
                u"content-view": new_cv["name"],
            }
        )
        # List the subscriptions in given org
        result = Subscription.list({u"organization-id": new_org["id"]}, per_page=False)
        self.assertEqual(result.return_code, 0)
        # Get the subscription ID from subscriptions list
        for subscription in result.stdout:
            if subscription["name"] == DEFAULT_SUBSCRIPTION_NAME:
                subscription_id = subscription["id"]
                subscription_quantity = int(subscription["quantity"])
        self.assertGreater(int(subscription_quantity), 0)
        # Add the subscriptions to activation-key
        result = ActivationKey.add_subscription(
            {u"id": activation_key["id"], u"subscription-id": subscription_id, u"quantity": 1}
        )
        self.assertEqual(result.return_code, 0)
        # Enable product content
        ActivationKey.content_override(
            {
                u"id": activation_key["id"],
                u"organization-id": new_org["id"],
                u"content-label": "rhel-6-server-rhev-agent-rpms",
                u"value": "1",
            }
        )
        # Create VM
        package_name = "python-kitchen"
        server_name = conf.properties["main.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)