def test_positive_list_multiple_repos(self):
        """Verify that puppet-modules list for specific repo is correct
        and does not affected by other repositories.

        :id: f36d25b3-2495-4e89-a1cf-e39d52762d95

        :expectedresults: Number of modules has no changed after a second repo
            was synced.

        :CaseImportance: Critical
        """
        # Verify that number of synced modules is correct
        repo1 = Repository.info({'id': self.repo['id']})
        repo_content_count = repo1['content-counts']['puppet-modules']
        modules_num = len(PuppetModule.list({'repository-id': repo1['id']}))
        self.assertEqual(repo_content_count, str(modules_num))
        # Create and sync second repo
        repo2 = make_repository({
            u'organization-id': self.org['id'],
            u'product-id': self.product['id'],
            u'content-type': u'puppet',
            u'url': FAKE_1_PUPPET_REPO,
        })
        Repository.synchronize({'id': repo2['id']})
        # Verify that number of modules from the first repo has not changed
        self.assertEqual(
            modules_num, len(PuppetModule.list({'repository-id':
                                                repo1['id']})))
    def test_positive_list_multiple_repos(self):
        """Verify that puppet-modules list for specific repo is correct
        and does not affected by other repositories.

        @id: f36d25b3-2495-4e89-a1cf-e39d52762d95

        @Assert: Number of modules has no changed after a second repo
        was synced.
        """
        # Verify that number of synced modules is correct
        repo1 = Repository.info({'id': self.repo['id']})
        repo_content_count = repo1['content-counts']['puppet-modules']
        modules_num = len(
            PuppetModule.list({'repository-id': repo1['id']}))
        self.assertEqual(repo_content_count, str(modules_num))
        # Create and sync second repo
        repo2 = make_repository({
            u'organization-id': self.org['id'],
            u'product-id': self.product['id'],
            u'content-type': u'puppet',
            u'url': FAKE_1_PUPPET_REPO,
        })
        Repository.synchronize({'id': repo2['id']})
        # Verify that number of modules from the first repo has not changed
        self.assertEqual(
            modules_num,
            len(PuppetModule.list({'repository-id': repo1['id']}))
        )
Exemple #3
0
    def test_bugzilla_1127382(self):
        """
        @Test: hammer puppet-module <info,list> --help
        @Feature: puppet-module info/list
        @Assert: Assert product option are present
        """
        # puppet-module list --help:
        result = PuppetModule.list({'help': True})
        # get list of lines and check they all are unique
        lines = [line['message'] for line in result.stdout]
        self.assertEqual(len(set(lines)), len(lines),
                         'The help should not have repeat options')
        product_options = [line for line in lines
                           if line.startswith('--product')]
        self.assertGreater(len(product_options), 0,
                           'At least one --product option should be present')

        # puppet-module info --help:info, ignore exception
        result = PuppetModule.info({'help': True})
        # get list of lines and check they all are unique
        lines = [line for line in result.stdout['options']]
        self.assertEqual(len(set(lines)), len(lines),
                         'The help should not have repeat options')
        product_options = [line for line in lines
                           if line.startswith('--product')]
        self.assertGreater(len(product_options), 0,
                           'At least one --product option should be present')
    def test_bugzilla_1127382(self):
        """@Test: hammer puppet-module <info,list> --help

        @Feature: puppet-module info/list

        @Assert: Assert product option are present

        """
        # puppet-module list --help:
        result = PuppetModule.list({'help': True})
        # get list of lines and check they all are unique
        lines = [line['message'] for line in result.stdout]
        self.assertEqual(len(set(lines)), len(lines),
                         'The help should not have repeat options')
        product_options = [line for line in lines
                           if line.startswith('--product')]
        self.assertGreater(len(product_options), 0,
                           'At least one --product option should be present')

        # puppet-module info --help:info, ignore exception
        result = PuppetModule.info({'help': True})
        # get list of lines and check they all are unique
        lines = [line for line in result.stdout['options']]
        self.assertEqual(len(set(lines)), len(lines),
                         'The help should not have repeat options')
        product_options = [line for line in lines
                           if line.startswith('--product')]
        self.assertGreater(len(product_options), 0,
                           'At least one --product option should be present')
