コード例 #1
0
    def test_positive_enable_manifest_reposet(self):
        """enable repository set

        @Feature: Subscriptions/Repository Sets

        @Assert: you are able to enable and synchronize
        repository contained in a manifest
        """
        self._upload_manifest(self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
        RepositorySet.enable({
            'basearch': 'x86_64',
            'name': REPOSET['rhva6'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
        })
        Repository.synchronize({
            'name': REPOS['rhva6']['name'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
        })
コード例 #2
0
    def test_positive_add_subscription_by_id(self):
        """Test that subscription can be added to activation key

        @Feature: Activation key - Subscription

        @Steps:

        1. Create Activation key
        2. Upload manifest and add subscription
        3. Associate the activation key to subscription

        @Assert: Subscription successfully added to activation key
        """
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        org_id = make_org()['id']
        ackey_id = self._make_activation_key()['id']
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org_id,
        })
        subs_id = Subscription.list(
            {'organization-id': org_id},
            per_page=False
        )
        result = ActivationKey.add_subscription({
            u'id': ackey_id,
            u'subscription-id': subs_id[0]['id'],
        })
        self.assertIn('Subscription added to activation key', result)
コード例 #3
0
    def test_positive_add_subscription_by_id(self):
        """Test that subscription can be added to activation key

        :id: b884be1c-b35d-440a-9a9d-c854c83e10a7

        :Steps:

            1. Create Activation key
            2. Upload manifest and add subscription
            3. Associate the activation key to subscription

        :expectedresults: Subscription successfully added to activation key

        :BZ: 1463685

        :CaseLevel: Integration
        """
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        org_id = make_org()['id']
        ackey_id = self._make_activation_key({'organization-id': org_id})['id']
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org_id,
        })
        subs_id = Subscription.list(
            {'organization-id': org_id},
            per_page=False
        )
        result = ActivationKey.add_subscription({
            u'id': ackey_id,
            u'subscription-id': subs_id[0]['id'],
        })
        self.assertIn('Subscription added to activation key', result)
コード例 #4
0
    def test_manifest_upload(self):
        """@Test: upload manifest (positive)

        @Feature: Subscriptions/Manifest Upload

        @Assert: Manifest are uploaded properly

        """

        upload_file(self.manifest, remote_file=self.manifest)
        result = Subscription.upload({
            'file': self.manifest,
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0,
                         "Failed to upload manifest")
        self.assertEqual(
            len(result.stderr), 0,
            "There should not be an exception while uploading manifest.")

        result = Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False)
        self.assertEqual(result.return_code, 0,
                         "Failed to list manifests in this org.")
        self.assertEqual(
            len(result.stderr), 0,
            "There should not be an exception while listing the manifest.")
