Exemplo n.º 1
0
    def test_update_existing_replicated_rule(self, m_run_command, m_fail_json):
        ca_test_common.set_module_args({
            'name': fake_name,
            'rule_type': 'replicated',
            'bucket_root': fake_bucket_root,
            'bucket_type': fake_bucket_type,
            'device_class': fake_device_class
        })
        m_fail_json.side_effect = ca_test_common.fail_json
        rc = 0
        stderr = ''
        stdout = '{{"type":3,"rule_name":"{}","steps":[{{"item_name":"default"}},{{"type":"host"}}]}}'.format(
            fake_name)
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            ceph_crush_rule.main()

        result = result.value.args[0]
        print(result)
        assert not result['changed']
        assert result[
            'msg'] == 'Can not convert crush rule {} to replicated'.format(
                fake_name)
        assert result['rc'] == 1
    def test_activate_with_container(self, m_run_command, m_exit_json):
        ca_test_common.set_module_args({
            'osd_id': fake_id,
            'osd_fsid': fake_uuid,
        })
        m_exit_json.side_effect = ca_test_common.exit_json
        stdout = ''
        stderr = ''
        rc = 0
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_volume_simple_activate.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == [fake_container_binary,
                                 'run', '--rm', '--privileged',
                                 '--ipc=host', '--net=host',
                                 '-v', '/etc/ceph:/etc/ceph:z',
                                 '-v', '/var/lib/ceph/:/var/lib/ceph/:z',
                                 '-v', '/var/log/ceph/:/var/log/ceph/:z',
                                 '-v', '/run/lvm/:/run/lvm/',
                                 '-v', '/run/lock/lvm/:/run/lock/lvm/',
                                 '--entrypoint=ceph-volume', fake_container_image,
                                 '--cluster', fake_cluster, 'simple', 'activate', fake_id, fake_uuid]
        assert result['rc'] == rc
        assert result['stderr'] == stderr
        assert result['stdout'] == stdout
Exemplo n.º 3
0
    def test_state_present_nothing_to_update(self, m_exec_command, m_exit_json,
                                             m_fail_json):
        ca_test_common.set_module_args({
            "state": "present",
            "name": "foo",
            "k": 2,
            "m": 4,
            "stripe_unit": 32,
        })
        m_exit_json.side_effect = ca_test_common.exit_json
        m_fail_json.side_effect = ca_test_common.fail_json
        m_exec_command.return_value = (
            0,
            [
                'ceph', 'osd', 'erasure-code-profile', 'get', 'foo',
                '--format', 'json'
            ],
            '{"crush-device-class":"","crush-failure-domain":"host","crush-root":"default","jerasure-per-chunk-alignment":"false","k":"2","m":"4","plugin":"jerasure","stripe_unit":"32","technique":"reed_sol_van","w":"8"}',  # noqa: E501
            '')

        with pytest.raises(ca_test_common.AnsibleExitJson) as r:
            ceph_ec_profile.run_module()

        result = r.value.args[0]
        assert not result['changed']
        assert result['cmd'] == [
            'ceph', 'osd', 'erasure-code-profile', 'get', 'foo', '--format',
            'json'
        ]
        assert result[
            'stdout'] == '{"crush-device-class":"","crush-failure-domain":"host","crush-root":"default","jerasure-per-chunk-alignment":"false","k":"2","m":"4","plugin":"jerasure","stripe_unit":"32","technique":"reed_sol_van","w":"8"}'  # noqa: E501
        assert not result['stderr']
        assert result['rc'] == 0
Exemplo n.º 4
0
    def test_state_info(self, m_exec_commands, m_exit_json, output_format):
        ca_test_common.set_module_args({
            "state": "info",
            "cluster": "ceph",
            "name": "client.admin",
            "output_format": output_format
        })
        m_exit_json.side_effect = ca_test_common.exit_json
        m_exec_commands.return_value = (
            0,
            ['ceph', 'auth', 'get', 'client.admin', '-f', output_format],
            '[{"entity":"client.admin","key":"AQC1tw5fF156GhAAoJCvHGX/jl/k7/N4VZm8iQ==","caps":{"mds":"allow *","mgr":"allow *","mon":"allow *","osd":"allow *"}}]',  # noqa: E501
            'exported keyring for client.admin')

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_key.run_module()

        result = result.value.args[0]
        assert not result['changed']
        assert result['cmd'] == [
            'ceph', 'auth', 'get', 'client.admin', '-f', output_format
        ]
        assert result[
            'stdout'] == '[{"entity":"client.admin","key":"AQC1tw5fF156GhAAoJCvHGX/jl/k7/N4VZm8iQ==","caps":{"mds":"allow *","mgr":"allow *","mon":"allow *","osd":"allow *"}}]'  # noqa: E501
        assert result['stderr'] == 'exported keyring for client.admin'
        assert result['rc'] == 0
