Skip to content

Commit 7ced21d

Browse files
committed
Bug fixes, debug shell, DB dump/import support
- Deleted obsoleted session_recorder.cc code - Renamed Process_launcher class to Process, removed unnecessary methods, added support for reading stdout from a thread to allow concurrent writing to stdin - Added dumpData and importData methods to testutil - Register testutil module in mysqlshrec - Fixed bugs in comment handling in SQL statement splitter - Added utility functions to find a file in PATH - Bridge support for wrapping functions with std::vector<std::string> params - Cleanup main() - Restore original codepage on error in Windows - Added util code to execute SQL scripts - Added support for not recording test scripts with _norecord in the name Change-Id: Ic1366e7e11e2add3e4867f6f9f488688c05b055f
1 parent d5913c1 commit 7ced21d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1100
-945
lines changed

CPPLINT.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
exclude_files=ext/*
2-
filter=-build/c++11
2+
filter=-build/c++11,-readability/multiline_comment

mysqlshdk/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
@@ -21,6 +21,7 @@
2121

2222
include_directories(BEFORE
2323
${CMAKE_SOURCE_DIR}
24+
${CMAKE_BINARY_DIR}
2425
${CMAKE_SOURCE_DIR}/mysqlshdk/libs
2526
${CMAKE_SOURCE_DIR}/mysqlshdk/include
2627
${CMAKE_BINARY_DIR}/mysqlshdk/include

mysqlshdk/include/scripting/types_cpp.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -133,6 +133,21 @@ struct Type_info<const std::string &> {
133133
static std::string default_value() { return std::string(); }
134134
};
135135

136+
template <>
137+
struct Type_info<const std::vector<std::string> &> {
138+
static std::vector<std::string> to_native(const shcore::Value &in) {
139+
std::vector<std::string> strs;
140+
shcore::Array_t array(in.as_array());
141+
for (size_t i = 0; i < array->size(); ++i) {
142+
strs.push_back(array->at(i).as_string());
143+
}
144+
return strs;
145+
}
146+
static Value_type vtype() { return shcore::Array; }
147+
static const char *code() { return "A"; }
148+
static std::vector<std::string> default_value() { return {}; }
149+
};
150+
136151
template <>
137152
struct Type_info<const shcore::Dictionary_t&> {
138153
static shcore::Dictionary_t to_native(const shcore::Value &in) {

mysqlshdk/libs/db/CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License, version 2.0,
@@ -25,7 +25,6 @@ set(db_SOURCE
2525
row.h
2626
column.cc
2727
charset.cc
28-
session_recorder.cc
2928
uri_parser.cc
3029
uri_encoder.cc
3130
connection_options.cc

mysqlshdk/libs/db/mysqlx/mysqlxclient_clean.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -29,6 +29,7 @@
2929
#pragma GCC diagnostic push
3030
#pragma GCC diagnostic ignored "-Wshadow"
3131
#pragma GCC diagnostic ignored "-Wunused-parameter"
32+
#pragma GCC diagnostic ignored "-Wsign-compare"
3233
#elif defined(__clang__)
3334
#pragma clang diagnostic push
3435
#pragma clang diagnostic ignored "-Wshadow"

mysqlshdk/libs/db/replay/setup.cc

+1-78
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -125,83 +125,6 @@ std::map<std::string, std::string> load_test_case_info() {
125125
return load_info(current_recording_dir() + "/info");
126126
}
127127

128-
static std::list<std::weak_ptr<mysqlshdk::db::ISession>> g_open_sessions;
129-
130-
static void on_session_connect(
131-
std::shared_ptr<mysqlshdk::db::ISession> session) {
132-
// called by session recorder classes when connect is called
133-
// adds a weak ptr to the session object along with the stack trace
134-
// to a list of open sessions, which will be checked when the test finishes
135-
g_open_sessions.push_back(session);
136-
}
137-
138-
static void on_session_close(std::shared_ptr<mysqlshdk::db::ISession> session) {
139-
// called by session recorder classes when close is called
140-
for (auto iter = g_open_sessions.begin(); iter != g_open_sessions.end();
141-
++iter) {
142-
auto ptr = iter->lock();
143-
if (ptr && ptr.get() == session.get()) {
144-
g_open_sessions.erase(iter);
145-
break;
146-
}
147-
}
148-
}
149-
150-
void setup_global_from_env() {
151-
int print_traces = 0;
152-
if (const char* debug = getenv("TEST_DEBUG")) {
153-
print_traces = atoi(debug);
154-
}
155-
if (const char* mode = getenv("MYSQLSH_RECORDER_MODE")) {
156-
if (strcasecmp(mode, "direct") == 0 || !*mode) {
157-
set_mode(Mode::Direct, 0);
158-
puts("Disabled classic session recording");
159-
} else if (strcasecmp(mode, "record") == 0) {
160-
set_mode(Mode::Record, print_traces);
161-
162-
if (!getenv("MYSQLSH_RECORDER_PREFIX")) {
163-
printf(
164-
"MYSQLSH_RECORDER_MODE set but MYSQLSH_RECORDER_PREFIX is not!\n");
165-
return;
166-
}
167-
set_recording_path_prefix(getenv("MYSQLSH_RECORDER_PREFIX"));
168-
169-
// Set up hooks for keeping track of opened sessions
170-
on_recorder_connect_hook =
171-
std::bind(&on_session_connect, std::placeholders::_1);
172-
on_recorder_close_hook =
173-
std::bind(&on_session_close, std::placeholders::_1);
174-
175-
printf("Recording classic sessions to %s\n", g_recording_path_prefix);
176-
} else if (strcasecmp(mode, "replay") == 0) {
177-
set_mode(Mode::Replay, print_traces);
178-
179-
if (!getenv("MYSQLSH_RECORDER_PREFIX")) {
180-
printf(
181-
"MYSQLSH_RECORDER_MODE set but MYSQLSH_RECORDER_PREFIX is not!\n");
182-
return;
183-
}
184-
set_recording_path_prefix(getenv("MYSQLSH_RECORDER_PREFIX"));
185-
printf("Replaying classic sessions from %s\n", g_recording_path_prefix);
186-
} else {
187-
printf("Invalid value for MYSQLSH_RECORDER_MODE '%s'\n", mode);
188-
}
189-
}
190-
}
191-
192-
void finalize_global() {
193-
// Automatically close recording sessions that may be still open
194-
on_recorder_connect_hook = {};
195-
on_recorder_close_hook = {};
196-
197-
for (const auto& s : g_open_sessions) {
198-
if (auto session = s.lock()) {
199-
session->close();
200-
}
201-
}
202-
g_open_sessions.clear();
203-
}
204-
205128
static Mode g_active_session_injector_mode = Mode::Direct;
206129
static int g_active_session_print_trace_mode = 0;
207130

mysqlshdk/libs/db/replay/setup.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0,
@@ -40,9 +40,6 @@ namespace replay {
4040

4141
enum class Mode { Direct, Record, Replay };
4242

43-
void setup_global_from_env();
44-
void finalize_global();
45-
4643
void set_mode(Mode mode, int print_traces);
4744

4845
void set_recording_path_prefix(const std::string& path);

0 commit comments

Comments
 (0)