コード例 #5
0
    def test_positive_enable_by_name(self):
        """Enable repo from reposet by names of reposet, org and product

        :id: a78537bd-b88d-4f00-8901-e7944e5de729

        :expectedresults: Repository was enabled

        :CaseImportance: Critical
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization': org['name'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name': REPOSET['rhva6'],
            u'organization': org['name'],
            u'product': PRDS['rhel'],
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
コード例 #6
0
    def test_manifest_upload(self):
        """@Test: upload manifest (positive)

        @Feature: Subscriptions/Manifest Upload

        @Assert: Manifest are uploaded properly

        """

        upload_file(self.manifest, remote_file=self.manifest)
        result = Subscription.upload({
            'file': self.manifest,
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0,
                         "Failed to upload manifest")
        self.assertEqual(
            len(result.stderr), 0,
            "There should not be an exception while uploading manifest.")

        result = Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False)
        self.assertEqual(result.return_code, 0,
                         "Failed to list manifests in this org.")
        self.assertEqual(
            len(result.stderr), 0,
            "There should not be an exception while listing the manifest.")
コード例 #7
0
    def test_positive_enable_by_name(self):
        """Enable repo from reposet by names of reposet, org and product

        @id: a78537bd-b88d-4f00-8901-e7944e5de729

        @Assert: Repository was enabled
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization': org['name'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name':
            REPOSET['rhva6'],
            u'organization':
            org['name'],
            u'product':
            PRDS['rhel'],
        })
        enabled = [
            repo['enabled'] for repo in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
コード例 #8
0
    def test_positive_enable_by_label(self):
        """Enable repo from reposet by org label, reposet and product
        names

        @id: 5230c1cd-fed7-40ac-8445-bac4f9c5ee68

        @Assert: Repository was enabled
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name':
            REPOSET['rhva6'],
            u'organization-label':
            org['label'],
            u'product':
            PRDS['rhel'],
        })
        enabled = [
            repo['enabled'] for repo in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
コード例 #9
0
    def test_positive_add_subscription_by_id(self):
        """Test that subscription can be added to activation key

        @Feature: Activation key - Subscription

        @Steps:

        1. Create Activation key
        2. Upload manifest and add subscription
        3. Associate the activation key to subscription

        @Assert: Subscription successfully added to activation key
        """
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        org_id = make_org()['id']
        ackey_id = self._make_activation_key()['id']
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org_id,
        })
        subs_id = Subscription.list(
            {'organization-id': org_id},
            per_page=False
        )
        result = ActivationKey.add_subscription({
            u'id': ackey_id,
            u'subscription-id': subs_id[0]['id'],
        })
        self.assertIn('Subscription added to activation key', result)
コード例 #10
0
    def test_enable_manifest_reposet(self):
        """@Test: enable repository set (positive)

        @Feature: Subscriptions/Repository Sets

        @Assert: you are able to enable and synchronize
        repository contained in a manifest
        """
        self._upload_manifest(self.manifest, self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
        RepositorySet.enable({
            'basearch': 'x86_64',
            'name': (
                'Red Hat Enterprise Virtualization Agents '
                'for RHEL 6 Workstation (RPMs)'
            ),
            'organization-id': self.org['id'],
            'product': 'Red Hat Enterprise Linux Workstation',
            'releasever': '6Workstation',
        })
        Repository.synchronize({
            'name': (
                'Red Hat Enterprise Virtualization Agents '
                'for RHEL 6 Workstation '
                'RPMs x86_64 6Workstation'
            ),
            'organization-id': self.org['id'],
            'product': 'Red Hat Enterprise Linux Workstation',
        })
コード例 #11
0
 def _upload_manifest(self, manifest, org_id):
     """Uploads a manifest file and import it into an organization"""
     upload_file(manifest, remote_file=manifest)
     Subscription.upload({
         'file': manifest,
         'organization-id': org_id,
     })
コード例 #12
0
    def test_positive_export_rh_product(self):
        """Export a repository from the Red Hat product

        @Feature: Repository - Export

        @Assert: Repository was successfully exported, rpm files are present on
        satellite machine
        """
        # Enable RH repository
        with manifests.clone() as manifest:
            ssh.upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': self.org['id'],
        })
        RepositorySet.enable({
            'basearch': 'x86_64',
            'name': REPOSET['rhva6'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
        })
        repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
        })
        repo_export_dir = (
            '/mnt/{0}/{1}-{2}-{3}/{1}/{4}/content/dist/rhel/server/6/6Server/'
            'x86_64/rhev-agent/3/os'.format(
                self.export_dir,
                self.org['label'],
                PRDS['rhel'].replace(' ', '_'),
                repo['label'],
                ENVIRONMENT,
            ))

        # Update the download policy to 'immediate'
        Repository.update({
            'download-policy': 'immediate',
            'id': repo['id'],
        })

        # Export the repository
        Repository.export({'id': repo['id']})

        # Verify export directory is empty
        result = ssh.command('ls -l {0} | grep .rpm'.format(repo_export_dir))
        self.assertEqual(len(result.stdout), 0)

        # Synchronize the repository
        Repository.synchronize({'id': repo['id']})

        # Export the repository once again
        Repository.export({'id': repo['id']})

        # Verify RPMs were successfully exported
        result = ssh.command('ls -l {0} | grep .rpm'.format(repo_export_dir))
        self.assertEqual(result.return_code, 0)
        self.assertGreaterEqual(len(result.stdout), 1)
コード例 #13
0
ファイル: test_subscription.py プロジェクト: ares/robottelo
    def test_manifest_refresh(self):
        """@Test: upload manifest (positive) and refresh

        @Feature: Subscriptions/Manifest refresh

        @Assert: Manifests can be refreshed

        """
        self._upload_manifest(
            manifests.download_manifest_template(), self.org['id'])
        result = Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False
        )
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Subscription.refresh_manifest({
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Subscription.delete_manifest({
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
コード例 #14
0
def test_positive_delete_manifest_as_another_user(default_sat):
    """Verify that uploaded manifest if visible and deletable
        by a different user than the one who uploaded it

    :id: 4861bcbc-785a-436d-98cf-13cfef7d6907

    :expectedresults: manifest is refreshed

    :customerscenario: true

    :BZ: 1669241

    :CaseImportance: Medium
    """
    org = entities.Organization().create()
    user1_password = gen_string('alphanumeric')
    user1 = entities.User(
        admin=True, password=user1_password, organization=[org], default_organization=org
    ).create()
    user2_password = gen_string('alphanumeric')
    user2 = entities.User(
        admin=True, password=user2_password, organization=[org], default_organization=org
    ).create()
    # use the first admin to upload a manifest
    with manifests.clone() as manifest:
        default_sat.put(manifest, manifest.filename)
    Subscription.with_user(username=user1.login, password=user1_password).upload(
        {'file': manifest.filename, 'organization-id': org.id}
    )
    # try to search and delete the manifest with another admin
    Subscription.with_user(username=user2.login, password=user2_password).delete_manifest(
        {'organization-id': org.id}
    )
    assert len(Subscription.list({'organization-id': org.id})) == 0
コード例 #15
0
ファイル: test_syncplan.py プロジェクト: chbrown13/robottelo
    def test_positive_synchronize_rh_product_future_sync_date(self):
        """Create a sync plan with sync date in a future and sync one RH
        product with it automatically.

        :id: 6ce2f777-f230-4bb8-9822-2cf3580c21aa

        :expectedresults: Product is synchronized successfully.

        :CaseLevel: System
        """
        delay = 10 * 60  # delay for sync date in seconds
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org['id'],
        })
        sync_plan = self._make_sync_plan({
            'enabled':
            'true',
            'organization-id':
            org['id'],
            'sync-date':
            (datetime.utcnow() +
             timedelta(seconds=delay)).strftime("%Y-%m-%d %H:%M:%S"),
        })
        RepositorySet.enable({
            'name': REPOSET['rhva6'],
            'organization-id': org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
            'basearch': 'x86_64',
        })
        product = Product.info({
            'name': PRDS['rhel'],
            'organization-id': org['id'],
        })
        repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'product': product['name'],
            'organization-id': org['id'],
        })
        # Verify product is not synced and doesn't have any content
        self.validate_repo_content(repo, ['errata', 'packages'],
                                   after_sync=False)
        # Associate sync plan with product
        Product.set_sync_plan({
            'id': product['id'],
            'sync-plan-id': sync_plan['id'],
        })
        # Wait half of expected time
        sleep(delay / 2)
        # Verify product has not been synced yet
        self.validate_repo_content(repo, ['errata', 'packages'],
                                   after_sync=False)
        # Wait the rest of expected time
        sleep(delay / 2)
        # Verify product was synced successfully
        self.validate_repo_content(repo, ['errata', 'packages'])
コード例 #16
0
    def test_positive_enable_manifest_reposet(self):
        """enable repository set

        :id: cc0f8f40-5ea6-4fa7-8154-acdc2cb56b45

        :expectedresults: you are able to enable and synchronize repository
            contained in a manifest

        :CaseLevel: Integration

        :CaseImportance: Critical
        """
        self._upload_manifest(self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
        RepositorySet.enable({
            'basearch': 'x86_64',
            'name': REPOSET['rhva6'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
        })
        Repository.synchronize({
            'name': REPOS['rhva6']['name'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
        })
コード例 #17
0
def test_positive_enable_manifest_reposet(function_org, manifest_clone_upload):
    """enable repository set

    :id: cc0f8f40-5ea6-4fa7-8154-acdc2cb56b45

    :expectedresults: you are able to enable and synchronize repository
        contained in a manifest

    :CaseLevel: Integration

    :CaseImportance: Critical
    """
    Subscription.list({'organization-id': function_org.id}, per_page=False)
    RepositorySet.enable(
        {
            'basearch': 'x86_64',
            'name': REPOSET['rhva6'],
            'organization-id': function_org.id,
            'product': PRDS['rhel'],
            'releasever': '6Server',
        }
    )
    Repository.synchronize(
        {
            'name': REPOS['rhva6']['name'],
            'organization-id': function_org.id,
            'product': PRDS['rhel'],
        }
    )
コード例 #18
0
    def test_positive_add_subscription_by_id(self):
        """Test that subscription can be added to activation key

        :id: b884be1c-b35d-440a-9a9d-c854c83e10a7

        :Steps:

            1. Create Activation key
            2. Upload manifest and add subscription
            3. Associate the activation key to subscription

        :expectedresults: Subscription successfully added to activation key

        :CaseLevel: Integration
        """
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        org_id = make_org()['id']
        ackey_id = self._make_activation_key()['id']
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org_id,
        })
        subs_id = Subscription.list(
            {'organization-id': org_id},
            per_page=False
        )
        result = ActivationKey.add_subscription({
            u'id': ackey_id,
            u'subscription-id': subs_id[0]['id'],
        })
        self.assertIn('Subscription added to activation key', result)
コード例 #19
0
    def test_positive_copy_subscription(self):
        """Copy Activation key and verify contents

        @Feature: Activation key copy

        @Steps:

        1. Create parent key and add content
        2. Copy Activation key by passing id of parent
        3. Verify content was successfully copied

        @Assert: Activation key is successfully copied
        """
        # Begin test setup
        parent_ak = self._make_activation_key()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({"file": manifest.filename, "organization-id": self.org["id"]})
        subscription_result = Subscription.list({"organization-id": self.org["id"]}, per_page=False)
        ActivationKey.add_subscription({u"id": parent_ak["id"], u"subscription-id": subscription_result[0]["id"]})
        # End test setup
        new_name = gen_string("utf8")
        result = ActivationKey.copy({u"id": parent_ak["id"], u"new-name": new_name, u"organization-id": self.org["id"]})
        self.assertEqual(result[0], u"Activation key copied")
        result = ActivationKey.subscriptions({u"name": new_name, u"organization-id": self.org["id"]})
        # Verify that the subscription copied over
        self.assertIn(subscription_result[0]["name"], result[3])  # subscription name  # subscription list
コード例 #20
0
    def test_manifest_upload(self):
        """
        @test: upload manifest (positive)
        @feature: Subscriptions/Manifest Upload
        @assert: Manifest are uploaded properly
        """

        mdetails = manifest.fetch_manifest()
        try:
            upload_file(mdetails['path'], remote_file=mdetails['path'])
            result = Subscription.upload(
                {'file': mdetails['path'],
                 'organization-id': self.org['id']})
            self.assertEqual(result.return_code, 0,
                             "Failed to upload manifest")
            self.assertEqual(
                len(result.stderr), 0,
                "There should not be an exception while uploading manifest.")

            result = Subscription.list({'organization-id': self.org['id']},
                                       per_page=False)
            self.assertEqual(result.return_code, 0,
                             "Failed to list manifests in this org.")
            self.assertEqual(
                len(result.stdout), 8,
                "There should not be an exception while listing the manifest.")
        finally:
            manifest.delete_distributor(ds_uuid=mdetails['uuid'])
コード例 #21
0
    def test_manifest_upload(self):
        """
        @test: upload manifest (positive)
        @feature: Subscriptions/Manifest Upload
        @assert: Manifest are uploaded properly
        """

        mdetails = manifest.fetch_manifest()
        try:
            upload_file(mdetails['path'], remote_file=mdetails['path'])
            result = Subscription.upload({
                'file': mdetails['path'],
                'organization-id': self.org['id']
            })
            self.assertEqual(result.return_code, 0,
                             "Failed to upload manifest")
            self.assertEqual(
                len(result.stderr), 0,
                "There should not be an exception while uploading manifest.")

            result = Subscription.list({'organization-id': self.org['id']},
                                       per_page=False)
            self.assertEqual(result.return_code, 0,
                             "Failed to list manifests in this org.")
            self.assertEqual(
                len(result.stdout), 8,
                "There should not be an exception while listing the manifest.")
        finally:
            manifest.delete_distributor(ds_uuid=mdetails['uuid'])
コード例 #22
0
    def test_positive_enable_by_label(self):
        """Enable repo from reposet by org label, reposet and product
        names

        @id: 5230c1cd-fed7-40ac-8445-bac4f9c5ee68

        @Assert: Repository was enabled
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
コード例 #23
0
    def test_add_subscription(self):
        """@Test: Test that subscription can be added to activation key

        @Feature: Activation key - Host

        @Steps:

        1. Create Activation key
        2. Upload manifest and add subscription
        3. Associate the activation key to subscription

        @Assert: Subscription successfully added to activation key

        """
        manifest = manifests.clone()
        upload_file(manifest, remote_file=manifest)
        org_id = make_org()['id']
        ackey_id = self._make_activation_key()['id']
        Subscription.upload({
            'file': manifest,
            'organization-id': org_id,
        })
        subs_id = Subscription.list(
            {'organization-id': org_id},
            per_page=False)
        result = ActivationKey.add_subscription({
            u'id': ackey_id,
            u'subscription-id': subs_id[0]['id'],
        })
        self.assertIn('Subscription added to activation key', result)
コード例 #24
0
    def test_positive_enable_by_name(self):
        """Enable repo from reposet by names of reposet, org and product

        @Feature: Repository-set

        @Assert: Repository was enabled
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization': org['name'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name': REPOSET['rhva6'],
            u'organization': org['name'],
            u'product': PRDS['rhel'],
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
コード例 #25
0
    def test_positive_enable_manifest_reposet(self):
        """enable repository set

        :id: cc0f8f40-5ea6-4fa7-8154-acdc2cb56b45

        :expectedresults: you are able to enable and synchronize repository
            contained in a manifest

        :CaseLevel: Integration
        """
        self._upload_manifest(self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
        RepositorySet.enable({
            'basearch': 'x86_64',
            'name': REPOSET['rhva6'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
        })
        Repository.synchronize({
            'name': REPOS['rhva6']['name'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
        })
コード例 #26
0
    def test_repositoryset_enable_by_label(self):
        """@Test: Enable repo from reposet by org label, reposet and product
        names

        @Feature: Repository-set

        @Assert: Repository was enabled

        """
        org = make_org()
        manifest = manifests.clone()
        upload_file(manifest, remote_file=manifest)
        Subscription.upload({
            u'file': manifest,
            u'organization-id': org['id'],
        })
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'name': REPOSET['rhva6'],
            u'organization-label': org['label'],
            u'product': PRDS['rhel'],
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'true')
コード例 #27
0
ファイル: test_subscription.py プロジェクト: ares/robottelo
    def test_manifest_delete(self):
        """@Test: Delete uploaded manifest (positive)

        @Feature: Subscriptions/Manifest Delete

        @Assert: Manifest are deleted properly

        @BZ: 1207501

        """
        self._upload_manifest(self.manifest, self.org['id'])
        result = Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False
        )
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Subscription.delete_manifest({
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False
        )
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stdout), 0)
コード例 #28
0
    def test_positive_enable_manifest_reposet(self):
        """enable repository set

        @Feature: Subscriptions/Repository Sets

        @Assert: you are able to enable and synchronize
        repository contained in a manifest
        """
        self._upload_manifest(self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
        RepositorySet.enable({
            'basearch': 'x86_64',
            'name': REPOSET['rhva6'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
        })
        Repository.synchronize({
            'name': REPOS['rhva6']['name'],
            'organization-id': self.org['id'],
            'product': PRDS['rhel'],
        })
コード例 #29
0
ファイル: test_subscription.py プロジェクト: ares/robottelo
    def test_manifest_history(self):
        """@Test: upload manifest (positive) and check history

        @Feature: Subscriptions/Manifest History

        @Assert: Manifest history is shown properly

        """
        self._upload_manifest(self.manifest, self.org['id'])
        result = Subscription.list(
            {'organization-id': self.org['id']},
            per_page=None
        )
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        result = Subscription.manifest_history({
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)
        self.assertIn(
            '{0} file imported successfully.'.format(self.org['name']),
            ''.join(result.stdout)
        )
コード例 #30
0
    def test_positive_synchronize_rh_product_current_sync_date(self):
        """Create a sync plan with current datetime as a sync date, add a
        RH product and verify the product gets synchronized on the next sync
        occurrence

        @Assert: Product is synchronized successfully.

        @Feature: SyncPlan

        @BZ: 1279539
        """
        interval = 60 * 60  # 'hourly' sync interval in seconds
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org['id'],
        })
        sync_plan = self._make_sync_plan({
            'enabled':
            'true',
            'interval':
            'hourly',
            'organization-id':
            org['id'],
            'sync-date':
            datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"),
        })
        RepositorySet.enable({
            'name': REPOSET['rhva6'],
            'organization-id': org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
            'basearch': 'x86_64',
        })
        product = Product.info({
            'name': PRDS['rhel'],
            'organization-id': org['id'],
        })
        repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'product': product['name'],
            'organization-id': org['id'],
        })
        # Associate sync plan with product
        Product.set_sync_plan({
            'id': product['id'],
            'sync-plan-id': sync_plan['id'],
        })
        # Wait half of expected time
        sleep(interval / 2)
        # Verify product has not been synced yet
        self.validate_repo_content(repo, ['errata', 'packages'],
                                   after_sync=False)
        # Wait the rest of expected time
        sleep(interval / 2)
        # Verify product was synced successfully
        self.validate_repo_content(repo, ['errata', 'packages'])
コード例 #31
0
ファイル: test_syncplan.py プロジェクト: kbidarkar/robottelo
    def test_positive_synchronize_rh_product_past_sync_date(self):
        """Create a sync plan with past datetime as a sync date, add a
        RH product and verify the product gets synchronized on the next sync
        occurrence

        :id: 47280ef4-3936-4dbc-8ed0-1076aa8d40df

        :expectedresults: Product is synchronized successfully.

        :BZ: 1279539

        :CaseLevel: System
        """
        interval = 60 * 60  # 'hourly' sync interval in seconds
        delay = 80
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org['id'],
        })
        sync_plan = self._make_sync_plan({
            'enabled': 'true',
            'interval': 'hourly',
            'organization-id': org['id'],
            'sync-date': (
              datetime.utcnow() - timedelta(interval - delay/2)
            ).strftime("%Y-%m-%d %H:%M:%S"),
        })
        RepositorySet.enable({
            'name': REPOSET['rhva6'],
            'organization-id': org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
            'basearch': 'x86_64',
        })
        product = Product.info({
            'name': PRDS['rhel'],
            'organization-id': org['id'],
        })
        repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'product': product['name'],
            'organization-id': org['id'],
        })
        # Associate sync plan with product
        Product.set_sync_plan({
            'id': product['id'],
            'sync-plan-id': sync_plan['id'],
        })
        # Verify product has not been synced yet
        sleep(delay/4)
        self.validate_repo_content(
            repo, ['errata', 'packages'], after_sync=False)
        # Wait the rest of expected time
        sleep(delay)
        # Verify product was synced successfully
        self.validate_repo_content(repo, ['errata', 'packages'])
コード例 #32
0
def manifest_org(org):
    """Upload a manifest to the organization."""
    with manifests.clone() as manifest:
        upload_file(manifest.content, manifest.filename)
    Subscription.upload({
        'file': manifest.filename,
        'organization-id': org['id']
    })
    return org
コード例 #33
0
def manifest_org(org, target_sat):
    """Upload a manifest to the organization."""
    with manifests.clone() as manifest:
        target_sat.put(manifest, manifest.filename)
    Subscription.upload({
        'file': manifest.filename,
        'organization-id': org['id']
    })
    return org
コード例 #34
0
ファイル: test_syncplan.py プロジェクト: elyezer/robottelo
    def test_positive_synchronize_rh_product_future_sync_date(self):
        """Create a sync plan with sync date in a future and sync one RH
        product with it automatically.

        :id: 6ce2f777-f230-4bb8-9822-2cf3580c21aa

        :expectedresults: Product is synchronized successfully.

        :CaseLevel: System
        """
        delay = 10 * 60  # delay for sync date in seconds
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org['id'],
        })
        sync_plan = self._make_sync_plan({
            'enabled': 'true',
            'organization-id': org['id'],
            'sync-date': (datetime.utcnow() + timedelta(seconds=delay))
                        .strftime("%Y-%m-%d %H:%M:%S"),
        })
        RepositorySet.enable({
            'name': REPOSET['rhva6'],
            'organization-id': org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
            'basearch': 'x86_64',
        })
        product = Product.info({
            'name': PRDS['rhel'],
            'organization-id': org['id'],
        })
        repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'product': product['name'],
            'organization-id': org['id'],
        })
        # Verify product is not synced and doesn't have any content
        self.validate_repo_content(
            repo, ['errata', 'packages'], after_sync=False)
        # Associate sync plan with product
        Product.set_sync_plan({
            'id': product['id'],
            'sync-plan-id': sync_plan['id'],
        })
        # Wait half of expected time
        sleep(delay/2)
        # Verify product has not been synced yet
        self.validate_repo_content(
            repo, ['errata', 'packages'], after_sync=False)
        # Wait the rest of expected time
        sleep(delay/2)
        # Verify product was synced successfully
        self.validate_repo_content(repo, ['errata', 'packages'])
コード例 #35
0
ファイル: test_syncplan.py プロジェクト: anarang/robottelo
    def test_positive_synchronize_rh_product_current_sync_date(self):
        """Create a sync plan with current datetime as a sync date, add a
        RH product and verify the product gets synchronized on the next sync
        occurrence

        @Assert: Product is synchronized successfully.

        @Feature: SyncPlan

        @BZ: 1279539
        """
        interval = 60 * 60  # 'hourly' sync interval in seconds
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': org['id'],
        })
        sync_plan = self._make_sync_plan({
            'enabled': 'true',
            'interval': 'hourly',
            'organization-id': org['id'],
            'sync-date': datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"),
        })
        RepositorySet.enable({
            'name': REPOSET['rhva6'],
            'organization-id': org['id'],
            'product': PRDS['rhel'],
            'releasever': '6Server',
            'basearch': 'x86_64',
        })
        product = Product.info({
            'name': PRDS['rhel'],
            'organization-id': org['id'],
        })
        repo = Repository.info({
            'name': REPOS['rhva6']['name'],
            'product': product['name'],
            'organization-id': org['id'],
        })
        # Associate sync plan with product
        Product.set_sync_plan({
            'id': product['id'],
            'sync-plan-id': sync_plan['id'],
        })
        # Wait half of expected time
        sleep(interval / 2)
        # Verify product has not been synced yet
        self.validate_repo_content(
            repo, ['errata', 'packages'], after_sync=False)
        # Wait the rest of expected time
        sleep(interval / 2)
        # Verify product was synced successfully
        self.validate_repo_content(repo, ['errata', 'packages'])
コード例 #36
0
    def test_positive_manifest_upload(self):
        """upload manifest

        :id: e5a0e4f8-fed9-4896-87a0-ac33f6baa227

        :expectedresults: Manifest are uploaded properly

        :CaseImportance: Critical
        """
        self._upload_manifest(self.org['id'])
        Subscription.list({'organization-id': self.org['id']}, per_page=False)
コード例 #37
0
def test_positive_manifest_upload(function_org, manifest_clone_upload):
    """upload manifest

    :id: e5a0e4f8-fed9-4896-87a0-ac33f6baa227

    :expectedresults: Manifest are uploaded properly

    :CaseImportance: Critical
    """

    Subscription.list({'organization-id': function_org.id}, per_page=False)
コード例 #38
0
    def test_enable_manifest_repository_set(self):
        """@Test: enable repository set (positive)

        @Feature: Subscriptions/Repository Sets

        @Assert: you are able to enable and synchronize
        repository contained in a manifest

        """

        upload_file(self.manifest, remote_file=self.manifest)
        result = Subscription.upload({
            'file': self.manifest,
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0,
                         "Failed to upload manifest")
        self.assertEqual(
            len(result.stderr), 0,
            "There should not be an exception while uploading manifest.")

        result = Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False)
        self.assertEqual(
            len(result.stderr), 0,
            "There should not be an exception while listing the manifest.")

        result = RepositorySet.enable({
            'name': (
                'Red Hat Enterprise Virtualization Agents '
                'for RHEL 6 Workstation (RPMs)'
            ),
            'organization-id': self.org['id'],
            'product': 'Red Hat Enterprise Linux Workstation',
            'releasever': '6Workstation',
            'basearch': 'x86_64',
        })
        self.assertEqual(result.return_code, 0, "Repo was not enabled")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        result = Repository.synchronize({
            'name': (
                'Red Hat Enterprise Virtualization Agents '
                'for RHEL 6 Workstation '
                'RPMs x86_64 6Workstation'
            ),
            'organization-id': self.org['id'],
            'product': 'Red Hat Enterprise Linux Workstation',
        })

        self.assertEqual(result.return_code, 0, "Repo was not synchronized")
        self.assertEqual(len(result.stderr), 0, "No error was expected")
コード例 #39
0
    def test_positive_manifest_upload(self):
        """upload manifest

        @id: e5a0e4f8-fed9-4896-87a0-ac33f6baa227

        @Assert: Manifest are uploaded properly
        """
        self._upload_manifest(self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
コード例 #40
0
    def test_enable_manifest_repository_set(self):
        """@Test: enable repository set (positive)

        @Feature: Subscriptions/Repository Sets

        @Assert: you are able to enable and synchronize
        repository contained in a manifest

        """

        upload_file(self.manifest, remote_file=self.manifest)
        result = Subscription.upload({
            'file': self.manifest,
            'organization-id': self.org['id'],
        })
        self.assertEqual(result.return_code, 0,
                         "Failed to upload manifest")
        self.assertEqual(
            len(result.stderr), 0,
            "There should not be an exception while uploading manifest.")

        result = Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False)
        self.assertEqual(
            len(result.stderr), 0,
            "There should not be an exception while listing the manifest.")

        result = RepositorySet.enable({
            'name': (
                'Red Hat Enterprise Virtualization Agents '
                'for RHEL 6 Workstation (RPMs)'
            ),
            'organization-id': self.org['id'],
            'product': 'Red Hat Enterprise Linux Workstation',
            'releasever': '6Workstation',
            'basearch': 'x86_64',
        })
        self.assertEqual(result.return_code, 0, "Repo was not enabled")
        self.assertEqual(len(result.stderr), 0, "No error was expected")

        result = Repository.synchronize({
            'name': (
                'Red Hat Enterprise Virtualization Agents '
                'for RHEL 6 Workstation '
                'RPMs x86_64 6Workstation'
            ),
            'organization-id': self.org['id'],
            'product': 'Red Hat Enterprise Linux Workstation',
        })

        self.assertEqual(result.return_code, 0, "Repo was not synchronized")
        self.assertEqual(len(result.stderr), 0, "No error was expected")
コード例 #41
0
def test_positive_manifest_history(function_org, manifest_clone_upload):
    """upload manifest and check history

    :id: 000ab0a0-ec1b-497a-84ff-3969a965b52c

    :expectedresults: Manifest history is shown properly

    :CaseImportance: Medium
    """
    Subscription.list({'organization-id': function_org.id}, per_page=None)
    history = Subscription.manifest_history({'organization-id': function_org.id})
    assert f'{function_org.name} file imported successfully.' in ''.join(history)
コード例 #42
0
    def test_positive_manifest_upload(self):
        """upload manifest

        @Feature: Subscriptions/Manifest Upload

        @Assert: Manifest are uploaded properly
        """
        self._upload_manifest(self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
コード例 #43
0
    def test_positive_manifest_upload(self):
        """upload manifest

        @Feature: Subscriptions/Manifest Upload

        @Assert: Manifest are uploaded properly
        """
        self._upload_manifest(self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
コード例 #44
0
    def test_positive_disable_by_id(self):
        """Disable repo from reposet by IDs of reposet, org and product

        :id: 0d6102ba-3fb9-4eb8-972e-d537e252a8e6

        :expectedresults: Repository was disabled

        :CaseImportance: Critical
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        product_id = Product.info({
            u'name': PRDS['rhel'],
            u'organization-id': org['id'],
        })['id']
        reposet_id = RepositorySet.info({
            u'name': REPOSET['rhva6'],
            u'organization-id': org['id'],
            u'product-id': product_id,
        })['id']
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'id': reposet_id,
            u'organization-id': org['id'],
            u'product-id': product_id,
            u'releasever': '6Server',
        })
        RepositorySet.disable({
            u'basearch': 'x86_64',
            u'id': reposet_id,
            u'organization-id': org['id'],
            u'product-id': product_id,
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'id':
            reposet_id,
            u'organization-id':
            org['id'],
            u'product-id':
            product_id,
        })
        enabled = [
            repo['enabled'] for repo in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'false')
