Skip to content

Commit 716959f

Browse files
committed
Backport from master:
Cosmetic changes in patch for BUG#26870329 Fixed testing framework handling of STDERR Fixed failing AdminAPI tests due to wrong STDERR handling
1 parent 447c86d commit 716959f

12 files changed

+42
-41
lines changed

modules/adminapi/mod_dba_replicaset.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -742,11 +742,10 @@ shcore::Value ReplicaSet::rejoin_instance(const shcore::Argument_list &args) {
742742
auto row = result->fetch_one();
743743
std::string member_state = row->get_value(0).as_string();
744744
std::string nice_error_msg = "Cannot rejoin instance '" +
745-
instance_address + "' with state '" +
746-
member_state +
747-
"' since it "
748-
"is an active member of the ReplicaSet '" +
749-
get_member("name").as_string() + "'.";
745+
instance_address + "' to the ReplicaSet '" +
746+
get_member("name").as_string() +
747+
"' since it is an active (" + member_state +
748+
") member of the ReplicaSet.";
750749
session->close(shcore::Argument_list());
751750
throw std::runtime_error(nice_error_msg);
752751
}

unittest/modules/adminapi/mod_dba_common_t.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,14 +1248,14 @@ TEST_F(Dba_common_test, validate_replicaset_group_name_002) {
12481248

12491249
TEST_F(Dba_common_test, validate_instance_rejoinable_01) {
12501250
// There are missing instances and the instance we are checking belongs to
1251-
// that list
1251+
// the metadata list but does not belong to the GR list.
12521252

12531253
// get_instances_gr():
12541254
//
12551255
// member_id
12561256
// ------------------------------------
1257+
// 8fcb92c9-5730-11e7-aa60-b86b230042b9
12571258
// 851f0e89-5730-11e7-9e4f-b86b230042b9
1258-
// 8a8ae9ce-5730-11e7-a437-b86b230042b9
12591259

12601260
std::vector<tests::Fake_result_data> queries;
12611261

@@ -1316,15 +1316,15 @@ TEST_F(Dba_common_test, validate_instance_rejoinable_01) {
13161316
}
13171317

13181318
TEST_F(Dba_common_test, validate_instance_rejoinable_02) {
1319-
// There are missing instances but the instance we are checking does not
1320-
// belong to that list.
1319+
// There are missing instances and the instance we are checking belongs
1320+
// to neither the metadata nor GR lists.
13211321

13221322
// get_instances_gr():
13231323
//
13241324
// member_id
13251325
// ------------------------------------
1326+
// 8fcb92c9-5730-11e7-aa60-b86b230042b9
13261327
// 851f0e89-5730-11e7-9e4f-b86b230042b9
1327-
// 8a8ae9ce-5730-11e7-a437-b86b230042b9
13281328

13291329
std::vector<tests::Fake_result_data> queries;
13301330

@@ -1362,9 +1362,11 @@ TEST_F(Dba_common_test, validate_instance_rejoinable_02) {
13621362
metadata.reset(new mysqlsh::dba::MetadataStorage(md_session));
13631363

13641364
std::vector<tests::Fake_result_data> instance_queries;
1365+
// Checking an instance that doesn't belong to the metadata nor the GR
1366+
// list.
13651367
add_get_server_variable_query(&instance_queries, "server_uuid",
13661368
tests::Type::String,
1367-
"8a8ae9ce-5730-11e7-a437-b86b230042b1");
1369+
"aaaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa");
13681370
START_SERVER_MOCK(_mysql_sandbox_nport2, instance_queries);
13691371
auto instance_session = create_session(_mysql_sandbox_nport2);
13701372
try {
@@ -1385,7 +1387,8 @@ TEST_F(Dba_common_test, validate_instance_rejoinable_02) {
13851387
}
13861388

13871389
TEST_F(Dba_common_test, validate_instance_rejoinable_03) {
1388-
// There are no missing instances
1390+
// There are no missing instances and the instance we are checking belongs
1391+
// to both the metadata and GR lists.
13891392

13901393
// get_instances_gr():
13911394
//

unittest/scripts/js_devapi/scripts/dba_cluster_misconfigurations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var cluster = dba.createCluster('dev');
4646
// Regression for BUG#25966731 : ALLOW-NON-COMPATIBLE-TABLES OPTION DOES NOT EXIST
4747
dba.verbose = 1;
4848

49-
//@<ERR> Create cluster fails (one table is not compatible) - verbose mode
49+
//@ Create cluster fails (one table is not compatible) - verbose mode
5050
// Regression for BUG#25966731 : ALLOW-NON-COMPATIBLE-TABLES OPTION DOES NOT EXIST
5151
var cluster = dba.createCluster('dev');
5252

unittest/scripts/js_devapi/scripts/dba_cluster_rejoin_instance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ wait_slave_state(cluster, uri2, "ONLINE");
7575
//@<OUT> Cluster status after rejoin
7676
cluster.status();
7777

78-
//@ Cannot rejoin an instance that is already in the group (not missing) Bug#26870329
78+
//@<ERR> Cannot rejoin an instance that is already in the group (not missing) Bug#26870329
7979
cluster.rejoinInstance({dbUser: 'foo', host: 'localhost', port:__mysql_sandbox_port2}, {password: 'bar'});
8080

8181
//@ Dissolve cluster

unittest/scripts/js_devapi/validation/dba_cluster_misconfigurations.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,9 @@
1313
//@ Enable verbose
1414
||
1515

16-
//@<ERR> Create cluster fails (one table is not compatible) - verbose mode
17-
* Checking compliance of existing tables... FAIL
18-
ERROR: 1 table(s) do not have a Primary Key or Primary Key Equivalent (non-null unique key).
19-
pke_test.t3
20-
21-
Group Replication requires tables to use InnoDB and have a PRIMARY KEY or PRIMARY KEY Equivalent (non-null unique key). Tables that do not follow these requirements will be readable but not updateable when used with Group Replication. If your applications make updates (INSERT, UPDATE or DELETE) to these tables, ensure they use the InnoDB storage engine and have a PRIMARY KEY or PRIMARY KEY Equivalent.
22-
23-
24-
ERROR: Error starting cluster: The operation could not continue due to the following requirements not being met:
25-
Non-compatible tables found in database.
26-
==============================================================================
16+
//@ Create cluster fails (one table is not compatible) - verbose mode
17+
||ERROR: Error starting cluster: The operation could not continue due to the following requirements not being met:
18+
||Non-compatible tables found in database.
2719

2820
//@ Disable verbose
2921
||

unittest/scripts/js_devapi/validation/dba_cluster_rejoin_instance.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484
}
8585
}
8686

87-
//@ Cannot rejoin an instance that is already in the group (not missing) Bug#26870329
88-
||Cluster.rejoinInstance: Cannot rejoin instance '<<<localhost>>>:<<<__mysql_sandbox_port2>>>' with state 'ONLINE' since it is an active member of the ReplicaSet 'default'.
87+
//@<ERR> Cannot rejoin an instance that is already in the group (not missing) Bug#26870329
88+
Cluster.rejoinInstance: Cannot rejoin instance '<<<localhost>>>:<<<__mysql_sandbox_port2>>>' to the ReplicaSet 'default' since it is an active ({{ONLINE|RECOVERING}}) member of the ReplicaSet. (RuntimeError)
8989

9090
//@ Dissolve cluster
9191
||

unittest/scripts/py_devapi/scripts/dba_cluster_misconfigurations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
# Regression for BUG#25966731 : ALLOW-NON-COMPATIBLE-TABLES OPTION DOES NOT EXIST
4747
dba.verbose = 1
4848

49-
#@<ERR> Create cluster fails (one table is not compatible) - verbose mode
49+
#@ Create cluster fails (one table is not compatible) - verbose mode
5050
# Regression for BUG#25966731 : ALLOW-NON-COMPATIBLE-TABLES OPTION DOES NOT EXIST
5151
cluster = dba.create_cluster('dev')
5252

unittest/scripts/py_devapi/validation/dba_cluster_misconfigurations.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,9 @@
1313
#@ Enable verbose
1414
||
1515

16-
#@<ERR> Create cluster fails (one table is not compatible) - verbose mode
17-
* Checking compliance of existing tables... FAIL
18-
ERROR: 1 table(s) do not have a Primary Key or Primary Key Equivalent (non-null unique key).
19-
pke_test.t3
20-
21-
Group Replication requires tables to use InnoDB and have a PRIMARY KEY or PRIMARY KEY Equivalent (non-null unique key). Tables that do not follow these requirements will be readable but not updateable when used with Group Replication. If your applications make updates (INSERT, UPDATE or DELETE) to these tables, ensure they use the InnoDB storage engine and have a PRIMARY KEY or PRIMARY KEY Equivalent.
22-
23-
24-
ERROR: Error starting cluster: The operation could not continue due to the following requirements not being met:
25-
Non-compatible tables found in database.
26-
==============================================================================
16+
#@ Create cluster fails (one table is not compatible) - verbose mode
17+
||ERROR: Error starting cluster: The operation could not continue due to the following requirements not being met:
18+
||Non-compatible tables found in database.
2719

2820
#@ Disable verbose
2921
||

unittest/shell_js_dba_t.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ TEST_F(Shell_js_dba_tests, cluster_no_misconfigurations_interactive) {
631631
"DBA: root@localhost:" + _mysql_sandbox_port1 + " : Server variable binlog_checksum was changed from 'CRC32' to 'NONE'"};
632632

633633
MY_EXPECT_LOG_NOT_CONTAINS(log);
634+
// Validate output for chunk: Create cluster fails
635+
// (one table is not compatible) - verbose mode
636+
// Regression for BUG#25966731 : ALLOW-NON-COMPATIBLE-TABLES OPTION DOES
637+
// NOT EXIST
638+
MY_EXPECT_STDOUT_NOT_CONTAINS("the --allow-non-compatible-tables option");
634639
}
635640

636641
TEST_F(Shell_js_dba_tests, function_preconditions) {

unittest/shell_py_dba_t.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,11 @@ TEST_F(Shell_py_dba_tests, cluster_misconfigurations) {
492492
"DBA: root@localhost:" + _mysql_sandbox_port1 + " : Server variable binlog_checksum was changed from 'CRC32' to 'NONE'"};
493493

494494
MY_EXPECT_LOG_CONTAINS(log);
495+
// Validate output for chunk: Create cluster fails
496+
// (one table is not compatible) - verbose mode
497+
// Regression for BUG#25966731 : ALLOW-NON-COMPATIBLE-TABLES OPTION DOES
498+
// NOT EXIST
499+
MY_EXPECT_STDOUT_NOT_CONTAINS("the --allow-non-compatible-tables option");
495500
}
496501

497502
TEST_F(Shell_py_dba_tests, cluster_misconfigurations_interactive) {

unittest/shell_script_tester.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ bool Shell_script_tester::validate(const std::string& context, const std::string
186186
ADD_FAILURE();
187187
}
188188
} else {
189-
ret_val = validate_line_by_line(context, chunk_id, "STDERR", error, original_std_out);
189+
ret_val = validate_line_by_line(context, chunk_id, "STDERR", error,
190+
original_std_err);
190191
}
191192
}
192193
}

unittest/test_utils/shell_base_test.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,15 @@ bool Shell_base_test::check_multiline_expect(const std::string& context,
192192
bool ret_val = true;
193193
auto expected_lines = shcore::split_string(expected, "\n");
194194
auto actual_lines = shcore::split_string(actual, "\n");
195+
std::string r_trimmed_actual, r_trimmed_expected;
195196

196197
// Identifies the index of the actual line containing the first expected line
197198
size_t actual_index = 0;
199+
r_trimmed_expected = boost::trim_right_copy(expected_lines.at(0));
198200
while (actual_index < actual_lines.size()) {
199-
if (actual_lines[actual_index].find(expected_lines[0]) != std::string::npos)
201+
// Ignore whitespace at the end of the actual and expected lines
202+
r_trimmed_actual = boost::trim_right_copy(actual_lines[actual_index]);
203+
if (multi_value_compare(r_trimmed_expected, r_trimmed_actual))
200204
break;
201205
else
202206
actual_index++;

0 commit comments

Comments
 (0)