Skip to content

Commit

Permalink
[#23179] CDCSDK: Refactor TestPgReplicationSlot for dynamic data types
Browse files Browse the repository at this point in the history
Summary:
This revision refactors the test method `replicationConnectionConsumptionAllDataTypes` along with related test framework to improve the interface for creating `PgOutputRelationMessageColumn` for dynamic data types. Since the OIDs of such types are not static, it is better if we do not specify them while creating `PgOutputRelationMessageColumn` for columns with dynamic types.
Jira: DB-12118

Test Plan: Jenkins: test regex: .*TestPgReplicationSlot.*

Reviewers: stiwary, jason

Reviewed By: jason

Subscribers: ycdcxcluster

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37383
  • Loading branch information
Sumukh-Phalgaonkar committed Aug 21, 2024
1 parent 22657da commit 90554b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,23 @@ public PgOutputRelationMessageColumn(
this.compareDataType = compareDataType;
}

public PgOutputRelationMessageColumn(byte flag, String name) {
this.flag = flag;
this.name = name;
// This constructor is used for columns having dynamic types. Since their type OIDs
// are dynamic they will not be compared during the tests.
this.dataType = 0;
this.atttypmod = 0;
this.compareDataType = false;
}

public static PgOutputRelationMessageColumn CreateForComparison(String name, int dataType) {
return new PgOutputRelationMessageColumn(
(byte) 0, name, dataType, 0, /* compareDataType */ true);
}

public static PgOutputRelationMessageColumn CreateForComparison(
String name, int dataType, boolean compareDataType) {
return new PgOutputRelationMessageColumn((byte) 0, name, dataType, 0, compareDataType);
public static PgOutputRelationMessageColumn CreateForComparison(String name) {
return new PgOutputRelationMessageColumn((byte) 0, name);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,9 @@ void replicationConnectionConsumptionAllDataTypes(String pluginName) throws Exce
// The Oids for columns below are not fixed. Changing the order of creation of
// objects (extensions, tables etc.) in the test will change these Oids. Hence,
// skip comparing the Oids of these types.
PgOutputRelationMessageColumn.CreateForComparison(
"col_hstore", 16385, /* compareDataType */ false),
PgOutputRelationMessageColumn.CreateForComparison(
"col_discount", 16518, /* compareDataType */ false),
PgOutputRelationMessageColumn.CreateForComparison(
"col_discount_array", 16517, /* compareDataType */ false))));
PgOutputRelationMessageColumn.CreateForComparison("col_hstore"),
PgOutputRelationMessageColumn.CreateForComparison("col_discount"),
PgOutputRelationMessageColumn.CreateForComparison("col_discount_array"))));
} else {
// The replica identity for test_table in case of pgoutput is DEFAULT.
add(PgOutputRelationMessage.CreateForComparison("public", "test_table", 'd',
Expand Down Expand Up @@ -1035,12 +1032,9 @@ void replicationConnectionConsumptionAllDataTypes(String pluginName) throws Exce
// The Oids for columns below are not fixed. Changing the order of creation of
// objects (extensions, tables etc.) in the test will change these Oids. Hence,
// skip comparing the Oids of these types.
PgOutputRelationMessageColumn.CreateForComparison(
"col_hstore", 16385, /* compareDataType */ false),
PgOutputRelationMessageColumn.CreateForComparison(
"col_discount", 16518, /* compareDataType */ false),
PgOutputRelationMessageColumn.CreateForComparison(
"col_discount_array", 16517, /* compareDataType */ false))));
PgOutputRelationMessageColumn.CreateForComparison("col_hstore"),
PgOutputRelationMessageColumn.CreateForComparison("col_discount"),
PgOutputRelationMessageColumn.CreateForComparison("col_discount_array"))));
}
add(PgOutputInsertMessage.CreateForComparison(new PgOutputMessageTuple((short) 38,
Arrays.asList(new PgOutputMessageTupleColumnValue("1"),
Expand Down

0 comments on commit 90554b0

Please sign in to comment.