コード例 #45
0
    def _upload_manifest(self, org_id, manifest=None):
        """Uploads a manifest into an organization.

        A cloned manifest will be used if ``manifest`` is None.
        """
        if manifest is None:
            manifest = manifests.clone()
        upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            'organization-id': org_id,
        })
        manifest.content.close()
コード例 #46
0
    def _upload_manifest(self, org_id, manifest=None):
        """Uploads a manifest into an organization.

        A cloned manifest will be used if ``manifest`` is None.
        """
        if manifest is None:
            manifest = manifests.clone()
        upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            'organization-id': org_id,
        })
        manifest.content.close()
コード例 #47
0
    def test_positive_manifest_history(self):
        """upload manifest and check history

        :id: 000ab0a0-ec1b-497a-84ff-3969a965b52c

        :expectedresults: Manifest history is shown properly

        :CaseImportance: Medium
        """
        self._upload_manifest(self.org['id'])
        Subscription.list({'organization-id': self.org['id']}, per_page=None)
        history = Subscription.manifest_history({'organization-id': self.org['id']})
        self.assertIn('{0} file imported successfully.'.format(self.org['name']), ''.join(history))
コード例 #48
0
    def test_positive_disable_by_id(self):
        """Disable repo from reposet by IDs of reposet, org and product

        :id: 0d6102ba-3fb9-4eb8-972e-d537e252a8e6

        :expectedresults: Repository was disabled

        :CaseImportance: Critical
        """
        org = make_org()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            u'file': manifest.filename,
            u'organization-id': org['id'],
        })
        product_id = Product.info({
            u'name': PRDS['rhel'],
            u'organization-id': org['id'],
        })['id']
        reposet_id = RepositorySet.info({
            u'name': REPOSET['rhva6'],
            u'organization-id': org['id'],
            u'product-id': product_id,
        })['id']
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'id': reposet_id,
            u'organization-id': org['id'],
            u'product-id': product_id,
            u'releasever': '6Server',
        })
        RepositorySet.disable({
            u'basearch': 'x86_64',
            u'id': reposet_id,
            u'organization-id': org['id'],
            u'product-id': product_id,
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'id': reposet_id,
            u'organization-id': org['id'],
            u'product-id': product_id,
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'false')
コード例 #49
0
    def test_positive_delete_subscription(self):
        """Check if deleting a subscription removes it from Activation key

        :id: bbbe4641-bfb0-48d6-acfc-de4294b18c15

        :expectedresults: Deleting subscription removes it from the Activation
            key

        :CaseLevel: Integration
        """
        new_ak = self._make_activation_key()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': self.org['id'],
        })
        subscription_result = Subscription.list(
            {
                'organization-id': self.org['id'],
                'order': 'id desc'
            },
            per_page=False)
        result = ActivationKey.add_subscription({
            u'id':
            new_ak['id'],
            u'subscription-id':
            subscription_result[-1]['id'],
        })
        self.assertIn('Subscription added to activation key', result)
        ak_subs_info = ActivationKey.subscriptions({
            u'id':
            new_ak['id'],
            u'organization-id':
            self.org['id'],
        })
        self.assertEqual(len(ak_subs_info), 6)
        result = ActivationKey.remove_subscription({
            u'id':
            new_ak['id'],
            u'subscription-id':
            subscription_result[-1]['id'],
        })
        self.assertIn('Subscription removed from activation key', result)
        ak_subs_info = ActivationKey.subscriptions({
            u'id':
            new_ak['id'],
            u'organization-id':
            self.org['id'],
        })
        self.assertEqual(len(ak_subs_info), 4)
