From 439ce945dde196a4439e4468681e35eadd4fca5f Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 31 May 2016 16:18:19 -0700 Subject: [PATCH] hammer: test: split objectcacher test into 'stress' and 'correctness' Signed-off-by: Greg Farnum (cherry picked from commit cc9aab1b0a22c3f7320046b97f75dccf2b86cc6d) --- qa/workunits/osdc/stress_objectcacher.sh | 4 ++- src/test/osdc/object_cacher_stress.cc | 34 ++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/qa/workunits/osdc/stress_objectcacher.sh b/qa/workunits/osdc/stress_objectcacher.sh index e6b9ec121ea8d..67baadc3317c4 100755 --- a/qa/workunits/osdc/stress_objectcacher.sh +++ b/qa/workunits/osdc/stress_objectcacher.sh @@ -14,7 +14,7 @@ do do for MAX_DIRTY in 0 25165824 do - ceph_test_objectcacher_stress --ops $OPS --percent-read $READS --delay-ns $DELAY --objects $OBJECTS --max-op-size $OP_SIZE --client-oc-max-dirty $MAX_DIRTY > /dev/null 2>&1 + ceph_test_objectcacher_stress --ops $OPS --percent-read $READS --delay-ns $DELAY --objects $OBJECTS --max-op-size $OP_SIZE --client-oc-max-dirty $MAX_DIRTY --stress-test > /dev/null 2>&1 done done done @@ -23,4 +23,6 @@ do done done +ceph_test_objectcacher_stress --correctness-test > /dev/null 2>&1 + echo OK diff --git a/src/test/osdc/object_cacher_stress.cc b/src/test/osdc/object_cacher_stress.cc index ec5f926082743..58c0019a82c2f 100644 --- a/src/test/osdc/object_cacher_stress.cc +++ b/src/test/osdc/object_cacher_stress.cc @@ -21,6 +21,7 @@ #include "osdc/ObjectCacher.h" #include "FakeWriteback.h" +#include "MemWriteback.h" // XXX: Only tests default namespace struct op_data { @@ -170,6 +171,24 @@ int stress_test(uint64_t num_ops, uint64_t num_objs, return EXIT_SUCCESS; } +int correctness_test(uint64_t delay_ns) +{ + Mutex lock("object_cacher_stress::object_cacher"); + MemWriteback writeback(g_ceph_context, &lock, delay_ns); + + ObjectCacher obc(g_ceph_context, "test", writeback, lock, NULL, NULL, + g_conf->client_oc_size, + g_conf->client_oc_max_objects, + g_conf->client_oc_max_dirty, + g_conf->client_oc_target_dirty, + g_conf->client_oc_max_dirty_age, + true); + obc.start(); + + std::cout << "Testing ObjectCacher correctness" << std::endl; + return 0; +} + int main(int argc, const char **argv) { std::vector args; @@ -184,6 +203,8 @@ int main(int argc, const char **argv) long long num_objs = 10; float percent_reads = 0.90; int seed = time(0) % 100000; + bool stress = false; + bool correctness = false; std::ostringstream err; std::vector::iterator i; for (i = args.begin(); i != args.end();) { @@ -222,12 +243,21 @@ int main(int argc, const char **argv) cerr << argv[0] << ": " << err.str() << std::endl; return EXIT_FAILURE; } + } else if (ceph_argparse_flag(args, i, "--stress-test", NULL)) { + stress = true; + } else if (ceph_argparse_flag(args, i, "--correctness-test", NULL)) { + correctness = true; } else { cerr << "unknown option " << *i << std::endl; return EXIT_FAILURE; } } - srandom(seed); - return stress_test(num_ops, num_objs, obj_bytes, delay_ns, max_len, percent_reads); + if (stress) { + srandom(seed); + return stress_test(num_ops, num_objs, obj_bytes, delay_ns, max_len, percent_reads); + } + if (correctness) { + return correctness_test(delay_ns); + } } -- 2.39.5