memgraph/tests/integration/run_time_settings/flag_tester.cpp
Gareth Andrew Lloyd 3cc2bc2791
Refactor interpreter to support multiple distributed clocks (Part 1) (#1281)
* Interpreter transaction ID decoupled from storage transaction ID
* Transactional scope for indices, statistics and constraints
* Storage::Accessor now has 2 modes (unique and shared)
* Introduced ResourceLock to fix pthread mutex problems
* Split InfoQuery in two: non-transactional SystemInfoQuery and transactional DatabaseInfoQuery
* Replicable and durable statistics
* Bumped WAL/Snapshot versions
* Initial implementation of the Lamport clock

---------

Co-authored-by: Andreja Tonev <andreja.tonev@memgraph.io>
2023-10-05 16:58:39 +02:00

69 lines
2.7 KiB
C++

// Copyright 2023 Memgraph Ltd.
//
// 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
// License, and you may not use this file except in compliance with the Business Source License.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
#include <gflags/gflags.h>
#include "communication/bolt/client.hpp"
#include "communication/bolt/v1/value.hpp"
#include "io/network/endpoint.hpp"
#include "io/network/utils.hpp"
#include "utils/logging.hpp"
DEFINE_string(address, "127.0.0.1", "Server address");
DEFINE_int32(port, 7687, "Server port");
DEFINE_string(field, "", "Expected settings field to check");
DEFINE_string(value, "", "Expected string result from field");
/**
* Executes queries passed as positional arguments and verifies whether they
* succeeded, failed, failed with a specific error message or executed without a
* specific error occurring.
*/
int main(int argc, char **argv) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
memgraph::communication::SSLInit sslInit;
memgraph::io::network::Endpoint endpoint(memgraph::io::network::ResolveHostname(FLAGS_address), FLAGS_port);
memgraph::communication::ClientContext context(false);
memgraph::communication::bolt::Client client(context);
try {
client.Connect(endpoint, "", "");
} catch (const memgraph::utils::BasicException &e) {
LOG_FATAL("");
}
const auto &res = client.Execute("SHOW DATABASE SETTINGS", {});
MG_ASSERT(res.fields[0] == "setting_name", "Expected \"setting_name\" field in the query result.");
MG_ASSERT(res.fields[1] == "setting_value", "Expected \"setting_value\" field in the query result.");
for (const auto &record : res.records) {
const auto &settings_name = record[0].ValueString();
if (settings_name == FLAGS_field) {
const auto &settings_value = record[1].ValueString();
// First try to encode the flags as float; if that fails just compare the raw strings
try {
MG_ASSERT(std::stof(settings_value) == std::stof(FLAGS_value),
"Failed when checking \"{}\"; expected \"{}\", found \"{}\"!", FLAGS_field, FLAGS_value,
settings_value);
} catch (const std::invalid_argument &) {
MG_ASSERT(settings_value == FLAGS_value, "Failed when checking \"{}\"; expected \"{}\", found \"{}\"!",
FLAGS_field, FLAGS_value, settings_value);
}
return 0;
}
}
LOG_FATAL("No setting named \"{}\" found!", FLAGS_field);
}