コード例 #50
0
    def test_positive_manifest_upload(self):
        """upload manifest

        :id: e5a0e4f8-fed9-4896-87a0-ac33f6baa227

        :expectedresults: Manifest are uploaded properly

        :CaseImportance: Critical
        """
        self._upload_manifest(self.org['id'])
        Subscription.list(
            {'organization-id': self.org['id']},
            per_page=False,
        )
コード例 #51
0
    def test_positive_copy_subscription(self):
        """Copy Activation key and verify contents

        :id: f4ee8096-4120-4d06-8c9a-57ac1eaa8f68

        :Steps:

            1. Create parent key and add content
            2. Copy Activation key by passing id of parent
            3. Verify content was successfully copied

        :expectedresults: Activation key is successfully copied

        :CaseLevel: Integration
        """
        # Begin test setup
        parent_ak = self._make_activation_key()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': self.org['id'],
        })
        subscription_result = Subscription.list(
            {'organization-id': self.org['id']}, per_page=False)
        ActivationKey.add_subscription({
            u'id':
            parent_ak['id'],
            u'subscription-id':
            subscription_result[0]['id'],
        })
        # End test setup
        new_name = gen_string('utf8')
        result = ActivationKey.copy({
            u'id': parent_ak['id'],
            u'new-name': new_name,
            u'organization-id': self.org['id'],
        })
        self.assertEqual(result[0], u'Activation key copied')
        result = ActivationKey.subscriptions({
            u'name':
            new_name,
            u'organization-id':
            self.org['id'],
        })
        # Verify that the subscription copied over
        self.assertIn(
            subscription_result[0]['name'],  # subscription name
            result[3]  # subscription list
        )
