]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/test: add dedup options (chunking algorithm, chunking size) to run dedup test
authormyoungwon oh <ohmyoungwon@gmail.com>
Thu, 4 Feb 2021 03:04:53 +0000 (12:04 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Mon, 29 Mar 2021 08:07:54 +0000 (17:07 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/test/osd/RadosModel.h
src/test/osd/TestRados.cc

index fc5d27daf8701586b0501a1f7a492723b1336fe5..4bde44f4c1730c9c353da4c8a4d0a42dedcef810 100644 (file)
@@ -197,6 +197,8 @@ public:
   int snapname_num;
   map<string,string > redirect_objs;
   bool enable_dedup;
+  string chunk_algo;
+  string chunk_size;
 
   RadosTestContext(const string &pool_name, 
                   int max_in_flight,
@@ -209,6 +211,8 @@ public:
                   bool write_fadvise_dontneed,
                   const string &low_tier_pool_name,
                   bool enable_dedup,
+                  string chunk_algo,
+                  string chunk_size,
                   const char *id = 0) :
     pool_obj_cont(),
     current_snap(0),
@@ -227,7 +231,9 @@ public:
     write_fadvise_dontneed(write_fadvise_dontneed),
     low_tier_pool_name(low_tier_pool_name),
     snapname_num(0),
-    enable_dedup(enable_dedup)
+    enable_dedup(enable_dedup),
+    chunk_algo(chunk_algo),
+    chunk_size(chunk_size)
   {
   }
 
@@ -285,7 +291,7 @@ public:
       }
       r = rados.mon_command(
        "{\"prefix\": \"osd pool set\", \"pool\": \"" + pool_name +
-       "\", \"var\": \"dedup_chunk_algorithm\", \"val\": \"" + "fastcdc" + "\"}",
+       "\", \"var\": \"dedup_chunk_algorithm\", \"val\": \"" + chunk_algo  + "\"}",
        inbl, NULL, NULL);
       if (r < 0) {
        rados.shutdown();
@@ -293,7 +299,7 @@ public:
       }
       r = rados.mon_command(
        "{\"prefix\": \"osd pool set\", \"pool\": \"" + pool_name +
-       "\", \"var\": \"dedup_cdc_chunk_size\", \"val\": \"" + "1024" + "\"}",
+       "\", \"var\": \"dedup_cdc_chunk_size\", \"val\": \"" + chunk_size + "\"}",
        inbl, NULL, NULL);
       if (r < 0) {
        rados.shutdown();
index d06bceafd822ca6b2c11a758856078edd4ef2204..9fb8c626d32594ceae680e134d5682acf9a4175c 100644 (file)
@@ -534,6 +534,13 @@ int main(int argc, char **argv)
     { TEST_OP_READ /* grr */, NULL },
   };
 
+  struct {
+    const char *name;
+  } chunk_algo_types[] = {
+    { "fastcdc" },
+    { "fixcdc" },
+  };
+
   map<TestOpType, unsigned int> op_weights;
   string pool_name = "rbd";
   string low_tier_pool_name = "";
@@ -545,6 +552,9 @@ int main(int argc, char **argv)
   bool set_redirect = false;
   bool set_chunk = false;
   bool enable_dedup = false;
+  string chunk_algo = "";
+  string chunk_size = "";
+
 
   for (int i = 1; i < argc; ++i) {
     if (strcmp(argv[i], "--max-ops") == 0)
@@ -629,6 +639,25 @@ int main(int argc, char **argv)
       low_tier_pool_name = argv[++i];
     } else if (strcmp(argv[i], "--enable_dedup") == 0) {
       enable_dedup = true;
+    } else if (strcmp(argv[i], "--dedup_chunk_algo") == 0) {
+      i++;
+      if (i == argc) {
+        cerr << "Missing chunking algorithm after --dedup_chunk_algo" << std::endl;
+        return 1;
+      }
+      int j;
+      for (j = 0; chunk_algo_types[j].name; ++j) {
+       if (strcmp(chunk_algo_types[j].name, argv[i]) == 0) {
+         break;
+       }
+      }
+      if (!chunk_algo_types[j].name) {
+       cerr << "unknown op " << argv[i] << std::endl;
+       exit(1);
+      }
+      chunk_algo = chunk_algo_types[j].name;
+    } else if (strcmp(argv[i], "--dedup_chunk_size") == 0) {
+      chunk_size = argv[++i];
     } else {
       cerr << "unknown arg " << argv[i] << std::endl;
       exit(1);
@@ -642,6 +671,14 @@ int main(int argc, char **argv)
     }
   }
 
+  if (enable_dedup) {
+    if (chunk_algo == "" || chunk_size == "") {
+      cerr << "Missing chunking algorithm: " << chunk_algo 
+          << " or chunking size: " << chunk_size << std::endl;
+      exit(1);
+    }
+  }
+
   if (op_weights.empty()) {
     cerr << "No operations specified" << std::endl;
     exit(1);
@@ -692,6 +729,8 @@ int main(int argc, char **argv)
     write_fadvise_dontneed,
     low_tier_pool_name,
     enable_dedup,
+    chunk_algo,
+    chunk_size,
     id);
 
   TestOpStat stats;