xyuanlu commented on a change in pull request #1129:
URL: https://github.com/apache/helix/pull/1129#discussion_r447266556
##########
File path:
helix-rest/src/test/java/org/apache/helix/rest/server/TestPerInstanceAccessor.java
##########
@@ -463,5 +464,53 @@ public void testValidateWeightForInstance()
// Must have the results saying they are all valid (true) because capacity
keys are set
// in ClusterConfig
node.iterator().forEachRemaining(child ->
Assert.assertTrue(child.getBooleanValue()));
+ System.out.println("End test :" + TestHelper.getTestMethodName());
+ }
+
+ @Test(dependsOnMethods = "testValidateWeightForInstance")
+ public void testValidateDeltaInstanceConfigForUpdate() throws IOException {
+ System.out.println("Start test :" + TestHelper.getTestMethodName());
+ // Enable Topology aware for the cluster
+ ClusterConfig clusterConfig =
_configAccessor.getClusterConfig(CLUSTER_NAME);
+ clusterConfig.getRecord()
+
.setListField(ClusterConfig.ClusterConfigProperty.INSTANCE_CAPACITY_KEYS.name(),
+ new ArrayList<>());
+ clusterConfig.setTopologyAwareEnabled(true);
+ clusterConfig.setTopology("/Rack/Sub-Rack/Host/Instance");
+ clusterConfig.setFaultZoneType("Host");
+ _configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
+
+ String instanceName = CLUSTER_NAME + "localhost_12918";
+ InstanceConfig instanceConfig =
_configAccessor.getInstanceConfig(CLUSTER_NAME, instanceName);
+
+ // Update InstanceConfig with Topology Info
+ String domain = "Rack=rack1, Sub-Rack=Sub-Rack1, Host=Host-1";
+ ZNRecord record = instanceConfig.getRecord();
+
record.getSimpleFields().put(InstanceConfig.InstanceConfigProperty.DOMAIN.name(),
domain);
+
+ // Add these fields by way of "update"
+ Entity entity =
+ Entity.entity(OBJECT_MAPPER.writeValueAsString(record),
MediaType.APPLICATION_JSON_TYPE);
+ Response response = new JerseyUriRequestBuilder(
+ "clusters/{}/instances/{}/configs?command=update&doSanityCheck=true")
+ .format(CLUSTER_NAME, INSTANCE_NAME).post(this, entity);
+ // Check that the fields have been added
+ Assert.assertEquals(response.getStatus(), 200);
+ // Check the cluster config is updated
+ Assert.assertEquals(
+ _configAccessor.getInstanceConfig(CLUSTER_NAME,
instanceName).getDomainAsString(), domain);
+
+ // set domain to an invalid value
+ record.getSimpleFields()
+ .put(InstanceConfig.InstanceConfigProperty.DOMAIN.name(),
"InvalidDomainValue");
+ entity =
+ Entity.entity(OBJECT_MAPPER.writeValueAsString(record),
MediaType.APPLICATION_JSON_TYPE);
+ // Updating using an invalid domain value should return a non-OK response
+ new JerseyUriRequestBuilder(
+ "clusters/{}/instances/{}/configs?command=update&doSanityCheck=true")
+
.expectedReturnStatusCode(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())
+ .format(CLUSTER_NAME, INSTANCE_NAME).post(this, entity);
Review comment:
Yes it will.
When I change the expected status to 200 in line 511 where the actual call
returns 500, I got the following assertion error.
```
java.lang.AssertionError:
Expected :200
Actual :500
at org.testng.Assert.fail(Assert.java:89)
at org.testng.Assert.failNotEquals(Assert.java:480)
at org.testng.Assert.assertEquals(Assert.java:118)
at org.testng.Assert.assertEquals(Assert.java:365)
at org.testng.Assert.assertEquals(Assert.java:375)
at
org.apache.helix.rest.server.util.JerseyUriRequestBuilder.post(JerseyUriRequestBuilder.java:115)
at
org.apache.helix.rest.server.TestPerInstanceAccessor.testValidateDeltaInstanceConfigForUpdate(TestPerInstance
......
at
com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)
```
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]