Search in sources :

Example 26 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestClusterTest method testChangeClusterVersion.

@Test
public void testChangeClusterVersion() throws IOException {
    Config config = createConfigWithRestEnabled();
    final HazelcastInstance instance = factory.newHazelcastInstance(config);
    final HTTPCommunicator communicator = new HTTPCommunicator(instance);
    String clusterName = config.getClusterName();
    ConnectionResponse resp = communicator.changeClusterVersion(clusterName, getPassword(), instance.getCluster().getClusterVersion().toString());
    assertSuccessJson(resp, "version", instance.getCluster().getClusterVersion().toString());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RestApiConfig(com.hazelcast.config.RestApiConfig) HazelcastTestSupport.smallInstanceConfig(com.hazelcast.test.HazelcastTestSupport.smallInstanceConfig) Config(com.hazelcast.config.Config) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 27 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestClusterTest method testHeadRequest_ClusterHealth.

@Test
public void testHeadRequest_ClusterHealth() throws Exception {
    HazelcastInstance instance = factory.newHazelcastInstance(createConfigWithRestEnabled());
    factory.newHazelcastInstance(createConfigWithRestEnabled());
    HTTPCommunicator communicator = new HTTPCommunicator(instance);
    ConnectionResponse response = communicator.headRequestToClusterHealthURI();
    assertEquals(HttpURLConnection.HTTP_OK, response.responseCode);
    assertEquals(response.responseHeaders.get("Hazelcast-NodeState").size(), 1);
    assertContains(response.responseHeaders.get("Hazelcast-NodeState"), "ACTIVE");
    assertEquals(response.responseHeaders.get("Hazelcast-ClusterState").size(), 1);
    assertContains(response.responseHeaders.get("Hazelcast-ClusterState"), "ACTIVE");
    assertEquals(response.responseHeaders.get("Hazelcast-ClusterSize").size(), 1);
    assertContains(response.responseHeaders.get("Hazelcast-ClusterSize"), "2");
    assertEquals(response.responseHeaders.get("Hazelcast-MigrationQueueSize").size(), 1);
    assertContains(response.responseHeaders.get("Hazelcast-MigrationQueueSize"), "0");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestClusterTest method testListNodes.

@Test
public void testListNodes() throws Exception {
    Config config = createConfigWithRestEnabled();
    HazelcastInstance instance = factory.newHazelcastInstance(config);
    HTTPCommunicator communicator = new HTTPCommunicator(instance);
    HazelcastTestSupport.waitInstanceForSafeState(instance);
    String clusterName = config.getClusterName();
    ConnectionResponse resp = communicator.listClusterNodes(clusterName, getPassword());
    assertSuccessJson(resp, "response", String.format("[%s]\n%s\n%s", instance.getCluster().getLocalMember().toString(), BuildInfoProvider.getBuildInfo().getVersion(), System.getProperty("java.version")));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) RestApiConfig(com.hazelcast.config.RestApiConfig) HazelcastTestSupport.smallInstanceConfig(com.hazelcast.test.HazelcastTestSupport.smallInstanceConfig) Config(com.hazelcast.config.Config) RestServerEndpointConfig(com.hazelcast.config.RestServerEndpointConfig) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 29 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestTest method testBad_PostRequest.

@Test
public void testBad_PostRequest() throws IOException {
    ConnectionResponse resp = communicator.postBadRequestURI();
    assertEquals(HTTP_BAD_REQUEST, resp.responseCode);
    assertJsonContains(resp.response, "status", "fail", "message", "Missing map name");
}
Also used : ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 30 with ConnectionResponse

use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.

the class RestCPSubsystemTest method test_promoteAPMemberToCPMember_withInvalidCredentials.

@Test
public void test_promoteAPMemberToCPMember_withInvalidCredentials() throws IOException, ExecutionException, InterruptedException {
    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    Hazelcast.newHazelcastInstance(config);
    Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance4 = Hazelcast.newHazelcastInstance(config);
    ConnectionResponse response = new HTTPCommunicator(instance4).promoteCPMember("x", "x");
    assertEquals(403, response.responseCode);
    Collection<CPMember> cpMembers = instance1.getCPSubsystem().getCPSubsystemManagementService().getCPMembers().toCompletableFuture().get();
    assertEquals(3, cpMembers.size());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) CPMember(com.hazelcast.cp.CPMember) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)39 Test (org.junit.Test)39 HazelcastInstance (com.hazelcast.core.HazelcastInstance)36 SlowTest (com.hazelcast.test.annotation.SlowTest)25 QuickTest (com.hazelcast.test.annotation.QuickTest)14 CPMember (com.hazelcast.cp.CPMember)11 Config (com.hazelcast.config.Config)10 RestApiConfig (com.hazelcast.config.RestApiConfig)10 RestServerEndpointConfig (com.hazelcast.config.RestServerEndpointConfig)10 HazelcastTestSupport.smallInstanceConfig (com.hazelcast.test.HazelcastTestSupport.smallInstanceConfig)10 JsonArray (com.hazelcast.internal.json.JsonArray)6 JsonObject (com.hazelcast.internal.json.JsonObject)6 JsonValue (com.hazelcast.internal.json.JsonValue)5 CPSession (com.hazelcast.cp.session.CPSession)2 CPGroup (com.hazelcast.cp.CPGroup)1 IAtomicLong (com.hazelcast.cp.IAtomicLong)1 RaftGroupId (com.hazelcast.cp.internal.RaftGroupId)1