Skip to content

Commit ce2ad47

Browse files
committedJan 31, 2025
[#25830] xClusterDDLRepl: Fix XClusterPgRegressDDLReplicationTest tests
Summary: Use namespace_name instead of yugabyte in ExecutePgFile. Also adding a sanity check to ensure that the tests are running properly Jira: DB-15127 Test Plan: XClusterPgRegressDDLReplicationTest Reviewers: mlillibridge, xCluster, hsunder Reviewed By: mlillibridge Subscribers: ybase Differential Revision: https://phorge.dev.yugabyte.com/D41608
1 parent 00ba3fb commit ce2ad47

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed
 

‎src/yb/integration-tests/xcluster/xcluster_ddl_replication_pgregress-test.cc

+16-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ class XClusterPgRegressDDLReplicationTest : public XClusterDDLReplicationTestBas
7272
", ", "\n"));
7373
}
7474

75-
void ExecutePgFile(const std::string& file_path) {
75+
void ExecutePgFile(const std::string& file_path) { ExecutePgFile(file_path, namespace_name); }
76+
77+
void ExecutePgFile(const std::string& file_path, const std::string& database_name) {
7678
std::vector<std::string> args;
7779
args.push_back(GetPgToolPath("ysqlsh"));
7880
args.push_back("--host");
@@ -83,6 +85,8 @@ class XClusterPgRegressDDLReplicationTest : public XClusterDDLReplicationTestBas
8385
args.push_back("--variable=ON_ERROR_STOP=1");
8486
args.push_back("-f");
8587
args.push_back(file_path);
88+
args.push_back("-d");
89+
args.push_back(database_name);
8690

8791
auto s = CallAdminVec(args);
8892
LOG(INFO) << "Command output: " << s;
@@ -98,7 +102,7 @@ class XClusterPgRegressDDLReplicationTest : public XClusterDDLReplicationTestBas
98102
RETURN_NOT_OK(SetUpClusters());
99103

100104
// Perturb OIDs on consumer side to make sure we don't accidentally preserve OIDs.
101-
auto conn = VERIFY_RESULT(consumer_cluster_.ConnectToDB("yugabyte"));
105+
auto conn = VERIFY_RESULT(consumer_cluster_.ConnectToDB(namespace_name));
102106
RETURN_NOT_OK(
103107
conn.Execute("CREATE TYPE gratuitous_enum AS ENUM ('red', 'orange', 'yellow', 'green', "
104108
"'blue', 'purple');"));
@@ -111,7 +115,8 @@ class XClusterPgRegressDDLReplicationTest : public XClusterDDLReplicationTestBas
111115
// Some of the scripts do take a long time to run so setting this timeout high.
112116
propagation_timeout_ = MonoDelta::FromMinutes(4 * kTimeMultiplier);
113117

114-
// First run just the create table part of the file, then run the drop parts.
118+
// First run just the create part of the file, then run the drop parts.
119+
std::string initial_dump = "";
115120
for (const auto& file_name : {create_file_name, drop_file_name}) {
116121
if (file_name.empty()) {
117122
continue;
@@ -126,6 +131,14 @@ class XClusterPgRegressDDLReplicationTest : public XClusterDDLReplicationTestBas
126131
auto producer_dump = VERIFY_RESULT(RunYSQLDump(producer_cluster_));
127132
auto consumer_dump = VERIFY_RESULT(RunYSQLDump(consumer_cluster_));
128133
SCHECK_EQ(producer_dump, consumer_dump, IllegalState, "Ysqldumps do not match");
134+
// Ensure that the dump is not empty, should at least contain the extension.
135+
if (initial_dump.empty()) {
136+
initial_dump = producer_dump;
137+
} else {
138+
// Check to ensure that the test is working properly.
139+
SCHECK_NE(
140+
initial_dump, producer_dump, IllegalState, "Ysqldumps after drops should not match");
141+
}
129142

130143
auto producer_enum_label_info = VERIFY_RESULT(ReadEnumLabelInfo(producer_cluster_));
131144
auto consumer_enum_label_info = VERIFY_RESULT(ReadEnumLabelInfo(consumer_cluster_));

0 commit comments

Comments
 (0)