From: Greg Farnum Date: Tue, 6 Jun 2017 23:00:37 +0000 (-0700) Subject: TestOSDMap: provide more flexibility in the PrimaryAffinity check X-Git-Tag: ses5-milestone8~1^2~21^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cdf22275f2462eb96aae74413feb15e0a4dde43e;p=ceph.git TestOSDMap: provide more flexibility in the PrimaryAffinity check Fix the margins for the primary affinity test. Signed-off-by: Greg Farnum Signed-off-by: Sage Weil --- diff --git a/src/test/osd/TestOSDMap.cc b/src/test/osd/TestOSDMap.cc index dad236074179..c1db4bad0bd6 100644 --- a/src/test/osd/TestOSDMap.cc +++ b/src/test/osd/TestOSDMap.cc @@ -122,6 +122,9 @@ public: ASSERT_EQ(acting, acting2); ASSERT_EQ(acting_primary, acting_primary2); } + cout << "any: " << *any << std::endl;; + cout << "first: " << *first << std::endl;; + cout << "primary: " << *primary << std::endl;; } }; @@ -376,7 +379,9 @@ TEST_F(OSDMapTest, PrimaryAffinity) { p != osdmap.get_pools().end(); ++p) { int pool = p->first; - cout << "pool " << pool << std::endl; + int expect_primary = 10000 / n; + cout << "pool " << pool << " size " << (int)p->second.size + << " expect_primary " << expect_primary << std::endl; { vector any(n, 0); vector first(n, 0); @@ -417,6 +422,8 @@ TEST_F(OSDMapTest, PrimaryAffinity) { vector first(n, 0); vector primary(n, 0); test_mappings(pool, 10000, &any, &first, &primary); + int expect = (10000 / (n-2)) / 2; // half weight + cout << "expect " << expect << std::endl; for (int i=0; i= 2) { @@ -428,8 +435,8 @@ TEST_F(OSDMapTest, PrimaryAffinity) { } ASSERT_EQ(0, primary[i]); } else { - ASSERT_LT(10000/6/4, primary[0]); - ASSERT_GT(10000/6/4*3, primary[0]); + ASSERT_LT(expect *2/3, primary[0]); + ASSERT_GT(expect *4/3, primary[0]); } } }