]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
TestOSDMap: provide more flexibility in the PrimaryAffinity check
authorGreg Farnum <gfarnum@redhat.com>
Tue, 6 Jun 2017 23:00:37 +0000 (16:00 -0700)
committerSage Weil <sage@redhat.com>
Wed, 28 Jun 2017 14:52:49 +0000 (10:52 -0400)
Fix the margins for the primary affinity test.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
Signed-off-by: Sage Weil <sage@redhat.com>
src/test/osd/TestOSDMap.cc

index dad236074179be745c7b8e79b22dd70a328e5f5f..c1db4bad0bd63b49551c58ac7e23a54e880a5a48 100644 (file)
@@ -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<int> any(n, 0);
       vector<int> first(n, 0);
@@ -417,6 +422,8 @@ TEST_F(OSDMapTest, PrimaryAffinity) {
       vector<int> first(n, 0);
       vector<int> 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<n; ++i) {
        ASSERT_LT(0, any[i]);
        if (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]);
        }
       }
     }