Skip to content

Commit

Permalink
CI Unittests errors fix
Browse files Browse the repository at this point in the history
Signed-off-by: Teoman ONAY <[email protected]>
  • Loading branch information
asm0deuz committed Dec 2, 2024
1 parent 9405558 commit 5d2bec4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
10 changes: 8 additions & 2 deletions tests/library/test_ceph_crush.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ def test_generate_commands(self):
("chassis", "monchassis"),
("rack", "monrack"),
]
result = ceph_crush.create_and_move_buckets_list(cluster, location)

crush_map = { "nodes", [] }

result = ceph_crush.create_and_move_buckets_list(cluster, location, crush_map)
assert result == expected_command_list

def test_generate_commands_container(self):
Expand All @@ -89,5 +92,8 @@ def test_generate_commands_container(self):
("chassis", "monchassis"),
("rack", "monrack"),
]
result = ceph_crush.create_and_move_buckets_list(cluster, location, containerized)

crush_map = { "nodes", [] }

result = ceph_crush.create_and_move_buckets_list(cluster, location, crush_map, containerized)
assert result == expected_command_list
26 changes: 15 additions & 11 deletions tests/library/test_ceph_ec_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_get_profile(self):
'--format=json'
]

assert ceph_ec_profile.get_profile(self.fake_module, self.fake_name) == expected_cmd
assert ceph_ec_profile.get_profile(self.fake_name) == expected_cmd

@pytest.mark.parametrize("stripe_unit,crush_device_class,force", [(False, None, False),
(32, None, True),
Expand All @@ -53,13 +53,18 @@ def test_create_profile(self, stripe_unit, crush_device_class, force):
if force:
expected_cmd.append('--force')

assert ceph_ec_profile.create_profile(self.fake_module,
self.fake_name,
self.fake_k,
self.fake_m,
stripe_unit,
crush_device_class,
self.fake_cluster,
user_profile = {
"k": self.fake_k,
"m": self.fake_m
}

if stripe_unit:
user_profile["stripe_unit"] = stripe_unit
if crush_device_class:
user_profile["crush-device-class"] = crush_device_class

assert ceph_ec_profile.create_profile(self.fake_name,
user_profile,
force) == expected_cmd

def test_delete_profile(self):
Expand All @@ -72,8 +77,7 @@ def test_delete_profile(self):
'rm', self.fake_name
]

assert ceph_ec_profile.delete_profile(self.fake_module,
self.fake_name,
assert ceph_ec_profile.delete_profile(self.fake_name,
self.fake_cluster) == expected_cmd

@patch('ansible.module_utils.basic.AnsibleModule.fail_json')
Expand All @@ -97,7 +101,7 @@ def test_state_present_nothing_to_update(self, m_exec_command, m_exit_json, m_fa
ceph_ec_profile.run_module()

result = r.value.args[0]
assert not result['changed']
assert 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']
Expand Down

0 comments on commit 5d2bec4

Please sign in to comment.