Make telemetry work with v2 and increase timeout

Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D2601
This commit is contained in:
Matej Ferencevic 2019-12-11 15:45:34 +01:00
parent e9f55e2f31
commit f27682dc26
4 changed files with 16 additions and 10 deletions

View File

@ -217,17 +217,22 @@ void SingleNodeMain() {
// Setup telemetry
std::optional<telemetry::Telemetry> telemetry;
#ifndef MG_SINGLE_NODE_V2
if (FLAGS_telemetry_enabled) {
telemetry.emplace(
"https://telemetry.memgraph.com/88b5e7e8-746a-11e8-9f85-538a9e9690cc/",
data_directory / "telemetry", std::chrono::minutes(10));
#ifdef MG_SINGLE_NODE_V2
telemetry->AddCollector("db", [&db]() -> nlohmann::json {
auto info = db.GetInfo();
return {{"vertices", info.vertex_count}, {"edges", info.edge_count}};
});
#else
telemetry->AddCollector("db", [&db]() -> nlohmann::json {
auto dba = db.Access();
return {{"vertices", dba.VerticesCount()}, {"edges", dba.EdgesCount()}};
});
}
#endif
}
// Handler for regular termination signals
auto shutdown = [&server, &interpreter_context] {

View File

@ -66,7 +66,8 @@ void Telemetry::SendData() {
}
}
if (requests::RequestPostJson(url_, payload)) {
if (requests::RequestPostJson(url_, payload,
/* timeout_in_seconds = */ 2 * 60)) {
for (const auto &key : keys) {
if (!storage_.Delete(key)) {
DLOG(WARNING) << "Couldn't delete key " << key

View File

@ -21,8 +21,8 @@ def execute_test(**kwargs):
interval = kwargs.pop("interval", 1)
duration = kwargs.pop("duration", 5)
timeout = duration * 2 if "hang" not in kwargs else duration + 60
success = "hang" in kwargs
timeout = duration * 2 if "hang" not in kwargs else duration * 2 + 60
success = False
server_args = [server_binary, "--interval", interval,
"--duration", duration]
@ -71,11 +71,11 @@ TESTS = [
{"redirect": True},
{"no_response_count": 2},
{"wrong_code_count": 2},
{"hang": True, "no_check": True, "duration": 0},
{"hang": True, "duration": 0},
{"path": "/nonexistant/", "no_check": True},
{"endpoint": "http://127.0.0.1:9000/nonexistant/", "no_check": True},
{"start_server": False},
{"startups": 5, "no_check_duration": True}, # the last 4 tests failed
{"startups": 4, "no_check_duration": True}, # the last 3 tests failed
# to send any data + this test
{"add_garbage": True}
]

View File

@ -61,12 +61,12 @@ def build_handler(storage, args):
assert "timestamp" in item
storage.append(item)
if args.hang:
time.sleep(20)
self.send_response(200)
self.end_headers()
if args.hang:
time.sleep(1000)
return Handler