コード例 #52
0
    def test_repositoryset_disable_by_id(self):
        """@Test: Disable repo from reposet by IDs of reposet, org and product

        @Feature: Repository-set

        @Assert: Repository was disabled

        """
        org = make_org()
        manifest = manifests.clone()
        upload_file(manifest, remote_file=manifest)
        Subscription.upload({
            u'file': manifest,
            u'organization-id': org['id'],
        })
        product_id = Product.info({
            u'name': PRDS['rhel'],
            u'organization-id': org['id'],
        })['id']
        reposet_id = RepositorySet.info({
            u'name': REPOSET['rhva6'],
            u'organization-id': org['id'],
            u'product-id': product_id,
        })['id']
        RepositorySet.enable({
            u'basearch': 'x86_64',
            u'id': reposet_id,
            u'organization-id': org['id'],
            u'product-id': product_id,
            u'releasever': '6Server',
        })
        RepositorySet.disable({
            u'basearch': 'x86_64',
            u'id': reposet_id,
            u'organization-id': org['id'],
            u'product-id': product_id,
            u'releasever': '6Server',
        })
        result = RepositorySet.available_repositories({
            u'id': reposet_id,
            u'organization-id': org['id'],
            u'product-id': product_id,
        })
        enabled = [
            repo['enabled']
            for repo
            in result
            if repo['arch'] == 'x86_64' and repo['release'] == '6Server'
        ][0]
        self.assertEqual(enabled, 'false')
