Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chenselena committed Oct 16, 2024
1 parent 8683b86 commit 922a036
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@ public void testUpdateSucceedsForReplicationConfig() throws Exception {
Assertions.assertEquals(
updatedPolicies.get("replication").get("config").toString(),
"[{\"destination\":\"clusterA\",\"interval\":\"24H\"}]");
RequestAndValidateHelper.deleteTableAndValidateResponse(mvc, GET_TABLE_RESPONSE_BODY);
}

@Test
Expand Down Expand Up @@ -1096,5 +1097,6 @@ public void testUpdateSucceedsForMultipleReplicationConfig() throws Exception {
Assertions.assertEquals(
updatedPolicies.get("replication").get("config").toString(),
"[{\"destination\":\"clusterA\",\"interval\":\"24H\"},{\"destination\":\"clusterB\",\"interval\":\"12H\"}]");
RequestAndValidateHelper.deleteTableAndValidateResponse(mvc, GET_TABLE_RESPONSE_BODY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.linkedin.openhouse.tables.api.spec.v0.request.UpdateAclPoliciesRequestBody;
import com.linkedin.openhouse.tables.api.spec.v0.request.components.ClusteringColumn;
import com.linkedin.openhouse.tables.api.spec.v0.request.components.Policies;
import com.linkedin.openhouse.tables.api.spec.v0.request.components.Replication;
import com.linkedin.openhouse.tables.api.spec.v0.request.components.ReplicationConfig;
import com.linkedin.openhouse.tables.api.spec.v0.request.components.Retention;
import com.linkedin.openhouse.tables.api.spec.v0.request.components.RetentionColumnPattern;
import com.linkedin.openhouse.tables.api.spec.v0.request.components.TimePartitionSpec;
Expand Down Expand Up @@ -282,6 +284,107 @@ public void validateCreateTableRequestParamWithInvalidDaysInPoliciesObject() {
}
}

@Test
public void validateCreateTableRequestParamWithInvalidReplicationClusterInPoliciesObject() {
assertThrows(
RequestValidationFailureException.class,
() ->
tablesApiValidator.validateCreateTable(
"c",
"d",
CreateUpdateTableRequestBody.builder()
.databaseId("d")
.tableId("t")
.clusterId("c")
.schema(HEALTH_SCHEMA_LITERAL)
.tableProperties(ImmutableMap.of())
.timePartitioning(
TimePartitionSpec.builder()
.columnName("timestamp")
.granularity(TimePartitionSpec.Granularity.HOUR)
.build())
.policies(
Policies.builder()
.replication(
Replication.builder()
.config(
Arrays.asList(
ReplicationConfig.builder().destination("c").build()))
.build())
.build())
.baseTableVersion("base")
.build()));
}

@Test
public void validateCreateTableRequestParamWithInvalidReplicationIntervalInPoliciesObject() {
assertThrows(
RequestValidationFailureException.class,
() ->
tablesApiValidator.validateCreateTable(
"c",
"d",
CreateUpdateTableRequestBody.builder()
.databaseId("d")
.tableId("t")
.clusterId("c")
.schema(HEALTH_SCHEMA_LITERAL)
.tableProperties(ImmutableMap.of())
.timePartitioning(
TimePartitionSpec.builder()
.columnName("timestamp")
.granularity(TimePartitionSpec.Granularity.HOUR)
.build())
.policies(
Policies.builder()
.replication(
Replication.builder()
.config(
Arrays.asList(
ReplicationConfig.builder()
.destination("z")
.interval("13H")
.build()))
.build())
.build())
.baseTableVersion("base")
.build()));
}

@Test
public void validateCreateTableRequestParamWithValidReplicationInPoliciesObject() {
assertDoesNotThrow(
() ->
tablesApiValidator.validateCreateTable(
"c",
"d",
CreateUpdateTableRequestBody.builder()
.databaseId("d")
.tableId("t")
.clusterId("c")
.schema(HEALTH_SCHEMA_LITERAL)
.tableProperties(ImmutableMap.of())
.timePartitioning(
TimePartitionSpec.builder()
.columnName("timestamp")
.granularity(TimePartitionSpec.Granularity.HOUR)
.build())
.policies(
Policies.builder()
.replication(
Replication.builder()
.config(
Arrays.asList(
ReplicationConfig.builder()
.destination("z")
.interval("12H")
.build()))
.build())
.build())
.baseTableVersion("base")
.build()));
}

@Test
public void validateCreateTableSpecialCharacterAndEmpty() {
assertThrows(
Expand Down

0 comments on commit 922a036

Please sign in to comment.