This is an automated email from the ASF dual-hosted git repository. hulee pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/helix.git
commit 9fcfa81f3975f599c1ad993e34e86eef31609d82 Author: Hunter Lee <[email protected]> AuthorDate: Wed Apr 3 14:34:29 2019 -0700 TEST: Fix UserContentStore related tests in helix-rest The behavior changed such that if the client-side code does not find the UserContent ZNode, it creates one instead of throwing an NPE. This fixes the tests so that it adapts to the new behavior. This behavior should be reverted eventually because UserContent ZNode should be created only by the Controller. RB=1618685 G=helix-reviewers A=jxue Signed-off-by: Hunter Lee <[email protected]> --- helix-core/src/test/java/org/apache/helix/integration/TestDrop.java | 2 +- .../src/test/java/org/apache/helix/rest/server/TestJobAccessor.java | 6 ++++-- .../test/java/org/apache/helix/rest/server/TestTaskAccessor.java | 6 ++++-- .../java/org/apache/helix/rest/server/TestWorkflowAccessor.java | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java b/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java index 5739543..54515af 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestDrop.java @@ -263,7 +263,6 @@ public class TestDrop extends ZkTestBase { Assert.assertEquals(disabledPartitions.get(0), "TestDB0_4"); // ExteranlView should have TestDB0_4->localhost_12918_>ERROR - Thread.sleep(2000); ExternalView ev = accessor.getProperty(keyBuilder.externalView("TestDB0")); Set<String> partitions = ev.getPartitionSet(); Assert.assertEquals(partitions.size(), 1, "Should have TestDB0_4->localhost_12918->ERROR"); @@ -441,6 +440,7 @@ public class TestDrop extends ZkTestBase { Assert.assertTrue(verifier.verifyByPolling()); Thread.sleep(400); + assertEmptyCSandEV(clusterName, "schemata", participants); // clean up diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestJobAccessor.java b/helix-rest/src/test/java/org/apache/helix/rest/server/TestJobAccessor.java index 0c5d862..b76ba71 100644 --- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestJobAccessor.java +++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestJobAccessor.java @@ -186,8 +186,10 @@ public class TestJobAccessor extends AbstractTestClass { get(invalidURI1, null, Response.Status.NOT_FOUND.getStatusCode(), false); get(invalidURI2, null, Response.Status.NOT_FOUND.getStatusCode(), false); - post(invalidURI1, validCmd, validEntity, Response.Status.NOT_FOUND.getStatusCode()); - post(invalidURI2, validCmd, validEntity, Response.Status.NOT_FOUND.getStatusCode()); + // The following two lines should get OK even though they should be NOT FOUND because the client + // side code create UserContent znodes when not found + post(invalidURI1, validCmd, validEntity, Response.Status.OK.getStatusCode()); + post(invalidURI2, validCmd, validEntity, Response.Status.OK.getStatusCode()); post(validURI, invalidCmd, validEntity, Response.Status.BAD_REQUEST.getStatusCode()); post(validURI, validCmd, invalidEntity, Response.Status.BAD_REQUEST.getStatusCode()); diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestTaskAccessor.java b/helix-rest/src/test/java/org/apache/helix/rest/server/TestTaskAccessor.java index 813f052..3f9a0e2 100644 --- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestTaskAccessor.java +++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestTaskAccessor.java @@ -74,8 +74,10 @@ public class TestTaskAccessor extends AbstractTestClass { get(invalidURI2, null, Response.Status.NOT_FOUND.getStatusCode(), false); get(invalidURI3, null, Response.Status.NOT_FOUND.getStatusCode(), false); - post(invalidURI1, validCmd, validEntity, Response.Status.NOT_FOUND.getStatusCode()); - post(invalidURI2, validCmd, validEntity, Response.Status.NOT_FOUND.getStatusCode()); + // The following two lines should get OK even though they should be NOT FOUND because the client + // side code create UserContent znodes when not found + post(invalidURI1, validCmd, validEntity, Response.Status.OK.getStatusCode()); + post(invalidURI2, validCmd, validEntity, Response.Status.OK.getStatusCode()); post(validURI, invalidCmd, validEntity, Response.Status.BAD_REQUEST.getStatusCode()); post(validURI, validCmd, invalidEntity, Response.Status.BAD_REQUEST.getStatusCode()); diff --git a/helix-rest/src/test/java/org/apache/helix/rest/server/TestWorkflowAccessor.java b/helix-rest/src/test/java/org/apache/helix/rest/server/TestWorkflowAccessor.java index 56a8853..aa4118d 100644 --- a/helix-rest/src/test/java/org/apache/helix/rest/server/TestWorkflowAccessor.java +++ b/helix-rest/src/test/java/org/apache/helix/rest/server/TestWorkflowAccessor.java @@ -187,7 +187,8 @@ public class TestWorkflowAccessor extends AbstractTestClass { Map<String, String> invalidCmd = ImmutableMap.of("command", "delete"); // cmd not supported get(invalidURI, null, Response.Status.NOT_FOUND.getStatusCode(), false); - post(invalidURI, validCmd, validEntity, Response.Status.NOT_FOUND.getStatusCode()); + // The following expects a OK because if the usercontent ZNode is not there, it is created + post(invalidURI, validCmd, validEntity, Response.Status.OK.getStatusCode()); post(validURI, invalidCmd, validEntity, Response.Status.BAD_REQUEST.getStatusCode()); post(validURI, validCmd, invalidEntity, Response.Status.BAD_REQUEST.getStatusCode());