コード例 #53
0
    def test_positive_copy_subscription(self):
        """@Test: Copy Activation key and verify contents

        @Feature: Activation key copy

        @Steps:

        1. Create parent key and add content
        2. Copy Activation key by passing id of parent
        3. Verify content was sucessfully copied

        @Assert: Activation key is sucessfully copied

        """
        # Begin test setup
        org_id = make_org()['id']
        parent_id = make_activation_key({
            u'organization-id': org_id
        })['id']
        manifest = manifests.clone()
        upload_file(manifest, remote_file=manifest)
        Subscription.upload({
            'file': manifest,
            'organization-id': org_id,
        })
        subscription_result = Subscription.list(
            {'organization-id': org_id}, per_page=False)
        ActivationKey.add_subscription({
            u'id': parent_id,
            u'subscription-id': subscription_result[0]['id'],
        })
        # End test setup
        new_name = gen_string('utf8')
        result = ActivationKey.copy({
            u'id': parent_id,
            u'new-name': new_name,
            u'organization-id': org_id,
        })
        self.assertEqual(result[0], u'Activation key copied')
        result = ActivationKey.subscriptions({
            u'name': new_name,
            u'organization-id': org_id,
        })
        # Verify that the subscription copied over
        self.assertIn(
            subscription_result[0]['name'],  # subscription name
            result[3]  # subscription list
        )
