Skip to content

Commit

Permalink
Added Unit Tests for generate.timeout config
Browse files Browse the repository at this point in the history
  • Loading branch information
garrix-fan committed Aug 3, 2022
1 parent 9728f7e commit b663c97
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DatagenConnectorConfig extends AbstractConfig {
+ "Each task will generate different data than the other tasks in the same connector.";
public static final String GENERATE_TIMEOUT_CONF = "generate.timeout";
private static final String GENERATE_TIMEOUT_DOC = "Timeout in milliseconds for random message "
+ "generation";
+ "generation. This timeout can be configured for upto 1 minute, i.e 60000ms";

public DatagenConnectorConfig(ConfigDef config, Map<String, String> parsedConfig) {
super(config, parsedConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,30 @@ public void shouldNotValidateSchemaKeyFieldWhenMultipleSchemaSourcesAreSet() {
);
}

@Test
public void shouldAllowSettingGenerateTimeoutInRange() {
clearSchemaSources();
config.put(DatagenConnectorConfig.GENERATE_TIMEOUT_CONF, "100");
Config validated = connector.validate(config);
assertThat(validated, hasNoValidationErrorsFor(DatagenConnectorConfig.GENERATE_TIMEOUT_CONF));
}

@Test
public void shouldNotAllowSettingGenerateTimeoutNegative() {
clearSchemaSources();
config.put(DatagenConnectorConfig.GENERATE_TIMEOUT_CONF, "-1");
Config validated = connector.validate(config);
assertThat(validated, hasValidationError(DatagenConnectorConfig.GENERATE_TIMEOUT_CONF, 1));
}

@Test
public void shouldNotAllowSettingGenerateTimeoutOutOfRange() {
clearSchemaSources();
config.put(DatagenConnectorConfig.GENERATE_TIMEOUT_CONF, "70000");
Config validated = connector.validate(config);
assertThat(validated, hasValidationError(DatagenConnectorConfig.GENERATE_TIMEOUT_CONF, 1));
}

protected void assertTaskConfigs(int maxTasks) {
List<Map<String, String>> taskConfigs = connector.taskConfigs(maxTasks);
assertEquals(maxTasks, taskConfigs.size());
Expand Down

0 comments on commit b663c97

Please sign in to comment.