diff options
author | Sage Weil <sage@inktank.com> | 2013-07-18 23:06:41 +0200 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-07-18 23:08:41 +0200 |
commit | 921a4aac8a89850303233fe188998202e0ddfe0d (patch) | |
tree | ac91f44fba00b4dba4af88dfce4d5cb236502f56 /src/test/cls_lock | |
parent | mds: tracedn should be NULL for LOOKUPINO/LOOKUPHASH reply (diff) | |
download | ceph-921a4aac8a89850303233fe188998202e0ddfe0d.tar.xz ceph-921a4aac8a89850303233fe188998202e0ddfe0d.zip |
cls_lock: fix duration test
It's possible for us to just be really slow when getting the reply to the
first op or doing the second op, resulting in a successful lock. If we
do get a success, assert that at least that amount of time has passed to
avoid any false positives.
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Diffstat (limited to 'src/test/cls_lock')
-rw-r--r-- | src/test/cls_lock/test_cls_lock.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/test/cls_lock/test_cls_lock.cc b/src/test/cls_lock/test_cls_lock.cc index 39d3cebde10..ead03bb2183 100644 --- a/src/test/cls_lock/test_cls_lock.cc +++ b/src/test/cls_lock/test_cls_lock.cc @@ -16,6 +16,7 @@ #include <errno.h> #include "include/types.h" +#include "common/Clock.h" #include "msg/msg_types.h" #include "include/rados/librados.hpp" @@ -280,11 +281,19 @@ TEST(ClsLock, TestLockDuration) { string oid = "foo"; Lock l("lock"); - l.set_duration(utime_t(5, 0)); + utime_t dur(5, 0); + l.set_duration(dur); + utime_t start = ceph_clock_now(NULL); ASSERT_EQ(0, l.lock_exclusive(&ioctx, oid)); - ASSERT_EQ(-EEXIST, l.lock_exclusive(&ioctx, oid)); + int r = l.lock_exclusive(&ioctx, oid); + if (r == 0) { + // it's possible to get success if we were just really slow... + ASSERT_TRUE(ceph_clock_now(NULL) > start + dur); + } else { + ASSERT_EQ(-EEXIST, r); + } - sleep(5); + sleep(dur.sec()); ASSERT_EQ(0, l.lock_exclusive(&ioctx, oid)); ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster)); |