コード例 #54
0
def test_positive_logging_from_candlepin(module_org, default_sat):
    """Check logging after manifest upload.

    :id: 8c06e501-52d7-4baf-903e-7de9caffb066

    :expectedresults: line of logs with POST has request ID

    :CaseImportance: Medium
    """

    POST_line_found = False
    source_log = '/var/log/candlepin/candlepin.log'
    test_logfile = '/var/tmp/logfile_from_candlepin'
    # regex for a version 4 UUID (8-4-4-12 format)
    regex = r"\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b"
    # get the number of lines in the source log before the test
    line_count_start = line_count(source_log, default_sat)
    # command for this test
    with manifests.clone() as manifest:
        with NamedTemporaryFile(dir=robottelo_tmp_dir) as content_file:
            content_file.write(manifest.content.read())
            content_file.seek(0)
            default_sat.put(local_path=content_file.name,
                            remote_path=manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': module_org.id
        })
    # get the number of lines in the source log after the test
    line_count_end = line_count(source_log, default_sat)
    # get the log lines of interest, put them in test_logfile
    cut_lines(line_count_start, line_count_end, source_log, test_logfile,
              default_sat)
    # use same location on remote and local for log file extract
    default_sat.get(remote_path=test_logfile)
    # search the log file extract for the line with POST to candlepin API
    with open(test_logfile) as logfile:
        for line in logfile:
            if re.search(r'verb=POST, uri=/candlepin/owners/{0}',
                         line.format(module_org.name)):
                logger.info('Found the line with POST to candlepin API')
                POST_line_found = True
                # Confirm the request ID was logged in the line with POST
                match = re.search(regex, line)
                assert match, "Request ID not found"
                logger.info("Request ID found for logging from candlepin")
                break
    assert POST_line_found, "The POST command to candlepin was not found in logs."