Exemple #5
0
 def setupScenario(self):
     """ Create yum, puppet repositories and synchronize them.
     """
     self.org = make_org({'name': self.org_name})
     self.product = make_product({
         'name': self.product_name,
         'organization-id': self.org['id']
     })
     self.yum_repo1 = make_repository({
         'name': self.yum_repo1_name,
         'product-id': self.product['id'],
         'content-type': 'yum',
         'url': FAKE_1_YUM_REPO
     })
     Repository.synchronize({'id': self.yum_repo1['id']})
     self.module = {'name': self.puppet_module_name, 'version': '3.3.3'}
     self.puppet_repo = make_repository({
         'name': self.puppet_repo_name,
         'content-type': 'puppet',
         'product-id': self.product['id'],
         'url': CUSTOM_PUPPET_REPO,
     })
     Repository.synchronize({'id': self.puppet_repo['id']})
     self.puppet_module = PuppetModule.list({
         'search':
         'name={name} and version={version}'.format(**self.module)
     })[0]
    def test_cv_preupgrade_scenario(self, request):
        """Pre-upgrade scenario that creates content-view with various repositories.

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

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

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

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

        remote_file_path = f"/tmp/{RPM_TO_UPLOAD}"

        ssh.upload_file(local_file=get_data_file(RPM_TO_UPLOAD),
                        remote_file=remote_file_path)
        with open(f'{get_data_file(RPM_TO_UPLOAD)}', "rb") as content:
            file_repository.upload_content(files={'content': content})
        assert RPM_TO_UPLOAD in file_repository.files()["results"][0]['name']
        cv = entities.ContentView(name=f"{test_name}_cv",
                                  organization=org).create()
        cv.repository = [yum_repository, file_repository]
        cv.update(['repository'])
        ContentView.puppet_module_add({
            'content-view-id': cv.id,
            'name': puppet_module_list['name'],
            'author': puppet_module_list['author'],
        })
        cv.publish()
        assert len(cv.puppet_module) == 0
        assert len(cv.read_json()['versions']) == 1
    def test_positive_list(self):
        """Check if puppet-module list retrieves puppet-modules of
        the given org

        @id: 77635e70-19e7-424d-9c89-ec5dbe91de75

        @Assert: Puppet-modules are retrieved for the given org
        """
        result = PuppetModule.list({'organization-id': self.org['id']})
        # There are 4 puppet modules in the test puppet-module url
        self.assertEqual(len(result), 4)
    def test_puppet_module_list(self):
        """@Test: Check if puppet-module list retrieves puppet-modules of
        the given org

        @Feature: Puppet-module

        @Assert: Puppet-modules are retrieved for the given org
        """
        result = PuppetModule.list({'organization-id': self.org['id']})
        # There are 4 puppet modules in the test puppet-module url
        self.assertEqual(len(result), 4)
Exemple #9
0
    def test_positive_list(self):
        """Check if puppet-module list retrieves puppet-modules of
        the given org

        @id: 77635e70-19e7-424d-9c89-ec5dbe91de75

        @Assert: Puppet-modules are retrieved for the given org
        """
        result = PuppetModule.list({'organization-id': self.org['id']})
        # There are 4 puppet modules in the test puppet-module url
        self.assertEqual(len(result), 4)
    def test_positive_list(self):
        """Check if puppet-module list retrieves puppet-modules of
        the given org

        :id: 77635e70-19e7-424d-9c89-ec5dbe91de75

        :expectedresults: Puppet-modules are retrieved for the given org

        :bz: 1283173

        :CaseImportance: Critical
        """
        result = PuppetModule.list({'organization-id': self.org['id']})
        # There are 4 puppet modules in the test puppet-module url
        self.assertEqual(len(result), 4)
Exemple #11
0
    def test_positive_info(self):
        """Check if puppet-module info retrieves info for the given
        puppet-module id

        @id: 8aaa9243-5e20-49d6-95ce-620cc1ba18dc

        @Assert: The puppet-module info is retrieved
        """
        return_value = PuppetModule.list({
            'organization-id': self.org['id'],
        })
        for i in range(len(return_value)):
            result = PuppetModule.info({'id': return_value[i]['id']},
                                       output_format='json')
            self.assertEqual(result['id'], return_value[i]['id'])
Exemple #12
0
def test_positive_list(module_setup):
    """Check if puppet-module list retrieves puppet-modules of
    the given org

    :id: 77635e70-19e7-424d-9c89-ec5dbe91de75

    :expectedresults: Puppet-modules are retrieved for the given org

    :BZ: 1283173

    :CaseImportance: Critical
    """
    result = PuppetModule.list({'organization-id': module_setup['org'].id})
    # There are 4 puppet modules in the test puppet-module url
    assert len(result) == 4
Exemple #13
0
def test_positive_info(module_setup):
    """Check if puppet-module info retrieves info for the given
    puppet-module id

    :id: 8aaa9243-5e20-49d6-95ce-620cc1ba18dc

    :expectedresults: The puppet-module info is retrieved

    :CaseImportance: Critical
    """
    return_value = PuppetModule.list(
        {'organization-id': module_setup['org'].id})
    for i in range(len(return_value)):
        result = PuppetModule.info({'id': return_value[i]['id']},
                                   output_format='json')
        assert result['id'] == return_value[i]['id']
    def test_positive_info(self):
        """Check if puppet-module info retrieves info for the given
        puppet-module id

        @id: 8aaa9243-5e20-49d6-95ce-620cc1ba18dc

        @Assert: The puppet-module info is retrieved
        """
        return_value = PuppetModule.list({
            'organization-id': self.org['id'],
        })
        for i in range(len(return_value)):
            result = PuppetModule.info(
                {'id': return_value[i]['id']},
                output_format='json'
            )
            self.assertEqual(result['id'], return_value[i]['id'])
    def test_puppet_module_info(self):
        """@Test: Check if puppet-module info retrieves info for the given
        puppet-module id

        @Feature: Puppet-module

        @Assert: The puppet-module info is retrieved
        """
        return_value = PuppetModule.list({
            'organization-id': self.org['id'],
        })
        for i in range(len(return_value)):
            result = PuppetModule.info(
                {'id': return_value[i]['id']},
                output_format='json'
            )
            self.assertEqual(result['ID'], return_value[i]['id'])
Exemple #16
0
 def setupScenario(self):
     """ Create yum, puppet repositories and synchronize them.
     """
     self.org = make_org({'name': self.org_name})
     self.product = make_product({
         'name': self.product_name, 'organization-id': self.org['id']})
     self.yum_repo1 = make_repository({
         'name': self.yum_repo1_name,
         'product-id': self.product['id'],
         'content-type': 'yum',
         'url': FAKE_1_YUM_REPO})
     Repository.synchronize({'id': self.yum_repo1['id']})
     self.module = {'name': self.puppet_module_name, 'version': '3.3.3'}
     self.puppet_repo = make_repository({
         'name': self.puppet_repo_name,
         'content-type': 'puppet',
         'product-id': self.product['id'],
         'url': CUSTOM_PUPPET_REPO,
     })
     Repository.synchronize({'id': self.puppet_repo['id']})
     self.puppet_module = PuppetModule.list({
         'search': 'name={name} and version={version}'.format(**self.module)})[0]
Exemple #17
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)
Exemple #18
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)
Exemple #19
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