Skip to content

Commit

Permalink
Merge pull request ceph#60812 from pecastro/improve-a-few-tests
Browse files Browse the repository at this point in the history
tests: Improve unittest_dbstore_tests and unittest_deferred to be suitable for reruns.

Reviewed-by: Soumya Koduri <[email protected]>
  • Loading branch information
cbodley authored Dec 6, 2024
2 parents a204f98 + 73109c1 commit 99f58a5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
7 changes: 3 additions & 4 deletions src/rgw/driver/dbstore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Standalone Rados Gateway (RGW) on DBStore (Experimental)
## CMake Option
Add below cmake option (enabled by default)

-DWITH_RADOSGW_DBSTORE=ON
-DWITH_RADOSGW_DBSTORE=ON


## Build
Expand Down Expand Up @@ -40,8 +40,8 @@ The location and prefix for the database files can be configured using the follo
To execute DBStore unit test cases (using Gtest framework), from build directory

ninja unittest_dbstore_tests
./bin/unittest_dbstore_tests [logfile] [loglevel]
(default logfile: rgw_dbstore_tests.log, loglevel: 20)
./bin/unittest_dbstore_tests [logfile] [loglevel] [tenantname]
(default logfile: rgw_dbstore_tests.log, loglevel: 20, default_ns_<timestamp_at_time_of_run>)
ninja unittest_dbstore_mgr_tests
./bin/unittest_dbstore_mgr_tests

Expand All @@ -50,4 +50,3 @@ To execute Sample test file
ninja src/rgw/driver/dbstore/install
./bin/dbstore-bin [logfile] [loglevel]
(default logfile: rgw_dbstore_bin.log, loglevel: 20)