コード例 #55
0
ファイル: products.py プロジェクト: pondrejk/robottelo
 def setup_activation_key(org_id, content_view_id, lce_id, subscription_names=None):
     # type: (int, int, int, Optional[List[str]], Optional[str]) -> Dict
     """Create activation and associate content-view, lifecycle environment and subscriptions"""
     if subscription_names is None:
         subscription_names = []
     activation_key = make_activation_key({
         'organization-id': org_id,
         'lifecycle-environment-id': lce_id,
         'content-view-id': content_view_id,
     })
     # Add subscriptions to activation-key
     # Get organization subscriptions
     subscriptions = Subscription.list({'organization-id': org_id}, per_page=False)
     added_subscription_names = []
     for subscription in subscriptions:
         if (subscription['name'] in subscription_names
                 and subscription['name'] not in added_subscription_names):
             ActivationKey.add_subscription({
                 'id': activation_key['id'],
                 'subscription-id': subscription['id'],
                 'quantity': 1,
             })
             added_subscription_names.append(subscription['name'])
             if len(added_subscription_names) == len(subscription_names):
                 break
     missing_subscription_names = set(subscription_names).difference(
         set(added_subscription_names))
     if missing_subscription_names:
         raise ValueError('Missing subscriptions: {0}'.format(missing_subscription_names))
     return activation_key
コード例 #56
0
def setup_content(request):
    """Pytest fixture for setting up an organization, manifest, content-view,
    lifecycle environment, and activation key with subscriptions"""
    org = make_org()
    with manifests.clone() as manifest:
        upload_file(manifest.content, manifest.filename)
    new_product = make_product({'organization-id': org['id']})
    new_repo = make_repository({'product-id': new_product['id']})
    Repository.synchronize({'id': new_repo['id']})
    content_view = make_content_view({'organization-id': org['id']})
    ContentView.add_repository(
        {'id': content_view['id'], 'organization-id': org['id'], 'repository-id': new_repo['id']}
    )
    ContentView.publish({'id': content_view['id']})
    env = make_lifecycle_environment({'organization-id': org['id']})
    cvv = ContentView.info({'id': content_view['id']})['versions'][0]
    ContentView.version_promote({'id': cvv['id'], 'to-lifecycle-environment-id': env['id']})
    new_ak = make_activation_key(
        {
            'lifecycle-environment-id': env['id'],
            'content-view': content_view['name'],
            'organization-id': org['id'],
            'auto-attach': False,
        }
    )
    subs_id = Subscription.list({'organization-id': org['id']}, per_page=False)
    ActivationKey.add_subscription({'id': new_ak['id'], 'subscription-id': subs_id[0]['id']})
    request.cls.setup_org = org
    request.cls.setup_new_ak = new_ak
    request.cls.setup_subs_id = subs_id
    request.cls.setup_env = env
    request.cls.setup_content_view = content_view
コード例 #57
0
ファイル: products.py プロジェクト: vikask18/robottelo
 def organization_has_manifest(organization_id):
     """Check if an organization has a manifest, an organization has manifest if one of it's
     subscriptions have the account defined.
     """
     subscriptions = Subscription.list({'organization-id': organization_id},
                                       per_page=False)
     return any(bool(sub['account']) for sub in subscriptions)
コード例 #58
0
    def test_positive_deploy_configure_by_id(self, form_data, virtwho_config):
        """ Verify " hammer virt-who-config deploy"

        :id: 19ffe76e-7e3d-48c7-b846-10a83afe0f3e

        :expectedresults: Config can be created and deployed

        :CaseLevel: Integration

        :CaseImportance: High
        """
        assert virtwho_config['status'] == 'No Report Yet'
        command = get_configure_command(virtwho_config['id'])
        hypervisor_name, guest_name = deploy_configure_by_command(command, debug=True)
        virt_who_instance = VirtWhoConfig.info({'id': virtwho_config['id']})[
            'general-information'
        ]['status']
        assert virt_who_instance == 'OK'
        hosts = [
            (hypervisor_name, f'product_id={settings.virtwho.sku_vdc_physical} and type=NORMAL'),
            (guest_name, f'product_id={settings.virtwho.sku_vdc_physical} and type=STACK_DERIVED'),
        ]
        for hostname, sku in hosts:
            host = Host.list({'search': hostname})[0]
            subscriptions = Subscription.list({'organization': DEFAULT_ORG, 'search': sku})
            vdc_id = subscriptions[0]['id']
            if 'type=STACK_DERIVED' in sku:
                for item in subscriptions:
                    if hypervisor_name.lower() in item['type']:
                        vdc_id = item['id']
                        break
            result = Host.subscription_attach({'host-id': host['id'], 'subscription-id': vdc_id})
            assert 'attached to the host successfully' in '\n'.join(result)
        VirtWhoConfig.delete({'name': virtwho_config['name']})
        assert not VirtWhoConfig.exists(search=('name', form_data['name']))
コード例 #59
0
    def test_positive_copy_subscription(self):
        """Copy Activation key and verify contents

        :id: f4ee8096-4120-4d06-8c9a-57ac1eaa8f68

        :Steps:

            1. Create parent key and add content
            2. Copy Activation key by passing id of parent
            3. Verify content was successfully copied

        :expectedresults: Activation key is successfully copied

        :CaseLevel: Integration
        """
        # Begin test setup
        parent_ak = self._make_activation_key()
        with manifests.clone() as manifest:
            upload_file(manifest.content, manifest.filename)
        Subscription.upload({
            'file': manifest.filename,
            'organization-id': self.org['id'],
        })
        subscription_result = Subscription.list(
            {'organization-id': self.org['id']}, per_page=False)
        ActivationKey.add_subscription({
            u'id': parent_ak['id'],
            u'subscription-id': subscription_result[0]['id'],
        })
        # End test setup
        new_name = gen_string('utf8')
        result = ActivationKey.copy({
            u'id': parent_ak['id'],
            u'new-name': new_name,
            u'organization-id': self.org['id'],
        })
        self.assertEqual(result[0], u'Activation key copied')
        result = ActivationKey.subscriptions({
            u'name': new_name,
            u'organization-id': self.org['id'],
        })
        # Verify that the subscription copied over
        self.assertIn(
            subscription_result[0]['name'],  # subscription name
            result[3]  # subscription list
        )