use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_forceDestroyCPGroup_withInvalidCredentials.
@Test
public void test_forceDestroyCPGroup_withInvalidCredentials() throws IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
instance1.getCPSubsystem().getAtomicLong("long1");
ConnectionResponse response = new HTTPCommunicator(instance1).forceDestroyCPGroup(DEFAULT_GROUP_NAME, "x", "x");
assertEquals(403, response.responseCode);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_forceCloseInvalidCPSession.
@Test
public void test_forceCloseInvalidCPSession() throws IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
instance1.getCPSubsystem().getAtomicLong("long1").set(5);
ConnectionResponse response1 = new HTTPCommunicator(instance1).forceCloseCPSession(DEFAULT_GROUP_NAME, 1, clusterName, null);
assertEquals(400, response1.responseCode);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_getMetadataCPGroupByName.
@Test
public void test_getMetadataCPGroupByName() throws IOException {
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
waitUntilCPDiscoveryCompleted(instance1, instance2, instance3);
HTTPCommunicator communicator = new HTTPCommunicator(instance1);
ConnectionResponse response = communicator.getCPGroupByName(METADATA_CP_GROUP_NAME);
assertEquals(200, response.responseCode);
CPMember cpMember1 = instance1.getCPSubsystem().getLocalCPMember();
CPMember cpMember2 = instance2.getCPSubsystem().getLocalCPMember();
CPMember cpMember3 = instance3.getCPSubsystem().getLocalCPMember();
boolean cpMember1Found = false;
boolean cpMember2Found = false;
boolean cpMember3Found = false;
JsonObject json = (JsonObject) Json.parse(response.response);
assertEquals(METADATA_CP_GROUP_NAME, ((JsonObject) json.get("id")).getString("name", ""));
assertEquals(CPGroupStatus.ACTIVE.name(), json.getString("status", ""));
for (JsonValue val : (JsonArray) json.get("members")) {
JsonObject mem = (JsonObject) val;
cpMember1Found |= cpMember1.getUuid().equals(UUID.fromString(mem.getString("uuid", "")));
cpMember2Found |= cpMember2.getUuid().equals(UUID.fromString(mem.getString("uuid", "")));
cpMember3Found |= cpMember3.getUuid().equals(UUID.fromString(mem.getString("uuid", "")));
}
assertTrue(cpMember1Found);
assertTrue(cpMember2Found);
assertTrue(cpMember3Found);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_promoteExistingCPMember.
@Test
public void test_promoteExistingCPMember() throws IOException, ExecutionException, InterruptedException {
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
waitUntilCPDiscoveryCompleted(instance1);
ConnectionResponse response = new HTTPCommunicator(instance1).promoteCPMember(clusterName, null);
assertEquals(200, response.responseCode);
Collection<CPMember> cpMembers = instance1.getCPSubsystem().getCPSubsystemManagementService().getCPMembers().toCompletableFuture().get();
assertEquals(3, cpMembers.size());
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_reset.
@Test
public void test_reset() throws ExecutionException, InterruptedException, IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
instance1.getCPSubsystem().getAtomicLong("long1").set(5);
CPGroup cpGroup1 = instance1.getCPSubsystem().getCPSubsystemManagementService().getCPGroup(DEFAULT_GROUP_NAME).toCompletableFuture().get();
sleepAtLeastMillis(10);
ConnectionResponse response = new HTTPCommunicator(instance1).restart(clusterName, null);
assertEquals(200, response.responseCode);
instance1.getCPSubsystem().getAtomicLong("long1").set(5);
CPGroup cpGroup2 = instance1.getCPSubsystem().getCPSubsystemManagementService().getCPGroup(DEFAULT_GROUP_NAME).toCompletableFuture().get();
RaftGroupId id1 = (RaftGroupId) cpGroup1.id();
RaftGroupId id2 = (RaftGroupId) cpGroup2.id();
assertTrue(id2.getSeed() > id1.getSeed());
}
Aggregations