Exemplo n.º 5
0
    def test_with_container(self, m_run_command, m_exit_json):
        ca_test_common.set_module_args({'name': fake_name, 'state': 'info'})
        m_exit_json.side_effect = ca_test_common.exit_json
        rc = 0
        stderr = ''
        stdout = '{{"rule_name":"{}","steps":[{{"item_name":"{}"}},{{"type":"{}"}}]}}'.format(
            fake_name, fake_bucket_root, fake_bucket_type)
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_crush_rule.main()

        result = result.value.args[0]
        assert not result['changed']
        assert result['cmd'] == [
            fake_container_binary, 'run', '--rm', '--net=host', '-v',
            '/etc/ceph:/etc/ceph:z', '-v', '/var/lib/ceph/:/var/lib/ceph/:z',
            '-v', '/var/log/ceph/:/var/log/ceph/:z', '--entrypoint=ceph',
            fake_container_image, '-n', fake_user, '-k', fake_keyring,
            '--cluster', fake_cluster, 'osd', 'crush', 'rule', 'dump',
            fake_name, '--format=json'
        ]
        assert result['rc'] == rc
        assert result['stderr'] == stderr
        assert result['stdout'] == stdout
Exemplo n.º 6
0
    def test_one_already_set_state_multiple_ids(self, m_run_command,
                                                m_exit_json, state):
        ca_test_common.set_module_args({'ids': fake_ids, 'state': state})
        m_exit_json.side_effect = ca_test_common.exit_json
        stdout = ''
        stderr = 'marked {} osd.{}. osd.{} does not exist. osd.{} does not exist.'.format(
            state, fake_ids[0], fake_ids[1], fake_ids[2])
        rc = 0
        m_run_command.return_value = rc, stdout, stderr
        cmd = [
            'ceph', '-n', fake_user, '-k', fake_keyring, '--cluster',
            fake_cluster, 'osd', state
        ]
        cmd.extend(fake_ids)
        if state in ['destroy', 'purge']:
            cmd.append('--yes-i-really-mean-it')

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_osd.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == cmd
        assert result['rc'] == rc
        assert result['stderr'] == stderr
        assert result['stdout'] == stdout
Exemplo n.º 7
0
    def test_create_non_existing_replicated_rule(self, m_run_command,
                                                 m_exit_json):
        ca_test_common.set_module_args({
            'name': fake_name,
            'rule_type': 'replicated',
            'bucket_root': fake_bucket_root,
            'bucket_type': fake_bucket_type
        })
        m_exit_json.side_effect = ca_test_common.exit_json
        get_rc = 2
        get_stderr = 'Error ENOENT: unknown crush rule \'{}\''.format(
            fake_name)
        get_stdout = ''
        create_rc = 0
        create_stderr = ''
        create_stdout = ''
        m_run_command.side_effect = [(get_rc, get_stdout, get_stderr),
                                     (create_rc, create_stdout, create_stderr)]

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_crush_rule.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == [
            'ceph', '-n', fake_user, '-k', fake_keyring, '--cluster',
            fake_cluster, 'osd', 'crush', 'rule', 'create-replicated',
            fake_name, fake_bucket_root, fake_bucket_type
        ]
        assert result['rc'] == create_rc
        assert result['stderr'] == create_stderr
        assert result['stdout'] == create_stdout
Exemplo n.º 8
0
    def test_create_existing_replicated_rule(self, m_run_command, m_exit_json):
        ca_test_common.set_module_args({
            'name': fake_name,
            'rule_type': 'replicated',
            'bucket_root': fake_bucket_root,
            'bucket_type': fake_bucket_type
        })
        m_exit_json.side_effect = ca_test_common.exit_json
        rc = 0
        stderr = ''
        stdout = '{{"rule_name":"{}","type":1,"steps":[{{"item_name":"{}"}},{{"type":"{}"}}]}}'.format(
            fake_name, fake_bucket_root, fake_bucket_type)
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_crush_rule.main()

        result = result.value.args[0]
        assert not result['changed']
        assert result['cmd'] == [
            'ceph', '-n', fake_user, '-k', fake_keyring, '--cluster',
            fake_cluster, 'osd', 'crush', 'rule', 'dump', fake_name,
            '--format=json'
        ]
        assert result['rc'] == 0
        assert result['stderr'] == stderr
        assert result['stdout'] == stdout