31 changes: 17 additions & 14 deletions src/rgw/driver/dbstore/tests/dbstore_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace gtest {
Environment(): tenant("default_ns"), db(nullptr),
db_type("SQLite"), ret(-1) {}

Environment(string tenantname, string db_typename):
Environment(string tenantname, string db_typename):
tenant(tenantname), db(nullptr),
db_type(db_typename), ret(-1) {}

Expand Down Expand Up @@ -153,8 +153,8 @@ TEST_F(DBStoreTest, InsertUser) {
RGWAccessKey k2("id2", "key2");
params.op.user.uinfo.access_keys["id1"] = k1;
params.op.user.uinfo.access_keys["id2"] = k2;
params.op.user.user_version.ver = 1;
params.op.user.user_version.tag = "UserTAG";
params.op.user.user_version.ver = 1;
params.op.user.user_version.tag = "UserTAG";

ret = db->ProcessOp(dpp, "InsertUser", &params);
ASSERT_EQ(ret, 0);
Expand Down Expand Up @@ -841,7 +841,7 @@ TEST_F(DBStoreTest, IterateObject) {
TEST_F(DBStoreTest, ListBucketObjects) {
struct DBOpParams params = GlobalParams;
int ret = -1;

int max = 2;
bool is_truncated = false;
rgw_obj_key marker1;
Expand Down Expand Up @@ -1032,7 +1032,7 @@ TEST_F(DBStoreTest, DeleteVersionedObject) {
true, &s);
ASSERT_EQ(ret, -ENOENT);

/* Delete delete marker..should be able to read object now */
/* Delete delete marker..should be able to read object now */
params.op.obj.state.obj.key.instance = dm_instance;
DB::Object op_target3(db, params.op.bucket.info, params.op.obj.state.obj);
DB::Object::Delete delete_op2(&op_target3);
Expand Down Expand Up @@ -1307,13 +1307,13 @@ TEST_F(DBStoreTest, LCEntry) {
ASSERT_EQ(ret, 0);

// get entry index1, entry1
ret = db->get_entry(index1, ents[0], entry);
ret = db->get_entry(index1, ents[0], entry);
ASSERT_EQ(ret, 0);
ASSERT_EQ(entry.status, lc_uninitial);
ASSERT_EQ(entry.start_time, lc_time);

// get next entry index1, entry2
ret = db->get_next_entry(index1, ents[1], entry);
ret = db->get_next_entry(index1, ents[1], entry);
ASSERT_EQ(ret, 0);
ASSERT_EQ(entry.bucket, ents[2]);
ASSERT_EQ(entry.status, lc_uninitial);
Expand All @@ -1323,7 +1323,7 @@ TEST_F(DBStoreTest, LCEntry) {
entry4.status = lc_complete;
ret = db->set_entry(index2, entry4);
ASSERT_EQ(ret, 0);
ret = db->get_entry(index2, ents[3], entry);
ret = db->get_entry(index2, ents[3], entry);
ASSERT_EQ(ret, 0);
ASSERT_EQ(entry.status, lc_complete);

Expand All @@ -1337,7 +1337,7 @@ TEST_F(DBStoreTest, LCEntry) {
}

// remove index1, entry3
ret = db->rm_entry(index1, entry3);
ret = db->rm_entry(index1, entry3);
ASSERT_EQ(ret, 0);

// get next entry index1, entry2.. should be empty
Expand Down Expand Up @@ -1373,8 +1373,8 @@ TEST_F(DBStoreTest, InsertTestIDUser) {
params.op.user.uinfo.user_email = "[email protected]";
RGWAccessKey k1("0555b35654ad1656d804", "h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q==");
params.op.user.uinfo.access_keys["0555b35654ad1656d804"] = k1;
params.op.user.user_version.ver = 1;
params.op.user.user_version.tag = "UserTAG";
params.op.user.user_version.ver = 1;
params.op.user.user_version.tag = "UserTAG";

ret = db->ProcessOp(dpp, "InsertUser", &params);
ASSERT_EQ(ret, 0);
Expand All @@ -1385,19 +1385,22 @@ int main(int argc, char **argv)
int ret = -1;
string c_logfile = "rgw_dbstore_tests.log";
int c_loglevel = 20;
string c_tenant = "default_ns_" + std::to_string(time(NULL));

// format: ./dbstore-tests logfile loglevel
if (argc == 3) {
// format: ./dbstore-tests logfile loglevel tenantname
if (argc == 4) {
c_logfile = argv[1];
c_loglevel = (atoi)(argv[2]);
cout << "logfile:" << c_logfile << ", loglevel set to " << c_loglevel << "\n";
c_tenant = argv[3];
cout << "logfile:" << c_logfile << ", loglevel set to " << c_loglevel << ", db is " << c_tenant << "\n";
}

::testing::InitGoogleTest(&argc, argv);

gtest::env = new gtest::Environment();
gtest::env->logfile = c_logfile;
gtest::env->loglevel = c_loglevel;
gtest::env->tenant = c_tenant;
::testing::AddGlobalTestEnvironment(gtest::env);

ret = RUN_ALL_TESTS();
Expand Down
6 changes: 4 additions & 2 deletions src/test/objectstore/test_deferred.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// vim: ts=8 sw=2 smarttab

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory>
Expand Down Expand Up @@ -44,10 +45,11 @@ void create_deferred_and_terminate() {
coll_t cid;
ghobject_t hoid;
ObjectStore::CollectionHandle ch;
ceph_assert(::mkdir("bluestore.test_temp_dir", 0777) == 0);
std::string const db_store_dir = "bluestore.test_temp_dir_" + std::to_string(time(NULL));
ceph_assert(::mkdir(db_store_dir.c_str(), 0777) == 0);
store = ObjectStore::create(g_ceph_context,
"bluestore",
"bluestore.test_temp_dir",
db_store_dir.c_str(),
"store_test_temp_journal");
ceph_assert(store->mkfs() == 0);
ceph_assert(store->mount() == 0);
Expand Down

0 comments on commit 99f58a5

Please sign in to comment.