Skip to content
Snippets Groups Projects
Commit 924fc721 authored by Irene Zhang's avatar Irene Zhang
Browse files

fixing some bugs and checking in new test cases for backend stores

parent 7876252a
No related branches found
No related tags found
No related merge requests found
......@@ -125,7 +125,7 @@ include lib/Rules.mk
include replication/common/Rules.mk
include replication/vr/Rules.mk
include store/common/Rules.mk
#include store/txnstore/Rules.mk
include store/txnstore/Rules.mk
include store/qwstore/Rules.mk
##################################################################
......
......@@ -11,8 +11,6 @@
using namespace std;
namespace spanstore {
LockServer::LockServer()
{
readers = 0;
......@@ -280,4 +278,3 @@ LockServer::releaseForWrite(const string &lock, uint64_t holder)
}
}
} // namespace spanstore
......@@ -42,8 +42,6 @@
#include <unordered_map>
#include <unordered_set>
namespace spanstore {
#define LOCK_WAIT_TIMEOUT 5000
class LockServer
......@@ -100,6 +98,4 @@ private:
uint64_t writers;
};
} // namespace spanstore
#endif /* _LOCK_SERVER_H_ */
......@@ -4,7 +4,9 @@ d := $(dir $(lastword $(MAKEFILE_LIST)))
# gtest-based tests
#
GTEST_SRCS += $(addprefix $(d), \
kvstore-test.cc, versionstore-test.cc, lockserver-test.cc)
kvstore-test.cc \
versionstore-test.cc \
lockserver-test.cc)
$(d)kvstore-test: $(o)kvstore-test.o $(LIB-transport) $(LIB-common) $(LIB-backend) $(GTEST_MAIN)
......
......@@ -28,7 +28,7 @@
*
**********************************************************************/
#include "store/common/backend/versionstore.h"
#include "store/common/backend/lockserver.h"
#include <gtest/gtest.h>
......@@ -36,16 +36,16 @@ TEST(LockServer, ReadLock)
{
LockServer s;
EXPECT_TRUE(s.LockForRead("x", 1));
EXPECT_TRUE(s.LockForRead("x", 2));
EXPECT_FALSE(s.LockForWrite("x", 3));
EXPECT_TRUE(s.lockForRead("x", 1));
EXPECT_TRUE(s.lockForRead("x", 2));
EXPECT_FALSE(s.lockForWrite("x", 3));
}
TEST(LockServer, WriteLock)
{
LockServer s;
EXPECT_TRUE(s.LockForWrite("x", 1));
EXPECT_FALSE(s.LockForRead("x", 2));
EXPECT_FALSE(s.LockForWrite("x", 3));
EXPECT_TRUE(s.lockForWrite("x", 1));
EXPECT_FALSE(s.lockForRead("x", 2));
EXPECT_FALSE(s.lockForWrite("x", 3));
}
......@@ -32,53 +32,26 @@
#include <gtest/gtest.h>
TEST(VersionedKVStore, Put)
{
VersionedKVStore store;
EXPECT_TRUE(store.put("test1", "abc"));
EXPECT_TRUE(store.put("test2", "def"));
EXPECT_TRUE(store.put("test1", "xyz"));
EXPECT_TRUE(store.put("test3", "abc"));
}
TEST(VersionedKVStore, Get)
{
VersionedKVStore store;
pair<Timestamp, std::string> val;
std::pair<Timestamp, std::string> val;
EXPECT_TRUE(store.put("test1", "abc"));
store.put("test1", "abc", Timestamp(10));
EXPECT_TRUE(store.get("test1", val));
EXPECT_EQ(val[1], "abc");
EXPECT_EQ(val.second, "abc");
EXPECT_EQ(Timestamp(10), val.first);
EXPECT_TRUE(store.put("test2", "def"));
store.put("test2", "def", Timestamp(10));
EXPECT_TRUE(store.get("test2", val));
EXPECT_EQ(val[1], "def");
EXPECT_EQ(val.second, "def");
EXPECT_EQ(Timestamp(10), val.first);
EXPECT_TRUE(store.put("test1", "xyz"));
store.put("test1", "xyz", Timestamp(11));
EXPECT_TRUE(store.get("test1", val));
EXPECT_EQ(val[1], "xyz");
}
TEST(VersionedKVStore, VersionedGet)
{
VersionedKVStore store;
Timestamp time;
Timestamp time2;
std::string val;
EXPECT_TRUE(store.put("test1", "abc", time));
EXPECT_TRUE(store.get("test1", val, time));
EXPECT_EQ(val, "abc");
EXPECT_TRUE(store.put("test2", "def", time2));
EXPECT_TRUE(store.get("test2", val, time2));
EXPECT_EQ(val, "def");
EXPECT_TRUE(store.put("test1", "xyz", time2));
EXPECT_TRUE(store.get("test1", val, time2));
EXPECT_EQ(val, "xyz");
EXPECT_EQ(val.second, "xyz");
EXPECT_EQ(Timestamp(11), val.first);
EXPECT_TRUE(store.get("test1", val, time));
EXPECT_EQ(val, "abc");
EXPECT_TRUE(store.get("test1", Timestamp(10), val));
EXPECT_EQ(val.second, "abc");
}
......@@ -4,7 +4,7 @@ SRCS += $(addprefix $(d), \
client.cc spanclient.cc lockserver.cc \
occstore.cc lockstore.cc server.cc)
PROTOS += $(addprefix $(d), span-proto.proto)
PROTOS += $(addprefix $(d), txn-proto.proto)
OBJS-span-store := $(LIB-message) $(LIB-store) $(LIB-common) $(o)server.o \
$(o)occstore.o $(o)lockstore.o $(o)lockserver.o $(o)span-proto.o
......
import "../common/common-proto.proto";
import "store/common/common-proto.proto";
package spanstore.proto;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment