Copilot commented on code in PR #17800:
URL: https://github.com/apache/pinot/pull/17800#discussion_r2879787704
##########
pinot-segment-local/src/test/java/org/apache/pinot/segment/local/utils/TableConfigUtilsTest.java:
##########
@@ -2025,6 +2027,81 @@ public void testValidateInvalidDedupConfigs() {
}
}
+ @Test
+ public void testValidateUpsertConfigWithMd5Disabled() {
+ Schema schema = new Schema.SchemaBuilder().setSchemaName(TABLE_NAME)
+ .addSingleValueDimension("myCol", FieldSpec.DataType.STRING)
+ .setPrimaryKeyColumns(Lists.newArrayList("myCol"))
+ .build();
+ UpsertConfig upsertConfig = new UpsertConfig(UpsertConfig.Mode.FULL);
+ upsertConfig.setHashFunction(HashFunction.MD5);
+ TableConfig tableConfig = new
TableConfigBuilder(TableType.REALTIME).setTableName(TABLE_NAME)
+ .setUpsertConfig(upsertConfig)
+ .setRoutingConfig(
+ new RoutingConfig(null, null,
RoutingConfig.STRICT_REPLICA_GROUP_INSTANCE_SELECTOR_TYPE, false))
+ .setStreamConfigs(getStreamConfigs())
+ .build();
+ try {
+ PinotMd5Mode.setPinotMd5Disabled(true);
+ IllegalStateException exception =
+ expectThrows(IllegalStateException.class, () ->
TableConfigUtils.validateUpsertAndDedupConfig(tableConfig,
+ schema));
+
assertTrue(exception.getMessage().contains(CommonConstants.CONFIG_OF_PINOT_MD5_DISABLED));
+ } finally {
+ PinotMd5Mode.setPinotMd5Disabled(false);
+ }
+ }
+
+ @Test
+ public void testValidateDedupConfigWithMd5Disabled() {
+ Schema schema = new Schema.SchemaBuilder().setSchemaName(TABLE_NAME)
+ .addSingleValueDimension("myCol", FieldSpec.DataType.STRING)
+ .setPrimaryKeyColumns(Lists.newArrayList("myCol"))
+ .build();
+ DedupConfig dedupConfig = new DedupConfig();
+ dedupConfig.setHashFunction(HashFunction.MD5);
+ TableConfig tableConfig = new
TableConfigBuilder(TableType.REALTIME).setTableName(TABLE_NAME)
+ .setDedupConfig(dedupConfig)
+ .setRoutingConfig(
+ new RoutingConfig(null, null,
RoutingConfig.STRICT_REPLICA_GROUP_INSTANCE_SELECTOR_TYPE, false))
+ .setStreamConfigs(getStreamConfigs())
+ .build();
+ try {
+ PinotMd5Mode.setPinotMd5Disabled(true);
+ IllegalStateException exception =
+ expectThrows(IllegalStateException.class, () ->
TableConfigUtils.validateUpsertAndDedupConfig(tableConfig,
+ schema));
+
assertTrue(exception.getMessage().contains(CommonConstants.CONFIG_OF_PINOT_MD5_DISABLED));
+ } finally {
+ PinotMd5Mode.setPinotMd5Disabled(false);
+ }
+ }
+
+ @Test
+ public void testValidateDedupConfigWithMd5DisabledAllowsUpsertModeNoneMd5() {
+ Schema schema = new Schema.SchemaBuilder().setSchemaName(TABLE_NAME)
+ .addSingleValueDimension("myCol", FieldSpec.DataType.STRING)
+ .setPrimaryKeyColumns(Lists.newArrayList("myCol"))
+ .build();
+ DedupConfig dedupConfig = new DedupConfig();
+ dedupConfig.setHashFunction(HashFunction.NONE);
+ UpsertConfig upsertConfig = new UpsertConfig(UpsertConfig.Mode.NONE);
+ upsertConfig.setHashFunction(HashFunction.MD5);
+ TableConfig tableConfig = new
TableConfigBuilder(TableType.REALTIME).setTableName(TABLE_NAME)
+ .setUpsertConfig(upsertConfig)
+ .setDedupConfig(dedupConfig)
+ .setRoutingConfig(
+ new RoutingConfig(null, null,
RoutingConfig.STRICT_REPLICA_GROUP_INSTANCE_SELECTOR_TYPE, false))
+ .setStreamConfigs(getStreamConfigs())
+ .build();
+ try {
+ PinotMd5Mode.setPinotMd5Disabled(true);
+ TableConfigUtils.validateUpsertAndDedupConfig(tableConfig, schema);
+ } finally {
+ PinotMd5Mode.setPinotMd5Disabled(false);
+ }
Review Comment:
The test updates the global `PinotMd5Mode` flag and then forces it back to
`false`. To avoid cross-test interference when the original value was `true`,
capture the original `PinotMd5Mode.isPinotMd5Disabled()` value and restore it
in `finally` instead of hard-coding `false`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]