Exemplo n.º 9
0
    def test_with_container(self, m_run_command, m_exit_json):
        ca_test_common.set_module_args({
            'name': fake_module,
        })
        m_exit_json.side_effect = ca_test_common.exit_json
        stdout = ''
        stderr = '{} is set'.format(fake_module)
        rc = 0
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_mgr_module.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == [fake_container_binary, 'run', '--rm', '--net=host',
                                 '-v', '/etc/ceph:/etc/ceph:z',
                                 '-v', '/var/lib/ceph/:/var/lib/ceph/:z',
                                 '-v', '/var/log/ceph/:/var/log/ceph/:z',
                                 '--entrypoint=ceph', fake_container_image,
                                 '-n', fake_user, '-k', fake_keyring,
                                 '--cluster', fake_cluster, 'mgr', 'module', 'enable', fake_module]
        assert result['rc'] == rc
        assert result['stderr'] == stderr
        assert result['stdout'] == stdout
    def test_scan_path_stdout_force(self, m_run_command, m_exit_json,
                                    m_os_path):
        ca_test_common.set_module_args({
            'path': fake_path,
            'force': True,
            'stdout': True
        })
        m_exit_json.side_effect = ca_test_common.exit_json
        stdout = ''
        stderr = ''
        rc = 0
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_volume_simple_scan.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == [
            'ceph-volume', '--cluster', fake_cluster, 'simple', 'scan',
            '--force', '--stdout', fake_path
        ]
        assert result['rc'] == rc
        assert result['stderr'] == stderr
        assert result['stdout'] == stdout
Exemplo n.º 11
0
    def test_with_default_values(self, m_run_command, m_exit_json):
        ca_test_common.set_module_args({'name': fake_name})
        m_exit_json.side_effect = ca_test_common.exit_json
        stdout = 'Stopping old systemd unit ceph-mon@{}...\n' \
                 'Disabling old systemd unit ceph-mon@{}...\n' \
                 'Moving data...\n' \
                 'Chowning content...\n' \
                 'Moving logs...\n' \
                 'Creating new units...\n' \
                 'firewalld ready'.format(fake_name, fake_name)
        stderr = ''
        rc = 0
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            cephadm_adopt.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == [
            'cephadm', 'adopt', '--cluster', fake_cluster, '--name', fake_name,
            '--style', 'legacy'
        ]
        assert result['rc'] == 0
        assert result['stderr'] == stderr
        assert result['stdout'] == stdout
Exemplo n.º 12
0
    def test_set_state_with_container(self, m_run_command, m_exit_json, state):
        ca_test_common.set_module_args({'ids': fake_id, 'state': state})
        m_exit_json.side_effect = ca_test_common.exit_json
        stdout = ''
        stderr = 'marked {} osd.{}'.format(state, fake_id)
        rc = 0
        m_run_command.return_value = rc, stdout, stderr
        cmd = [
            fake_container_binary, 'run', '--rm', '--net=host', '-v',
            '/etc/ceph:/etc/ceph:z', '-v', '/var/lib/ceph/:/var/lib/ceph/:z',
            '-v', '/var/log/ceph/:/var/log/ceph/:z', '--entrypoint=ceph',
            fake_container_image, '-n', fake_user, '-k', fake_keyring,
            '--cluster', fake_cluster, 'osd', state, fake_id
        ]
        if state in ['destroy', 'purge']:
            cmd.append('--yes-i-really-mean-it')

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_osd.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == cmd
        assert result['rc'] == rc
        assert result['stderr'] == stderr
        assert result['stdout'] == stdout
Exemplo n.º 13
0
    def test_remove_existing_rule(self, m_run_command, m_exit_json):
        ca_test_common.set_module_args({'name': fake_name, 'state': 'absent'})
        m_exit_json.side_effect = ca_test_common.exit_json
        get_rc = 0
        get_stderr = ''
        get_stdout = '{{"rule_name":"{}","steps":[{{"item_name":"{}"}},{{"type":"{}"}}]}}'.format(
            fake_name, fake_bucket_root, fake_bucket_type)
        remove_rc = 0
        remove_stderr = ''
        remove_stdout = ''
        m_run_command.side_effect = [(get_rc, get_stdout, get_stderr),
                                     (remove_rc, remove_stdout, remove_stderr)]

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_crush_rule.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == [
            'ceph', '-n', fake_user, '-k', fake_keyring, '--cluster',
            fake_cluster, 'osd', 'crush', 'rule', 'rm', fake_name
        ]
        assert result['rc'] == remove_rc
        assert result['stderr'] == remove_stderr
        assert result['stdout'] == remove_stdout
