From 35dc2dea580234a7e3db62835bd0054d141994c5 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Thu, 26 Apr 2012 17:00:45 +0100 Subject: [PATCH] workload_generator: specify number of ops to run, or 0 to run forever. New option '--test-num-ops VAL' -- if (VAL == 0) then run forever; fi Signed-off-by: Joao Eduardo Luis --- src/test/filestore/workload_generator.cc | 42 +++++++++++++++++++++--- src/test/filestore/workload_generator.h | 1 + 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/test/filestore/workload_generator.cc b/src/test/filestore/workload_generator.cc index 4fb934b104c0d..c6d04e13c1d7f 100644 --- a/src/test/filestore/workload_generator.cc +++ b/src/test/filestore/workload_generator.cc @@ -36,6 +36,7 @@ boost::scoped_ptr wrkldgen; WorkloadGenerator::WorkloadGenerator(vector args) : TestFileStoreState(NULL), + m_num_ops(-1), m_destroy_coll_every_nr_runs(def_destroy_coll_every_nr_runs), m_nr_runs(0), m_num_colls(def_num_colls), @@ -83,6 +84,9 @@ void WorkloadGenerator::init_args(vector args) } else if (ceph_argparse_witharg(args, i, &val, "--test-destroy-coll-per-N-trans", (char*) NULL)) { m_destroy_coll_every_nr_runs = strtoll(val.c_str(), NULL, 10); + } else if (ceph_argparse_witharg(args, i, &val, + "--test-num-ops", (char*) NULL)) { + m_num_ops = strtoll(val.c_str(), NULL, 10); } else if (ceph_argparse_flag(args, i, "--help", (char*) NULL)) { usage(NULL); exit(0); @@ -224,8 +228,13 @@ TestFileStoreState::coll_entry_t void WorkloadGenerator::run() { + bool create_coll = false; + int ops_run = 0; do { - if (!m_collections.size()) { + if (m_num_ops && (ops_run == m_num_ops)) + break; + + if (!create_coll && !m_collections.size()) { dout(0) << "We ran out of collections!" << dendl; break; } @@ -234,14 +243,31 @@ void WorkloadGenerator::run() wait_for_ready(); ObjectStore::Transaction *t = new ObjectStore::Transaction; + Context *c; + bool destroy_collection = false; + TestFileStoreState::coll_entry_t *entry = NULL; - bool destroy_collection = should_destroy_collection(); - coll_entry_t *entry = get_rnd_coll_entry(destroy_collection); + if (create_coll) { + create_coll = false; + + entry = do_create_collection(t); + if (!entry) { + dout(0) << __func__ << " something went terribly wrong creating coll" << dendl; + break; + } + + c = new C_OnReadable(this, t); + goto queue_tx; + } + + destroy_collection = should_destroy_collection(); + entry = get_rnd_coll_entry(destroy_collection); - Context *c; if (destroy_collection) { do_destroy_collection(t, entry); c = new C_OnDestroyed(this, t, entry); + if (!m_num_ops) + create_coll = true; } else { hobject_t *obj = get_rnd_obj(entry); @@ -253,9 +279,13 @@ void WorkloadGenerator::run() c = new C_OnReadable(this, t); } +queue_tx: m_store->queue_transaction(&(entry->m_osr), t, c); m_in_flight++; m_lock.Unlock(); + + ops_run ++; + } while (true); wait_for_done(); @@ -284,7 +314,9 @@ Test-specific Options:\n\ --test-num-colls VAL Set the number of collections\n\ --test-num-objs-per-coll VAL Set the number of objects per collection\n\ --test-destroy-coll-per-N-trans VAL Set how many transactions to run before\n\ - destroying a collection.\ + destroying a collection.\n\ + --test-num-ops VAL Run a certain number of operations\n\ + (a VAL of 0 runs the test forever)\ " << std::endl; } diff --git a/src/test/filestore/workload_generator.h b/src/test/filestore/workload_generator.h index 143b4974c1284..1bbf8fb9836a1 100644 --- a/src/test/filestore/workload_generator.h +++ b/src/test/filestore/workload_generator.h @@ -43,6 +43,7 @@ public: static const size_t log_append_bytes = 1024; private: + int m_num_ops; int m_destroy_coll_every_nr_runs; int m_nr_runs; -- 2.39.5