From da4f82806d19ce1657f0dfd851af7b835fbb4c46 Mon Sep 17 00:00:00 2001 From: John Fulton Date: Mon, 6 Jan 2020 17:27:41 -0500 Subject: [PATCH] Ceph PG validation unit shouldn't depend on dict order The test_simulate_pool_creation_not_enough_osds unit test was requiring that the error message returned by the function it tests to contain a dictionary in a certain order. However, any ordering is valid so the test shouldn't fail if the order differs. This update of the unit test supports both possible orderings of the two items. Change-Id: I80097beb9072c9728de2f08eec4580ea4959be1b --- .../library/test_ceph_pools_pg_protection.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tripleo_validations/tests/library/test_ceph_pools_pg_protection.py b/tripleo_validations/tests/library/test_ceph_pools_pg_protection.py index 52e66f551..f21e6b679 100644 --- a/tripleo_validations/tests/library/test_ceph_pools_pg_protection.py +++ b/tripleo_validations/tests/library/test_ceph_pools_pg_protection.py @@ -59,16 +59,21 @@ class TestCephPoolsPgProtection(base.TestCase): def test_simulate_pool_creation_not_enough_osds(self): '''Test creating 3 pools with differing PGs with 1 OSD''' num_osds = 1 - error = "The following Ceph pools would be created (but no others):\n" - error += "{'images': {'pg_num': 128, 'size': 3}}\n" - error += "Pool creation would then fail with the following from Ceph:\n" - error += "Cannot add pool: vms pg_num 256 size 3 would mean 384 total pgs, " - error += "which exceeds max 200 (mon_max_pg_per_osd 200 * num_in_osds 1)\n" - error += "Please use https://ceph.io/pgcalc and then update the " - error += "CephPools parameter" pools = [{'name': 'images', 'pg_num': 128, 'size': 3}, {'name': 'vms', 'pg_num': 256, 'size': 3}, {'name': 'volumes', 'pg_num': 512, 'size': 3}] sim = validation.simulate_pool_creation(num_osds, pools) self.assertEqual(sim['failed'], True) - self.assertEqual(sim['msg'], error) + + error_head = "The following Ceph pools would be created (but no others):\n" + order0 = "{'images': {'size': 3}, 'pg_num': 128}\n" + order1 = "{'images': {'pg_num': 128, 'size': 3}}\n" + error_tail = "Pool creation would then fail with the following from Ceph:\n" + error_tail += "Cannot add pool: vms pg_num 256 size 3 would mean 384 total pgs, " + error_tail += "which exceeds max 200 (mon_max_pg_per_osd 200 * num_in_osds 1)\n" + error_tail += "Please use https://ceph.io/pgcalc and then update the " + error_tail += "CephPools parameter" + + self.assertTrue( + (sim['msg'] == error_head + order0 + error_tail) + or (sim['msg'] == error_head + order1 + error_tail))