diff options
author | Babu Shanmugam <anbu@enovance.com> | 2013-06-18 16:06:36 +0530 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-06-20 13:38:47 -0700 |
commit | 0deb6d4093d20e8783f012cf91f87604081e0e57 (patch) | |
tree | fd40e8453da8d02b403ead5618cd7d857a217a2a | |
parent | 3b4c11b2d9edb00acde419da3f5707b1a85c8283 (diff) | |
download | ceph-0deb6d4093d20e8783f012cf91f87604081e0e57.tar.gz |
rgw: lock related modificationswip-rgw-geo-enovance
1. zone-id inclusion in lock/unlock for mdlog and datalog
2. renewal of lock if the locker request lock again
3. modified lock_id param to locker-id
Signed-off-by: Babu Shanmugam <anbu@enovance.com>
Conflicts:
src/rgw/rgw_rest_log.cc
-rw-r--r-- | src/rgw/rgw_bucket.h | 8 | ||||
-rw-r--r-- | src/rgw/rgw_metadata.cc | 14 | ||||
-rw-r--r-- | src/rgw/rgw_metadata.h | 4 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 8 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 4 | ||||
-rw-r--r-- | src/rgw/rgw_rest_log.cc | 54 | ||||
-rw-r--r-- | src/test/test_rgw_admin_log.cc | 108 |
7 files changed, 118 insertions, 82 deletions
diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 4431c77f97e..f4ff4ec15cc 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -344,11 +344,11 @@ public: list<rgw_data_change>& entries, string& marker, bool *truncated); int trim_entries(int shard_id, utime_t& start_time, utime_t& end_time); int trim_entries(utime_t& start_time, utime_t& end_time); - int lock_exclusive(int shard_id, utime_t& duration, string& owner_id) { - return store->lock_exclusive(store->zone.log_pool, oids[shard_id], duration, owner_id); + int lock_exclusive(int shard_id, utime_t& duration, string& zone_id, string& owner_id) { + return store->lock_exclusive(store->zone.log_pool, oids[shard_id], duration, zone_id, owner_id); } - int unlock(int shard_id, string& owner_id) { - return store->unlock(store->zone.log_pool, oids[shard_id], owner_id); + int unlock(int shard_id, string& zone_id, string& owner_id) { + return store->unlock(store->zone.log_pool, oids[shard_id], zone_id, owner_id); } struct LogMarker { int shard; diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index 6e0d4b3b632..6242806ef4d 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -136,18 +136,18 @@ int RGWMetadataLog::trim(int shard_id, utime_t& from_time, utime_t& end_time) return ret; } -int RGWMetadataLog::lock_exclusive(int shard_id, utime_t& duration, string& owner_id) { +int RGWMetadataLog::lock_exclusive(int shard_id, utime_t& duration, string& zone_id, string& owner_id) { string oid; get_shard_oid(shard_id, oid); - return store->lock_exclusive(store->zone.log_pool, oid, duration, owner_id); + return store->lock_exclusive(store->zone.log_pool, oid, duration, zone_id, owner_id); } -int RGWMetadataLog::unlock(int shard_id, string& owner_id) { +int RGWMetadataLog::unlock(int shard_id, string& zone_id, string& owner_id) { string oid; get_shard_oid(shard_id, oid); - return store->unlock(store->zone.log_pool, oid, owner_id); + return store->unlock(store->zone.log_pool, oid, zone_id, owner_id); } obj_version& RGWMetadataObject::get_version() @@ -359,6 +359,7 @@ int RGWMetadataManager::remove(string& metadata_key) int RGWMetadataManager::lock_exclusive(string& metadata_key, utime_t duration, string& owner_id) { RGWMetadataHandler *handler; string entry; + string zone_id; int ret = find_handler(metadata_key, &handler, entry); if (ret < 0) @@ -369,13 +370,14 @@ int RGWMetadataManager::lock_exclusive(string& metadata_key, utime_t duration, s handler->get_pool_and_oid(store, entry, pool, oid); - return store->lock_exclusive(pool, oid, duration, owner_id); + return store->lock_exclusive(pool, oid, duration, zone_id, owner_id); } int RGWMetadataManager::unlock(string& metadata_key, string& owner_id) { librados::IoCtx io_ctx; RGWMetadataHandler *handler; string entry; + string zone_id; int ret = find_handler(metadata_key, &handler, entry); if (ret < 0) @@ -386,7 +388,7 @@ int RGWMetadataManager::unlock(string& metadata_key, string& owner_id) { handler->get_pool_and_oid(store, entry, pool, oid); - return store->unlock(pool, oid, owner_id); + return store->unlock(pool, oid, zone_id, owner_id); } struct list_keys_handle { diff --git a/src/rgw/rgw_metadata.h b/src/rgw/rgw_metadata.h index 5f0fafefc5f..ba12decdd41 100644 --- a/src/rgw/rgw_metadata.h +++ b/src/rgw/rgw_metadata.h @@ -98,8 +98,8 @@ public: list<cls_log_entry>& entries, bool *truncated); int trim(int shard_id, utime_t& from_time, utime_t& end_time); - int lock_exclusive(int shard_id, utime_t& duration, string& owner_id); - int unlock(int shard_id, string& owner_id); + int lock_exclusive(int shard_id, utime_t& duration, string&zone_id, string& owner_id); + int unlock(int shard_id, string& zone_id, string& owner_id); }; class RGWMetadataLogData; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 9a485600b6d..055e7ad0283 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1481,7 +1481,8 @@ int RGWRados::time_log_trim(const string& oid, utime_t& start_time, utime_t& end } -int RGWRados::lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& duration, string& owner_id) { +int RGWRados::lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& duration, + string& zone_id, string& owner_id) { librados::IoCtx io_ctx; const char *pool_name = pool.name.c_str(); @@ -1493,11 +1494,13 @@ int RGWRados::lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& durat rados::cls::lock::Lock l(log_lock_name); l.set_duration(duration); l.set_cookie(owner_id); + l.set_tag(zone_id); + l.set_renew(true); return l.lock_exclusive(&io_ctx, oid); } -int RGWRados::unlock(rgw_bucket& pool, const string& oid, string& owner_id) { +int RGWRados::unlock(rgw_bucket& pool, const string& oid, string& zone_id, string& owner_id) { librados::IoCtx io_ctx; const char *pool_name = pool.name.c_str(); @@ -1507,6 +1510,7 @@ int RGWRados::unlock(rgw_bucket& pool, const string& oid, string& owner_id) { return r; rados::cls::lock::Lock l(log_lock_name); + l.set_tag(zone_id); l.set_cookie(owner_id); return l.unlock(&io_ctx, oid); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 7e08d8016c0..9c43f001452 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1213,8 +1213,8 @@ public: int time_log_list(const string& oid, utime_t& start_time, utime_t& end_time, int max_entries, list<cls_log_entry>& entries, string& marker, bool *truncated); int time_log_trim(const string& oid, utime_t& start_time, utime_t& end_time); - int lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& duration, string& owner_id); - int unlock(rgw_bucket& pool, const string& oid, string& owner_id); + int lock_exclusive(rgw_bucket& pool, const string& oid, utime_t& duration, string& zone_id, string& owner_id); + int unlock(rgw_bucket& pool, const string& oid, string& zone_id, string& owner_id); /// clean up/process any temporary objects older than given date[/time] int remove_temp_objects(string date, string time); diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index f066b6b4b04..43bb84fc763 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -46,7 +46,7 @@ void RGWOp_MDLog_List::execute() { utime_t ut_st, ut_et; void *handle; - unsigned shard_id, max_entries = 0; + unsigned shard_id, max_entries = LOG_CLASS_LIST_MAX_ENTRIES; shard_id = (unsigned)strict_strtol(shard.c_str(), 10, &err); if (!err.empty()) { @@ -72,9 +72,8 @@ void RGWOp_MDLog_List::execute() { http_ret = -EINVAL; return; } - } else - max_entries = LOG_CLASS_LIST_MAX_ENTRIES; - + } + RGWMetadataLog *meta_log = store->meta_mgr->get_log(); meta_log->init_list_entries(shard_id, ut_st, ut_et, marker, &handle); @@ -162,18 +161,20 @@ void RGWOp_MDLog_Delete::execute() { } void RGWOp_MDLog_Lock::execute() { - string shard_id_str, duration_str, lock_id; + string shard_id_str, duration_str, locker_id, zone_id; unsigned shard_id; http_ret = 0; shard_id_str = s->info.args.get("id"); duration_str = s->info.args.get("length"); - lock_id = s->info.args.get("lock_id"); + locker_id = s->info.args.get("locker-id"); + zone_id = s->info.args.get("zone-id"); if (shard_id_str.empty() || (duration_str.empty()) || - lock_id.empty()) { + locker_id.empty() || + zone_id.empty()) { dout(5) << "Error invalid parameter list" << dendl; http_ret = -EINVAL; return; @@ -196,20 +197,22 @@ void RGWOp_MDLog_Lock::execute() { return; } utime_t time(dur, 0); - http_ret = meta_log->lock_exclusive(shard_id, time, lock_id); + http_ret = meta_log->lock_exclusive(shard_id, time, zone_id, locker_id); } void RGWOp_MDLog_Unlock::execute() { - string shard_id_str, lock_id; + string shard_id_str, locker_id, zone_id; unsigned shard_id; http_ret = 0; shard_id_str = s->info.args.get("id"); - lock_id = s->info.args.get("lock_id"); + locker_id = s->info.args.get("locker-id"); + zone_id = s->info.args.get("zone-id"); if (shard_id_str.empty() || - lock_id.empty()) { + locker_id.empty() || + zone_id.empty()) { dout(5) << "Error invalid parameter list" << dendl; http_ret = -EINVAL; return; @@ -224,7 +227,7 @@ void RGWOp_MDLog_Unlock::execute() { } RGWMetadataLog *meta_log = store->meta_mgr->get_log(); - http_ret = meta_log->unlock(shard_id, lock_id); + http_ret = meta_log->unlock(shard_id, zone_id, locker_id); } void RGWOp_BILog_List::execute() { @@ -341,7 +344,7 @@ void RGWOp_DATALog_List::execute() { err; utime_t ut_st, ut_et; - unsigned shard_id, max_entries = 0; + unsigned shard_id, max_entries = LOG_CLASS_LIST_MAX_ENTRIES; shard_id = (unsigned)strict_strtol(shard.c_str(), 10, &err); if (!err.empty()) { @@ -367,9 +370,8 @@ void RGWOp_DATALog_List::execute() { http_ret = -EINVAL; return; } - } else - max_entries = LOG_CLASS_LIST_MAX_ENTRIES; - + } + bool truncated; do { http_ret = store->data_log->list_entries(shard_id, ut_st, ut_et, @@ -419,18 +421,20 @@ void RGWOp_DATALog_GetShardsInfo::send_response() { } void RGWOp_DATALog_Lock::execute() { - string shard_id_str, duration_str, lock_id; + string shard_id_str, duration_str, locker_id, zone_id; unsigned shard_id; http_ret = 0; shard_id_str = s->info.args.get("id"); duration_str = s->info.args.get("length"); - lock_id = s->info.args.get("lock_id"); + locker_id = s->info.args.get("locker-id"); + zone_id = s->info.args.get("zone-id"); if (shard_id_str.empty() || (duration_str.empty()) || - lock_id.empty()) { + locker_id.empty() || + zone_id.empty()) { dout(5) << "Error invalid parameter list" << dendl; http_ret = -EINVAL; return; @@ -452,20 +456,22 @@ void RGWOp_DATALog_Lock::execute() { return; } utime_t time(dur, 0); - http_ret = store->data_log->lock_exclusive(shard_id, time, lock_id); + http_ret = store->data_log->lock_exclusive(shard_id, time, zone_id, locker_id); } void RGWOp_DATALog_Unlock::execute() { - string shard_id_str, lock_id; + string shard_id_str, locker_id, zone_id; unsigned shard_id; http_ret = 0; shard_id_str = s->info.args.get("id"); - lock_id = s->info.args.get("lock_id"); + locker_id = s->info.args.get("locker-id"); + zone_id = s->info.args.get("zone-id"); if (shard_id_str.empty() || - lock_id.empty()) { + locker_id.empty() || + zone_id.empty()) { dout(5) << "Error invalid parameter list" << dendl; http_ret = -EINVAL; return; @@ -479,7 +485,7 @@ void RGWOp_DATALog_Unlock::execute() { return; } - http_ret = store->data_log->unlock(shard_id, lock_id); + http_ret = store->data_log->unlock(shard_id, zone_id, locker_id); } void RGWOp_DATALog_Delete::execute() { diff --git a/src/test/test_rgw_admin_log.cc b/src/test/test_rgw_admin_log.cc index 3ce853ab67e..7c419e7d3c4 100644 --- a/src/test/test_rgw_admin_log.cc +++ b/src/test/test_rgw_admin_log.cc @@ -847,92 +847,104 @@ TEST(TestRGWAdmin, datalog_lock_unlock) { ASSERT_EQ(0, user_create(uid, display_name)); ASSERT_EQ(0, caps_add(cname, perm)); - rest_req = "/admin/log?type=data&lock&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=data&lock&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=data&lock&id=3&lock_id=ceph"; + rest_req = "/admin/log?type=data&lock&id=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=data&lock&length=3&id=1"; + rest_req = "/admin/log?type=data&lock&length=3&id=1&zone-id=1"; + g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); + EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ + + rest_req = "/admin/log?type=data&lock&length=3&id=1&locker-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=data&unlock&id=1"; + rest_req = "/admin/log?type=data&unlock&id=1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=data&unlock&lock_id=ceph"; + rest_req = "/admin/log?type=data&unlock&locker-id=ceph&zone-id=1"; + g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); + EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ + + rest_req = "/admin/log?type=data&unlock&locker-id=ceph&id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&unlock&id=1&lock_id=ceph"; + rest_req = "/admin/log?type=data&unlock&id=1&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph1"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&unlock&id=1&lock_id=ceph1"; + rest_req = "/admin/log?type=data&unlock&id=1&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); utime_t sleep_time(3, 0); - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph1"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(500U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph1&zone-id=2"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); - EXPECT_EQ(409U, g_test->get_resp_code()); + EXPECT_EQ(500U, g_test->get_resp_code()); + + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph&zone-id=1"; + g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); + EXPECT_EQ(200U, g_test->get_resp_code()); sleep_time.sleep(); - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph1"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&unlock&id=1&lock_id=ceph1"; + rest_req = "/admin/log?type=data&unlock&id=1&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); ASSERT_EQ(0, caps_rm(cname, perm)); perm = "read"; ASSERT_EQ(0, caps_add(cname, perm)); - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(403U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&unlock&id=1&lock_id=ceph"; + rest_req = "/admin/log?type=data&unlock&id=1&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(403U, g_test->get_resp_code()); ASSERT_EQ(0, caps_rm(cname, perm)); perm = "write"; ASSERT_EQ(0, caps_add(cname, perm)); - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&unlock&id=1&lock_id=ceph"; + rest_req = "/admin/log?type=data&unlock&id=1&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); ASSERT_EQ(0, caps_rm(cname, perm)); - rest_req = "/admin/log?type=data&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=data&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(403U, g_test->get_resp_code()); - rest_req = "/admin/log?type=data&unlock&id=1&lock_id=ceph"; + rest_req = "/admin/log?type=data&unlock&id=1&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(403U, g_test->get_resp_code()); @@ -1276,92 +1288,104 @@ TEST(TestRGWAdmin, mdlog_lock_unlock) { ASSERT_EQ(0, user_create(uid, display_name)); ASSERT_EQ(0, caps_add(cname, perm)); - rest_req = "/admin/log?type=metadata&lock&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&lock&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=metadata&lock&id=3&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&lock&id=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=metadata&lock&length=3&id=1"; + rest_req = "/admin/log?type=metadata&lock&length=3&id=1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=metadata&unlock&id=1"; + rest_req = "/admin/log?type=metadata&lock&id=3&locker-id=ceph&length=1"; + g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); + EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ + + rest_req = "/admin/log?type=metadata&unlock&id=1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=metadata&unlock&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&unlock&locker-id=ceph&zone-id=1"; + g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); + EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ + + rest_req = "/admin/log?type=metadata&unlock&locker-id=ceph&id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(400U, g_test->get_resp_code()); /*Bad request*/ - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&unlock&id=1&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&unlock&id=1&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph1"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&unlock&id=1&lock_id=ceph1"; + rest_req = "/admin/log?type=metadata&unlock&id=1&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); utime_t sleep_time(3, 0); - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph1"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(500U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph&zone-id=2"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); - EXPECT_EQ(409U, g_test->get_resp_code()); + EXPECT_EQ(500U, g_test->get_resp_code()); + + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph&zone-id=1"; + g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); + EXPECT_EQ(200U, g_test->get_resp_code()); sleep_time.sleep(); - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph1"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&unlock&id=1&lock_id=ceph1"; + rest_req = "/admin/log?type=metadata&unlock&id=1&locker-id=ceph1&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); ASSERT_EQ(0, caps_rm(cname, perm)); perm = "read"; ASSERT_EQ(0, caps_add(cname, perm)); - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(403U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&unlock&id=1&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&unlock&id=1&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(403U, g_test->get_resp_code()); ASSERT_EQ(0, caps_rm(cname, perm)); perm = "write"; ASSERT_EQ(0, caps_add(cname, perm)); - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&unlock&id=1&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&unlock&id=1&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(200U, g_test->get_resp_code()); ASSERT_EQ(0, caps_rm(cname, perm)); - rest_req = "/admin/log?type=metadata&lock&id=1&length=3&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&lock&id=1&length=3&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(403U, g_test->get_resp_code()); - rest_req = "/admin/log?type=metadata&unlock&id=1&lock_id=ceph"; + rest_req = "/admin/log?type=metadata&unlock&id=1&locker-id=ceph&zone-id=1"; g_test->send_request(string("POST"), rest_req, read_dummy_post, NULL, sizeof(int)); EXPECT_EQ(403U, g_test->get_resp_code()); |