[GitHub] [incubator-pinot] sunithabeeram commented on a change in pull request #3993: In TableConfig, add checks for mandatory fields

2019-03-20 Thread GitBox
sunithabeeram commented on a change in pull request #3993: In TableConfig, add 
checks for mandatory fields
URL: https://github.com/apache/incubator-pinot/pull/3993#discussion_r267582170
 
 

 ##
 File path: 
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/OfflineClusterIntegrationTest.java
 ##
 @@ -150,6 +152,22 @@ public void testInstancesStarted() {
 }
   }
 
+  @Test
+  public void testInvalidTableConfig() {
+TableConfig tableConfig =
+new 
TableConfig.Builder(CommonConstants.Helix.TableType.OFFLINE).setTableName("badTable").build();
+ObjectNode jsonConfig = tableConfig.toJsonConfig();
+// Remove a mandatory field
+jsonConfig.remove(TableConfig.VALIDATION_CONFIG_KEY);
+try {
+  sendPostRequest(_controllerRequestURLBuilder.forTableCreate(), 
jsonConfig.toString());
+  fail();
+} catch (IOException e) {
+  // Should get response code 400 (BAD_REQUEST)
+  assertTrue(e.getMessage().startsWith("Server returned HTTP response 
code: 400"));
 
 Review comment:
   Can we assert on the rest of the message? (If we don't have access to the 
message at this level, ignore)
   
   The reason is, currently the client does get a 400, but the message is 
"null" which makes it hard to debug.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org



[GitHub] [incubator-pinot] sunithabeeram commented on a change in pull request #3993: In TableConfig, add checks for mandatory fields

2019-03-20 Thread GitBox
sunithabeeram commented on a change in pull request #3993: In TableConfig, add 
checks for mandatory fields
URL: https://github.com/apache/incubator-pinot/pull/3993#discussion_r267479988
 
 

 ##
 File path: 
pinot-common/src/main/java/org/apache/pinot/common/config/TableConfig.java
 ##
 @@ -118,14 +118,24 @@ public static TableConfig fromJsonString(String 
jsonString)
   @Nonnull
   public static TableConfig fromJSONConfig(@Nonnull JsonNode jsonConfig)
   throws IOException {
+// Mandatory fields
+Preconditions.checkState(jsonConfig.has(TABLE_TYPE_KEY), "Table type is 
missing");
 TableType tableType = 
TableType.valueOf(jsonConfig.get(TABLE_TYPE_KEY).asText().toUpperCase());
+Preconditions.checkState(jsonConfig.has(TABLE_NAME_KEY), "Table name is 
missing");
 String tableName = 
TableNameBuilder.forType(tableType).tableNameWithType(jsonConfig.get(TABLE_NAME_KEY).asText());
-
+Preconditions
+.checkState(jsonConfig.has(VALIDATION_CONFIG_KEY), "Mandatory config 
'%s' is missing", VALIDATION_CONFIG_KEY);
 SegmentsValidationAndRetentionConfig validationConfig =
 extractChildConfig(jsonConfig, VALIDATION_CONFIG_KEY, 
SegmentsValidationAndRetentionConfig.class);
+Preconditions.checkState(jsonConfig.has(TENANT_CONFIG_KEY), "Mandatory 
config '%s' is missing", TENANT_CONFIG_KEY);
 TenantConfig tenantConfig = extractChildConfig(jsonConfig, 
TENANT_CONFIG_KEY, TenantConfig.class);
+Preconditions
+.checkState(jsonConfig.has(INDEXING_CONFIG_KEY), "Mandatory config 
'%s' is missing", INDEXING_CONFIG_KEY);
 
 Review comment:
   Are INDEXING and CUSTOM configs really mandatory?


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org