Fix ShowReplicas tests

This commit is contained in:
Andi Skrgat 2024-02-29 08:03:42 +01:00
parent 208838289e
commit 3607eef5df
6 changed files with 29 additions and 14 deletions

View File

@ -25,9 +25,8 @@ find_package(Threads REQUIRED)
add_library(mg-utils STATIC ${utils_src_files}) add_library(mg-utils STATIC ${utils_src_files})
add_library(mg::utils ALIAS mg-utils) add_library(mg::utils ALIAS mg-utils)
find_library(LIBUUID_LIBRARY libuuid.a)
target_link_libraries(mg-utils PUBLIC Boost::headers fmt::fmt spdlog::spdlog json) target_link_libraries(mg-utils PUBLIC Boost::headers fmt::fmt spdlog::spdlog json)
target_link_libraries(mg-utils PRIVATE librdtsc stdc++fs Threads::Threads gflags ${LIBUUID_LIBRARY} rt) target_link_libraries(mg-utils PRIVATE librdtsc stdc++fs Threads::Threads gflags uuid rt)
set(settings_src_files set(settings_src_files
settings.cpp) settings.cpp)

View File

@ -1,4 +1,4 @@
// Copyright 2023 Memgraph Ltd. // Copyright 2024 Memgraph Ltd.
// //
// Use of this software is governed by the Business Source License // Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
@ -10,7 +10,7 @@
// licenses/APL.txt. // licenses/APL.txt.
#include "utils/uuid.hpp" #include "utils/uuid.hpp"
#include <uuid/uuid.h>
#include "slk/serialization.hpp" #include "slk/serialization.hpp"
namespace memgraph::utils { namespace memgraph::utils {

View File

@ -12,6 +12,7 @@
#pragma once #pragma once
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include <array> #include <array>
#include <json/json.hpp> #include <json/json.hpp>
#include <string> #include <string>

View File

@ -138,8 +138,11 @@ def test_distributed_automatic_failover():
{"memgraph": {"ts": 0, "behind": 0, "status": "ready"}}, {"memgraph": {"ts": 0, "behind": 0, "status": "ready"}},
), ),
] ]
actual_data_on_main = sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
assert actual_data_on_main == sorted(expected_data_on_main) def retrieve_data_show_replicas():
return sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
mg_sleep_and_assert_collection(expected_data_on_main, retrieve_data_show_replicas)
interactive_mg_runner.kill(MEMGRAPH_INSTANCES_DESCRIPTION, "instance_3") interactive_mg_runner.kill(MEMGRAPH_INSTANCES_DESCRIPTION, "instance_3")

View File

@ -75,8 +75,11 @@ def test_replication_works_on_failover():
{"memgraph": {"ts": 0, "behind": 0, "status": "ready"}}, {"memgraph": {"ts": 0, "behind": 0, "status": "ready"}},
), ),
] ]
actual_data_on_main = sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
assert actual_data_on_main == expected_data_on_main def retrieve_data_show_replicas():
return sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
mg_sleep_and_assert(expected_data_on_main, retrieve_data_show_replicas)
# 3 # 3
interactive_mg_runner.start_all_keep_others(MEMGRAPH_SECOND_CLUSTER_DESCRIPTION) interactive_mg_runner.start_all_keep_others(MEMGRAPH_SECOND_CLUSTER_DESCRIPTION)

View File

@ -910,8 +910,11 @@ def test_replication_works_on_failover_simple():
{"memgraph": {"ts": 0, "behind": 0, "status": "ready"}}, {"memgraph": {"ts": 0, "behind": 0, "status": "ready"}},
), ),
] ]
actual_data_on_main = sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
assert actual_data_on_main == expected_data_on_main def main_cursor_show_replicas():
return sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
mg_sleep_and_assert_collection(expected_data_on_main, main_cursor_show_replicas)
# 3 # 3
interactive_mg_runner.kill(MEMGRAPH_INSTANCES_DESCRIPTION, "instance_3") interactive_mg_runner.kill(MEMGRAPH_INSTANCES_DESCRIPTION, "instance_3")
@ -1028,8 +1031,11 @@ def test_replication_works_on_replica_instance_restart():
{"memgraph": {"ts": 0, "behind": 0, "status": "ready"}}, {"memgraph": {"ts": 0, "behind": 0, "status": "ready"}},
), ),
] ]
actual_data_on_main = sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
assert actual_data_on_main == expected_data_on_main def main_cursor_show_replicas():
return sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
mg_sleep_and_assert_collection(expected_data_on_main, main_cursor_show_replicas)
# 3 # 3
coord_cursor = connect(host="localhost", port=7690).cursor() coord_cursor = connect(host="localhost", port=7690).cursor()
@ -1216,8 +1222,11 @@ def test_simple_automatic_failover():
{"memgraph": {"ts": 0, "behind": 0, "status": "ready"}}, {"memgraph": {"ts": 0, "behind": 0, "status": "ready"}},
), ),
] ]
actual_data_on_main = sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
assert actual_data_on_main == sorted(expected_data_on_main) def main_cursor_show_replicas():
return sorted(list(execute_and_fetch_all(main_cursor, "SHOW REPLICAS;")))
mg_sleep_and_assert_collection(expected_data_on_main, main_cursor_show_replicas)
interactive_mg_runner.kill(MEMGRAPH_INSTANCES_DESCRIPTION, "instance_3") interactive_mg_runner.kill(MEMGRAPH_INSTANCES_DESCRIPTION, "instance_3")