Example #1
0
    def test_cv_postupgrade_scenario(self, request, dependent_scenario_name):
        """After upgrade, the existing content-view(created before upgrade) should be updated.

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

        :steps:
          1. Check yum, puppet and file repository which was added in CV before upgrade.
          2. Check the content view which was was created before upgrade.
          3. Remove yum repository from existing CV.
          4. Create new yum repository in existing CV.
          5. Remove puppet module which was added to content-view before upgrade.
          6. Add another puppet module to content-view
          7. Publish content-view

        :expectedresults: After upgrade,
          1. All the repositories should be intact.
          2. Content view created before upgrade should be intact.
          3. The new repository should be added/updated to the CV.
          4. Puppet module should be added/updated to the CV.

        """
        pre_test_name = dependent_scenario_name
        puppet_module = {'name': 'versioned', 'version': '3.3.3'}
        org = entities.Organization().search(
            query={'search': f'name="{pre_test_name}_org"'})[0]
        request.addfinalizer(org.delete)
        product = entities.Product(organization=org.id).search(
            query={'search': f'name="{pre_test_name}_prod"'})[0]
        request.addfinalizer(product.delete)
        cv = entities.ContentView(organization=org.id).search(
            query={'search': f'name="{pre_test_name}_cv"'})[0]
        yum_repo = entities.Repository(organization=org.id).search(
            query={'search': f'name="{pre_test_name}_yum_repo"'})[0]
        request.addfinalizer(yum_repo.delete)
        file_repo = entities.Repository(organization=org.id).search(
            query={'search': f'name="{pre_test_name}_file_repo"'})[0]
        request.addfinalizer(file_repo.delete)
        puppet_repo = entities.Repository(organization=org.id).search(
            query={'search': f'name="{pre_test_name}_puppet_repo"'})[0]
        request.addfinalizer(puppet_repo.delete)
        request.addfinalizer(cv.delete)
        puppet_module_list = PuppetModule.list({
            'search':
            'name={name} and version={version}'.format(**puppet_module)
        })[0]
        cv.repository = []
        cv.update(['repository'])
        assert len(cv.read_json()['repositories']) == 0

        yum_repository2 = entities.Repository(
            product=product,
            name=f'{pre_test_name}_yum_repos2',
            url=FAKE_2_YUM_REPO).create()
        yum_repository2.sync()
        cv.repository = [yum_repository2]
        cv.update(['repository'])
        assert cv.read_json(
        )['repositories'][0]['name'] == yum_repository2.name

        ContentView.puppet_module_remove({
            'organization':
            org.name,
            'content-view':
            cv.name,
            'name':
            puppet_module_list['name'],
            'author':
            puppet_module_list['author'],
        })
        assert len(cv.read_json()['puppet_modules']) == 0

        module = {'name': 'versioned', 'version': '2.2.2'}
        puppet_module_list = PuppetModule.list(
            {'search':
             'name={name} and version={version}'.format(**module)})[0]
        ContentView.puppet_module_add({
            'organization': org.name,
            'content-view': cv.name,
            'name': puppet_module_list['name'],
            'author': puppet_module_list['author'],
        })
        assert len(cv.read_json()['puppet_modules']) > 0
        cv.publish()
        assert len(cv.read_json()['versions']) == 2
        content_view_json = cv.read_json()['environments'][0]
        cv.delete_from_environment(content_view_json['id'])
        assert len(cv.read_json()['environments']) == 0
Example #2
0
    def test_cv_postupgrade_scenario(self):
        """This is post-upgrade scenario test to verify if we can update
         content-view created in pre-upgrade scenario with various repositories.

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

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

         :expectedresults: content-view updated with various repositories.
        """
        product_id = Repository.info({
            'name': self.yum_repo1_name,
            'organization': self.org_name,
            'product': self.product_name
        })['product']['id']
        ContentView.remove_repository({
            'organization': self.org_name,
            'name': self.cv_name,
            'repository': self.yum_repo1_name
        })
        content_view = ContentView.info({
            'name': self.cv_name,
            'organization': self.org_name
        })
        self.assertNotIn(self.yum_repo1_name, content_view['yum-repositories'])
        yum_repo2 = make_repository({
            'name': self.yum_repo2_name,
            'organization': self.org_name,
            'content-type': 'yum',
            'product-id': product_id,
            'url': FAKE_2_YUM_REPO
        })
        Repository.synchronize({
            'id': yum_repo2['id'],
            'organization': self.org_name
        })
        ContentView.add_repository({
            'name': self.cv_name,
            'organization': self.org_name,
            'product': self.product_name,
            'repository-id': yum_repo2['id']
        })
        content_view = ContentView.info({
            'name': self.cv_name,
            'organization': self.org_name
        })
        self.assertEqual(
            content_view['yum-repositories'][0]['name'],
            self.yum_repo2_name,
            'Repo was not associated to CV',
        )
        ContentView.puppet_module_remove({
            'organization': self.org_name,
            'content-view': self.cv_name,
            'name': self.puppet_module_name,
            'author': self.puppet_module_author,
        })
        content_view = ContentView.info({
            'name': self.cv_name,
            'organization': self.org_name
        })
        self.assertEqual(len(content_view['puppet-modules']), 0)
        module = {'name': 'versioned', 'version': '2.2.2'}
        puppet_module = PuppetModule.list(
            {'search':
             'name={name} and version={version}'.format(**module)})[0]
        ContentView.puppet_module_add({
            'organization': self.org_name,
            'content-view': self.cv_name,
            'name': puppet_module['name'],
            'author': puppet_module['author'],
        })
        content_view = ContentView.info({'id': content_view['id']})
        self.assertGreater(len(content_view['puppet-modules']), 0)
        ContentView.publish({
            'name': self.cv_name,
            'organization': self.org_name
        })
        content_view = ContentView.info({
            'name': self.cv_name,
            'organization': self.org_name
        })
        self.assertEqual(len(content_view['versions']), 2)
Example #3
0
    def test_cv_postupgrade_scenario(self):
        """This is post-upgrade scenario test to verify if we can update
         content-view created in pre-upgrade scenario with various repositories.

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

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

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