Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Fix tests.

kishorencc982335bddc4
diff --git a/include/store.h b/include/store.h
index 609ec7d0..0df94024 100644
--- a/include/store.h
+++ b/include/store.h
@@ -54,7 +54,7 @@ public:
Store(const std::string & state_dir_path,
const size_t wal_ttl_secs = 24*60*60,
- const size_t wal_size_mb = 1024): state_dir_path(state_dir_path) {
+ const size_t wal_size_mb = 1024, bool disable_wal = true): state_dir_path(state_dir_path) {
// Optimize RocksDB
options.IncreaseParallelism();
options.OptimizeLevelStyleCompaction();
@@ -71,7 +71,7 @@ public:
// Disable WAL for master writes (Raft's WAL is used)
// The replica uses native WAL, though.
- write_options.disableWAL = true;
+ write_options.disableWAL = disable_wal;
// open DB
rocksdb::Status s = rocksdb::DB::Open(options, state_dir_path, &db);
diff --git a/src/main/benchmark.cpp b/src/main/benchmark.cpp
index 8e69ffff..793eb00a 100644
--- a/src/main/benchmark.cpp
+++ b/src/main/benchmark.cpp
@@ -47,6 +47,7 @@ void benchmark_hn_titles(char* file_path) {
Store *store = new Store("/tmp/typesense-data");
CollectionManager & collectionManager = CollectionManager::get_instance();
collectionManager.init(store, 4, "abcd", "1234");
+ collectionManager.load();
Collection *collection = collectionManager.get_collection("hnstories_direct");
if(collection == nullptr) {
@@ -116,6 +117,7 @@ void benchmark_reactjs_pages(char* file_path) {
Store *store = new Store("/tmp/typesense-data");
CollectionManager & collectionManager = CollectionManager::get_instance();
collectionManager.init(store, 4, "abcd", "1234");
+ collectionManager.load();
Collection *collection = collectionManager.get_collection("reactjs_pages");
if(collection == nullptr) {
diff --git a/src/main/main.cpp b/src/main/main.cpp
index a891ef1b..80606fe1 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -22,6 +22,7 @@ int main(int argc, char* argv[]) {
CollectionManager & collectionManager = CollectionManager::get_instance();
collectionManager.init(store, 4, "abcd", "123");
+ collectionManager.load();
std::vector<field> fields_to_index = {
field("lang", field_types::STRING, true),
diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cpp
index b3767a3e..843d8f68 100644
--- a/test/collection_faceting_test.cpp
+++ b/test/collection_faceting_test.cpp
@@ -21,6 +21,7 @@ protected:
store = new Store(state_dir_path);
collectionManager.init(store, 4, "auth_key", "search_auth_key");
+ collectionManager.load();
}
virtual void SetUp() {
diff --git a/test/collection_manager_test.cpp b/test/collection_manager_test.cpp
index cc663c59..9fb21068 100644
--- a/test/collection_manager_test.cpp
+++ b/test/collection_manager_test.cpp
@@ -21,6 +21,7 @@ protected:
store = new Store(state_dir_path);
collectionManager.init(store, 4, "auth_key", "search_auth_key");
+ collectionManager.load();
search_fields = {
field("title", field_types::STRING, false),
@@ -211,6 +212,7 @@ TEST_F(CollectionManagerTest, RestoreRecordsOnRestart) {
// create a new collection manager to ensure that it restores the records from the disk backed store
CollectionManager & collectionManager2 = CollectionManager::get_instance();
collectionManager2.init(store, 4, "auth_key", "search_auth_key");
+ collectionManager2.load();
collection1 = collectionManager2.get_collection("collection1");
ASSERT_NE(nullptr, collection1);
@@ -278,6 +280,7 @@ TEST_F(CollectionManagerTest, Symlinking) {
system(("rm -rf "+state_dir_path+" && mkdir -p "+state_dir_path).c_str());
Store *store = new Store(state_dir_path);
cmanager.init(store, 4, "auth_key", "search_auth_key");
+ cmanager.load();
// try resolving on a blank slate
Option<std::string> collection_option = cmanager.resolve_symlink("collection");
@@ -324,6 +327,8 @@ TEST_F(CollectionManagerTest, Symlinking) {
// should be able to restore state on init
CollectionManager & cmanager2 = CollectionManager::get_instance();
cmanager2.init(store, 4, "auth_key", "search_auth_key");
+ cmanager2.load();
+
collection_option = cmanager2.resolve_symlink("company");
ASSERT_TRUE(collection_option.ok());
ASSERT_EQ("company_2019", collection_option.get());
diff --git a/test/collection_sorting_test.cpp b/test/collection_sorting_test.cpp
index 1f122d3d..9004d6f7 100644
--- a/test/collection_sorting_test.cpp
+++ b/test/collection_sorting_test.cpp
@@ -21,6 +21,7 @@ protected:
store = new Store(state_dir_path);
collectionManager.init(store, 4, "auth_key", "search_auth_key");
+ collectionManager.load();
}
virtual void SetUp() {
diff --git a/test/collection_test.cpp b/test/collection_test.cpp
index 3a9a9493..ed250b88 100644
--- a/test/collection_test.cpp
+++ b/test/collection_test.cpp
@@ -21,6 +21,7 @@ protected:
store = new Store(state_dir_path);
collectionManager.init(store, 4, "auth_key", "search_auth_key");
+ collectionManager.load();
std::ifstream infile(std::string(ROOT_DIR)+"test/documents.jsonl");
std::vector<field> search_fields = {
diff --git a/test/store_test.cpp b/test/store_test.cpp
index 6206832e..7ae388ee 100644
--- a/test/store_test.cpp
+++ b/test/store_test.cpp
@@ -10,7 +10,7 @@ TEST(StoreTest, GetUpdatesSince) {
// add some records, get the updates and restore them in a new store
- Store primary_store(primary_store_path);
+ Store primary_store(primary_store_path, 24*60*60, 1024, false);
// on a fresh store, sequence number is 0
Option<std::vector<std::string>*> updates_op = primary_store.get_updates_since(0, 10);
@@ -36,6 +36,7 @@ TEST(StoreTest, GetUpdatesSince) {
primary_store.insert("foo1", "bar1");
ASSERT_EQ(1, primary_store.get_latest_seq_number());
updates_op = primary_store.get_updates_since(1, 10);
+ std::cout << updates_op.error() << std::endl;
ASSERT_TRUE(updates_op.ok());
ASSERT_EQ(1, updates_op.get()->size());
delete updates_op.get();
@@ -66,7 +67,7 @@ TEST(StoreTest, GetUpdatesSince) {
LOG(INFO) << "Truncating and creating: " << replica_store_path;
system(("rm -rf "+replica_store_path+" && mkdir -p "+replica_store_path).c_str());
- Store replica_store(replica_store_path);
+ Store replica_store(replica_store_path, 24*60*60, 1024, false);
rocksdb::DB* replica_db = replica_store._get_db_unsafe();
updates_op = primary_store.get_updates_since(0, 10);
@@ -124,7 +125,7 @@ TEST(StoreTest, GetUpdateSinceInvalidIterator) {
// add some records, get the updates and restore them in a new store
- Store primary_store(primary_store_path, 0, 0); // disable WAL
+ Store primary_store(primary_store_path, 0, 0, true); // disable WAL
primary_store.insert("foo1", "bar1");
primary_store.insert("foo2", "bar2");
primary_store.insert("foo3", "bar3");