Exemplo n.º 14
0
    def test_state_present_profile_doesnt_exist(self, m_exec_command,
                                                m_exit_json, m_fail_json):
        ca_test_common.set_module_args({
            "state": "present",
            "name": "foo",
            "k": 2,
            "m": 4,
            "stripe_unit": 32
        })
        m_exit_json.side_effect = ca_test_common.exit_json
        m_fail_json.side_effect = ca_test_common.fail_json
        m_exec_command.side_effect = [
            (2, [
                'ceph', 'osd', 'erasure-code-profile', 'get', 'foo',
                '--format', 'json'
            ], '', "Error ENOENT: unknown erasure code profile 'foo'"),
            (0, [
                'ceph', 'osd', 'erasure-code-profile', 'set', 'foo', 'k=2',
                'm=4', 'stripe_unit=32', '--force'
            ], '', '')
        ]

        with pytest.raises(ca_test_common.AnsibleExitJson) as r:
            ceph_ec_profile.run_module()

        result = r.value.args[0]
        assert result['changed']
        assert result['cmd'] == [
            'ceph', 'osd', 'erasure-code-profile', 'set', 'foo', 'k=2', 'm=4',
            'stripe_unit=32', '--force'
        ]
        assert not result['stdout']
        assert not result['stderr']
        assert result['rc'] == 0
Exemplo n.º 15
0
    def test_generate_key(self, m_exit_json, m_generate_secret):
        fake_secret = b'AQDaLb1fAAAAABAAsIMKdGEKu+lGOyXnRfT0Hg=='
        ca_test_common.set_module_args({"state": "generate_secret"})
        m_exit_json.side_effect = ca_test_common.exit_json
        m_generate_secret.return_value = fake_secret

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_key.run_module()
        assert result.value.args[0]['stdout'] == fake_secret.decode()
Exemplo n.º 16
0
    def test_without_parameters(self, m_fail_json):
        ca_test_common.set_module_args({})
        m_fail_json.side_effect = ca_test_common.fail_json

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            ceph_mgr_module.main()

        result = result.value.args[0]
        assert result['msg'] == 'missing required arguments: name'
Exemplo n.º 17
0
    def test_with_name_only(self, m_fail_json):
        ca_test_common.set_module_args({'name': fake_name})
        m_fail_json.side_effect = ca_test_common.fail_json

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            ceph_crush_rule.main()

        result = result.value.args[0]
        assert result[
            'msg'] == 'state is present but all of the following are missing: rule_type'
    def test_scan_path_not_exists(self, m_fail_json, m_os_path):
        ca_test_common.set_module_args({'path': fake_path})
        m_fail_json.side_effect = ca_test_common.fail_json

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            ceph_volume_simple_scan.main()

        result = result.value.args[0]
        assert result['msg'] == '{} does not exist'.format(fake_path)
        assert result['rc'] == 1
Exemplo n.º 19
0
    def test_invalid_state_multiple_ids(self, m_run_command, m_fail_json,
                                        state):
        ca_test_common.set_module_args({'ids': fake_ids, 'state': state})
        m_fail_json.side_effect = ca_test_common.fail_json

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            ceph_osd.main()

        result = result.value.args[0]
        assert result[
            'msg'] == 'destroy and purge only support one OSD at at time'
        assert result['rc'] == 1
Exemplo n.º 20
0
    def test_with_invalid_state(self, m_fail_json):
        ca_test_common.set_module_args({
            'ids': fake_id,
            'state': invalid_state,
        })
        m_fail_json.side_effect = ca_test_common.fail_json

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            ceph_osd.main()

        result = result.value.args[0]
        assert result['msg'] == (
            'value of state must be one of: destroy, down, '
            'in, out, purge, rm, got: {}'.format(invalid_state))
Exemplo n.º 21
0
    def test_with_failure(self, m_run_command, m_fail_json):
        ca_test_common.set_module_args({'name': fake_name})
        m_fail_json.side_effect = ca_test_common.fail_json
        stdout = ''
        stderr = 'ERROR: cephadm should be run as root'
        rc = 1
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            cephadm_adopt.main()

        result = result.value.args[0]
        assert result['rc'] == 1
        assert result['msg'] == 'ERROR: cephadm should be run as root'
Exemplo n.º 22
0
    def test_with_invalid_flag(self, m_fail_json):
        ca_test_common.set_module_args({
            'name': invalid_flag,
        })
        m_fail_json.side_effect = ca_test_common.fail_json

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            ceph_osd_flag.main()

        result = result.value.args[0]
        assert result['msg'] == (
            'value of name must be one of: noup, nodown, '
            'noout, nobackfill, norebalance, norecover, '
            'noscrub, nodeep-scrub, got: {}'.format(invalid_flag))
    def test_with_check_mode(self, m_exit_json):
        ca_test_common.set_module_args({'_ansible_check_mode': True})
        m_exit_json.side_effect = ca_test_common.exit_json

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_volume_simple_scan.main()

        result = result.value.args[0]
        assert not result['changed']
        assert result['cmd'] == [
            'ceph-volume', '--cluster', fake_cluster, 'simple', 'scan'
        ]
        assert result['rc'] == 0
        assert not result['stdout']
        assert not result['stderr']
Exemplo n.º 24
0
    def test_with_check_mode(self, m_exit_json):
        ca_test_common.set_module_args({
            'name': fake_name,
            '_ansible_check_mode': True
        })
        m_exit_json.side_effect = ca_test_common.exit_json

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            cephadm_adopt.main()

        result = result.value.args[0]
        assert not result['changed']
        assert result['cmd'] == ['cephadm', 'ls', '--no-detail']
        assert result['rc'] == 0
        assert not result['stdout']
        assert not result['stderr']
Exemplo n.º 25
0
    def test_with_check_mode(self, m_exit_json):
        ca_test_common.set_module_args({
            'name': fake_module,
            '_ansible_check_mode': True
        })
        m_exit_json.side_effect = ca_test_common.exit_json

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_mgr_module.main()

        result = result.value.args[0]
        assert not result['changed']
        assert result['cmd'] == ['ceph', '-n', fake_user, '-k', fake_keyring, '--cluster', fake_cluster, 'mgr', 'module', 'enable', fake_module]
        assert result['rc'] == 0
        assert not result['stdout']
        assert not result['stderr']
Exemplo n.º 26
0
    def test_with_failure(self, m_run_command, m_exit_json):
        ca_test_common.set_module_args({'mon_ip': fake_ip})
        m_exit_json.side_effect = ca_test_common.exit_json
        stdout = ''
        stderr = 'ERROR: cephadm should be run as root'
        rc = 1
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            cephadm_bootstrap.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == ['cephadm', 'bootstrap', '--mon-ip', fake_ip]
        assert result['rc'] == 1
        assert result['stderr'] == 'ERROR: cephadm should be run as root'
Exemplo n.º 27
0
    def test_with_default_values(self, m_run_command, m_exit_json):
        ca_test_common.set_module_args({'mon_ip': fake_ip})
        m_exit_json.side_effect = ca_test_common.exit_json
        stdout = 'Bootstrap complete.'
        stderr = ''
        rc = 0
        m_run_command.return_value = rc, stdout, stderr

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            cephadm_bootstrap.main()

        result = result.value.args[0]
        assert result['changed']
        assert result['cmd'] == ['cephadm', 'bootstrap', '--mon-ip', fake_ip]
        assert result['rc'] == 0
        assert result['stdout'] == 'Bootstrap complete.'
    def test_with_check_mode(self, m_exit_json):
        ca_test_common.set_module_args({
            'mon_ip': fake_ip,
            '_ansible_check_mode': True
        })
        m_exit_json.side_effect = ca_test_common.exit_json

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            cephadm_bootstrap.main()

        result = result.value.args[0]
        assert not result['changed']
        assert result['cmd'] == ['cephadm', 'bootstrap', '--mon-ip', fake_ip]
        assert result['rc'] == 0
        assert not result['stdout']
        assert not result['stderr']
Exemplo n.º 29
0
    def test_check_mode(self, m_exit_json):
        ca_test_common.set_module_args({
            'name': 'foo',
            'k': 2,
            'm': 4,
            '_ansible_check_mode': True
        })
        m_exit_json.side_effect = ca_test_common.exit_json

        with pytest.raises(ca_test_common.AnsibleExitJson) as result:
            ceph_ec_profile.run_module()

        result = result.value.args[0]
        assert not result['changed']
        assert result['rc'] == 0
        assert not result['stdout']
        assert not result['stderr']
Exemplo n.º 30
0
    def test_state_info_invalid_format(self, m_fail_json):
        invalid_format = 'txt'
        ca_test_common.set_module_args({
            "state": "info",
            "cluster": "ceph",
            "name": "client.admin",
            "output_format": invalid_format
        })
        m_fail_json.side_effect = ca_test_common.fail_json

        with pytest.raises(ca_test_common.AnsibleFailJson) as result:
            ceph_key.run_module()

        result = result.value.args[0]
        assert result[
            'msg'] == 'value of output_format must be one of: json, plain, xml, yaml, got: {}'.format(
                invalid_format)