Exemplo n.º 1
0
    def _traverse_command_tree(self, command):
        """Recursively walk through the hammer commands tree and assert that
        the expected options are present.

        """
        output = hammer.parse_help(
            ssh.command('{0} --help'.format(command)).stdout
        )
        command_options = set([option['name'] for option in output['options']])
        command_subcommands = set(
            [subcommand['name'] for subcommand in output['subcommands']]
        )
        if 'discovery_rule' in command and bz_bug_is_open(1219610):
            # Adjust the discovery_rule subcommand name. The expected data is
            # already with the naming convetion name
            expected = self._fetch_command_info(
                command.replace('discovery_rule', 'discovery-rule'))
        else:
            expected = self._fetch_command_info(command)
        expected_options = set()
        expected_subcommands = set()

        if expected is not None:
            expected_options = set(
                [option['name'] for option in expected['options']]
            )
            expected_subcommands = set(
                [subcommand['name'] for subcommand in expected['subcommands']]
            )

        if command == 'hammer' and bz_bug_is_open(1219610):
            # Adjust the discovery_rule subcommand name
            command_subcommands.discard('discovery_rule')
            command_subcommands.add('discovery-rule')

        added_options = tuple(command_options - expected_options)
        removed_options = tuple(expected_options - command_options)
        added_subcommands = tuple(command_subcommands - expected_subcommands)
        removed_subcommands = tuple(expected_subcommands - command_subcommands)

        if (added_options or added_subcommands or removed_options or
                removed_subcommands):
            diff = {
                'added_command': expected is None,
            }
            if added_options:
                diff['added_options'] = added_options
            if removed_options:
                diff['removed_options'] = removed_options
            if added_subcommands:
                diff['added_subcommands'] = added_subcommands
            if removed_subcommands:
                diff['removed_subcommands'] = removed_subcommands
            self.differences[command] = diff

        if len(output['subcommands']) > 0:
            for subcommand in output['subcommands']:
                self._traverse_command_tree(
                    '{0} {1}'.format(command, subcommand['name'])
                )
Exemplo n.º 2
0
    def test_positive_delete_1(self):
        """@Test: Check if product can be deleted

        @Feature: Product

        @Assert: Product is deleted

        """
        new_product = make_product({
            u'organization-id': self.org['id']
        })

        # Delete it
        result = Product.delete({u'id': new_product['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # Fetch it
        result = Product.info({
            u'id': new_product['id'],
            u'organization-id': self.org['id'],
        })
        if bz_bug_is_open(1219490):
            for _ in range(5):
                if result.return_code == 0:
                    time.sleep(5)
                    result = Product.info({
                        u'id': new_product['id'],
                        u'organization-id': self.org['id'],
                    })
                else:
                    break
        self.assertNotEqual(result.return_code, 0)
        self.assertGreater(len(result.stderr), 0)
Exemplo n.º 3
0
def enable_rhrepo_and_fetchid(basearch, org_id, product, repo,
                              reposet, releasever):
    """Enable a RedHat Repository and fetches it's Id.

    :param str org_id: The organization Id.
    :param str product: The product name in which repository exists.
    :param str reposet: The reposet name in which repository exists.
    :param str repo: The repository name who's Id is to be fetched.
    :param str basearch: The architecture of the repository.
    :param str releasever: The releasever of the repository.
    :return: Returns the repository Id.
    :rtype: str

    """
    product = entities.Product(name=product, organization=org_id).search()[0]
    r_set = entities.RepositorySet(name=reposet, product=product).search()[0]
    payload = {}
    if basearch is not None:
        payload['basearch'] = basearch
    if releasever is not None:
        payload['releasever'] = releasever
    r_set.enable(data=payload)
    result = entities.Repository(name=repo).search(
        query={'organization_id': org_id})
    if bz_bug_is_open(1252101):
        for _ in range(5):
            if len(result) > 0:
                break
            time.sleep(5)
            result = entities.Repository(name=repo).search(
                query={'organization_id': org_id})
    return result[0].id
Exemplo n.º 4
0
    def test_sc_params_by_environment_name(self):
        """@Test: Check if environment sc-param subcommand works passing
        an environment name

        @Feature: Environment

        @Assert: The command runs without raising an error

        @BZ: 1219934

        """
        environment = make_environment()
        result = Environment.sc_params({
            'environment': environment['name'],
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        if not bz_bug_is_open(1219934):
            self.fail('BZ #1219934 is closed, should assert the content')