// Copyright 2022 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 #include #include "utils/logging.hpp" #include "utils/timer.hpp" DEFINE_uint64(bolt_port, 7687, "Bolt port"); DEFINE_uint64(timeout, 120, "Timeout seconds"); int main(int argc, char **argv) { google::SetUsageMessage("Memgraph E2E Memory Control"); gflags::ParseCommandLineFlags(&argc, &argv, true); logging::RedirectToStderr(); mg::Client::Init(); auto client = mg::Client::Connect({.host = "127.0.0.1", .port = static_cast(FLAGS_bolt_port), .use_ssl = false}); if (!client) { LOG_FATAL("Failed to connect!"); } client->Execute("MATCH (n) DETACH DELETE n;"); client->DiscardAll(); const auto *create_query = "UNWIND range(1, 50) as u CREATE (n {string: \"Some longer string\"}) RETURN n;"; utils::Timer timer; while (true) { if (timer.Elapsed>().count() > FLAGS_timeout) { LOG_FATAL("The test timed out"); } client->Execute(create_query); try { client->DiscardAll(); } catch (const mg::TransientException & /*unused*/) { break; } } spdlog::info("Memgraph is out of memory"); return 0; }