From 9e9ac372727f4984e4c74efa6fea86a18548fa12 Mon Sep 17 00:00:00 2001 From: Mathieu Carbou Date: Fri, 16 Dec 2016 18:23:57 -0500 Subject: [PATCH] :white_check_mark: #191: Failover Galvan tests --- .../integration/tests/AbstractHATest.java | 6 + .../integration/tests/FailoverIT.java | 20 +- .../integration/tests/PassiveLeaveIT.java | 70 +++ .../integration/tests/PassiveStartupIT.java | 126 +++++ .../{HAIT.java => PassiveTopologyIT.java} | 58 +-- .../integration/tests/StartupIT.java | 167 ------- .../src/test/resources/passive.json | 447 ++++++++++++++++++ 7 files changed, 679 insertions(+), 215 deletions(-) create mode 100644 management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveLeaveIT.java create mode 100644 management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveStartupIT.java rename management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/{HAIT.java => PassiveTopologyIT.java} (54%) delete mode 100644 management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/StartupIT.java create mode 100644 management/testing/integration-tests/src/test/resources/passive.json diff --git a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/AbstractHATest.java b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/AbstractHATest.java index b904d50712..19096ff2eb 100644 --- a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/AbstractHATest.java +++ b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/AbstractHATest.java @@ -18,6 +18,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Rule; +import org.junit.rules.TestName; import org.terracotta.testing.rules.BasicExternalCluster; import java.io.File; @@ -41,8 +42,12 @@ public abstract class AbstractHATest extends AbstractTest { public org.terracotta.testing.rules.Cluster voltron = new BasicExternalCluster(new File("target/galvan"), 2, emptyList(), "", resourceConfig, ""); + @Rule + public TestName testName = new TestName(); + @Before public void setUp() throws Exception { + System.out.println(" => [" + testName.getMethodName() + "] " + getClass().getSimpleName() + ".setUp()"); voltron.getClusterControl().waitForActive(); voltron.getClusterControl().waitForRunningPassivesInStandby(); commonSetUp(voltron); @@ -51,6 +56,7 @@ public void setUp() throws Exception { @After public void tearDown() throws Exception { + System.out.println(" => [" + testName.getMethodName() + "] " + getClass().getSimpleName() + ".tearDown()"); commonTearDown(); } diff --git a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/FailoverIT.java b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/FailoverIT.java index 76447651f0..cfe869a9f0 100644 --- a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/FailoverIT.java +++ b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/FailoverIT.java @@ -32,7 +32,8 @@ /** * @author Mathieu Carbou */ -@Ignore // TODO activate +@Ignore("Impacted by https://github.com/Terracotta-OSS/terracotta-core/issues/405") +//TODO: VOLTRON ISSUE ? https://github.com/Terracotta-OSS/terracotta-core/issues/405 public class FailoverIT extends AbstractHATest { @Test @@ -47,9 +48,12 @@ public void failover_management() throws Exception { tmsAgentService.readMessages(); // kill active - passive should take the active role + System.out.printf("==> terminateActive()"); voltron.getClusterControl().terminateActive(); + System.out.printf("==> waitForActive()"); voltron.getClusterControl().waitForActive(); + System.out.printf("==> readTopology()"); cluster = tmsAgentService.readTopology(); Server newActive = cluster.serverStream().filter(Server::isActive).findFirst().get(); assertThat(newActive.getState(), equalTo(Server.State.ACTIVE)); @@ -57,6 +61,9 @@ public void failover_management() throws Exception { // read messages List messages = tmsAgentService.readMessages(); + + messages.forEach(System.out::println); + assertThat(messages.size(), equalTo(3)); List notifs = messages.stream() @@ -79,4 +86,15 @@ public void failover_management() throws Exception { //- check notification that might be there: CLIENT_RECONNECTED and SERVER_ENTITY_FAILOVER_COMPLETE } + @Test + public void puts_can_be_seen_on_other_clients_after_failover() throws Exception { + put(0, "clients", "client1", "Mathieu"); + + // kill active - passive should take the active role + voltron.getClusterControl().terminateActive(); + voltron.getClusterControl().waitForActive(); + + assertThat(get(1, "clients", "client1"), equalTo("Mathieu")); + } + } diff --git a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveLeaveIT.java b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveLeaveIT.java new file mode 100644 index 0000000000..cdbd67a1ca --- /dev/null +++ b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveLeaveIT.java @@ -0,0 +1,70 @@ +/* + * Copyright Terracotta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.terracotta.management.integration.tests; + +import org.junit.Test; +import org.terracotta.management.model.cluster.Server; +import org.terracotta.management.model.message.Message; +import org.terracotta.management.model.notification.ContextualNotification; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** + * @author Mathieu Carbou + */ +public class PassiveLeaveIT extends AbstractHATest { + + @Test + public void get_notifications_when_passive_leaves() throws Exception { + Server active = tmsAgentService.readTopology().serverStream().filter(Server::isActive).findFirst().get(); + Server passive = tmsAgentService.readTopology().serverStream().filter(server -> !server.isActive()).findFirst().get(); + assertThat(active.getState(), equalTo(Server.State.ACTIVE)); + assertThat(passive.getState(), equalTo(Server.State.PASSIVE)); + + // clear notification buffer + tmsAgentService.readMessages(); + + // remove one passive + voltron.getClusterControl().terminateOnePassive(); + + // wait for SERVER_LEFT message + List messages; + do { + messages = tmsAgentService.readMessages(); + } + while (messages.isEmpty() && !Thread.currentThread().isInterrupted()); + + assertThat(messages.stream() + .filter(message -> message.getType().equals("NOTIFICATION")) + .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) + .map(ContextualNotification::getType) + .collect(Collectors.toList()), + equalTo(Arrays.asList("SERVER_LEFT"))); + + assertThat(messages.stream() + .filter(message -> message.getType().equals("NOTIFICATION")) + .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) + .map(contextualNotification -> contextualNotification.getContext().get(Server.NAME_KEY)) + .collect(Collectors.toList()), + equalTo(Arrays.asList(passive.getServerName()))); + } + +} diff --git a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveStartupIT.java b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveStartupIT.java new file mode 100644 index 0000000000..9819351b73 --- /dev/null +++ b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveStartupIT.java @@ -0,0 +1,126 @@ +/* + * Copyright Terracotta, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.terracotta.management.integration.tests; + +import org.junit.Before; +import org.junit.Test; +import org.terracotta.management.model.cluster.Server; +import org.terracotta.management.model.message.Message; +import org.terracotta.management.model.notification.ContextualNotification; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.core.IsCollectionContaining.hasItem; +import static org.junit.Assert.assertThat; + +/** + * @author Mathieu Carbou + */ +public class PassiveStartupIT extends AbstractHATest { + + @Before + @Override + public void setUp() throws Exception { + System.out.println(" => [" + testName.getMethodName() + "] " + getClass().getSimpleName() + ".setUp()"); + + // this sequence is so tha twe can have a stripe of 2 servers bu starting with only 1 active + // galvan does not have an easier way to do that + voltron.getClusterControl().waitForActive(); + voltron.getClusterControl().waitForRunningPassivesInStandby(); + voltron.getClusterControl().terminateOnePassive(); + + commonSetUp(voltron); + tmsAgentService.readMessages(); + } + + @Test + public void get_notifications_when_passive_joins() throws Exception { + put(0, "clients", "client1", "Mat"); + + // start a passive after management is connected to active + voltron.getClusterControl().startOneServer(); + voltron.getClusterControl().waitForRunningPassivesInStandby(); + + assertThat(get(1, "clients", "client1"), equalTo("Mat")); + + Server active = tmsAgentService.readTopology().serverStream().filter(Server::isActive).findFirst().get(); + Server passive = tmsAgentService.readTopology().serverStream().filter(server -> !server.isActive()).findFirst().get(); + assertThat(active.getState(), equalTo(Server.State.ACTIVE)); + assertThat(passive.getState(), equalTo(Server.State.PASSIVE)); + + // read messages + List messages = tmsAgentService.readMessages(); + assertThat(messages.size(), equalTo(13)); + Map> map = messages.stream().collect(Collectors.groupingBy(Message::getType)); + assertThat(map.size(), equalTo(2)); + assertThat(map.keySet(), hasItem("TOPOLOGY")); + assertThat(map.keySet(), hasItem("NOTIFICATION")); + assertThat(map.get("NOTIFICATION").size(), equalTo(12)); + + List notifs = map.get("NOTIFICATION").stream() + .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) + .collect(Collectors.toList()); + + // test notifications generated on active from passive "actions" + assertThat( + notifs.stream().map(ContextualNotification::getType).collect(Collectors.toList()), + equalTo(Arrays.asList( + "SERVER_JOINED", + "SERVER_STATE_CHANGED", + "SERVER_ENTITY_CREATED", + "SERVER_ENTITY_CREATED", "ENTITY_REGISTRY_AVAILABLE", + "SERVER_ENTITY_CREATED", "ENTITY_REGISTRY_AVAILABLE", "ENTITY_REGISTRY_UPDATED", + "SERVER_ENTITY_CREATED", "ENTITY_REGISTRY_AVAILABLE", "ENTITY_REGISTRY_UPDATED", + "SERVER_STATE_CHANGED"))); + + // only 1 server in source: passive server + assertThat( + notifs.stream().map(contextualNotification -> contextualNotification.getContext().get(Server.NAME_KEY)).collect(Collectors.toSet()), + equalTo(new HashSet<>(Arrays.asList(passive.getServerName())))); + + // test state transition of passive + assertThat( + Stream.of(1, 11).map(idx -> notifs.get(idx).getAttributes().get("state")).collect(Collectors.toList()), + equalTo(Arrays.asList("SYNCHRONIZING", "PASSIVE"))); + + // wait for SYNC_END message to transit from passive to active + do { + messages = tmsAgentService.readMessages(); + } + while (messages.isEmpty() && !Thread.currentThread().isInterrupted()); + + assertThat(messages.stream() + .filter(message -> message.getType().equals("NOTIFICATION")) + .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) + .map(ContextualNotification::getType) + .collect(Collectors.toList()), + equalTo(Arrays.asList("SYNC_END", "SYNC_END"))); + + assertThat(messages.stream() + .filter(message -> message.getType().equals("NOTIFICATION")) + .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) + .map(contextualNotification -> contextualNotification.getContext().get(Server.NAME_KEY)) + .collect(Collectors.toList()), + equalTo(Arrays.asList(passive.getServerName(), passive.getServerName()))); + } + +} diff --git a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/HAIT.java b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveTopologyIT.java similarity index 54% rename from management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/HAIT.java rename to management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveTopologyIT.java index bc38dcd2a0..4a751864ca 100644 --- a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/HAIT.java +++ b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/PassiveTopologyIT.java @@ -15,31 +15,22 @@ */ package org.terracotta.management.integration.tests; -import org.junit.Ignore; import org.junit.Test; import org.terracotta.management.model.capabilities.descriptors.Settings; import org.terracotta.management.model.cluster.Cluster; import org.terracotta.management.model.cluster.Server; import org.terracotta.management.model.cluster.ServerEntity; -import org.terracotta.management.model.message.Message; -import org.terracotta.management.model.notification.ContextualNotification; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; +import java.io.File; +import java.io.FileWriter; import java.util.stream.Stream; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.core.IsCollectionContaining.hasItem; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; /** * @author Mathieu Carbou */ -@Ignore // TODO activate -public class HAIT extends AbstractHATest { +public class PassiveTopologyIT extends AbstractHATest { @Test public void topology_includes_passives() throws Exception { @@ -51,6 +42,9 @@ public void topology_includes_passives() throws Exception { server.setActivateTime(0); server.setStartTime(0); server.setBuildId("Build ID"); + server.setVersion(""); + server.setGroupPort(0); + server.setBindPort(0); }); cluster.serverEntityStream() @@ -72,43 +66,13 @@ public void topology_includes_passives() throws Exception { cluster.clientStream().forEach(client -> currentPassive[0] = currentPassive[0] .replace(passive.getServerName(), "stripe-PASSIVE")); + // please leave this: easy to compare if something changes + /*FileWriter w = new FileWriter(new File("target/out.json")); + w.write(currentPassive[0]); + w.close();*/ + // and compare assertEquals(readJson("passive.json").toString(), currentPassive[0]); } - @Test - public void get_notifications_when_passive_leaves() throws Exception { - Server active = tmsAgentService.readTopology().serverStream().filter(Server::isActive).findFirst().get(); - Server passive = tmsAgentService.readTopology().serverStream().filter(server -> !server.isActive()).findFirst().get(); - assertThat(active.getState(), equalTo(Server.State.ACTIVE)); - assertThat(passive.getState(), equalTo(Server.State.PASSIVE)); - - // clear notification buffer - tmsAgentService.readMessages(); - - // remove one passive - voltron.getClusterControl().terminateOnePassive(); - - // read messages - List messages = tmsAgentService.readMessages(); - assertThat(messages.size(), equalTo(2)); - Map> map = messages.stream().collect(Collectors.groupingBy(Message::getType)); - assertThat(map.size(), equalTo(2)); - assertThat(map.keySet(), hasItem("TOPOLOGY")); - assertThat(map.keySet(), hasItem("NOTIFICATION")); - assertThat(map.get("NOTIFICATION").size(), equalTo(1)); - - List notifs = map.get("NOTIFICATION").stream() - .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) - .collect(Collectors.toList()); - - assertThat( - notifs.stream().map(ContextualNotification::getType).collect(Collectors.toList()), - equalTo(Arrays.asList("SERVER_LEFT"))); - - assertThat( - notifs.get(0).getContext().get(Server.NAME_KEY), - equalTo(passive.getServerName())); - } - } diff --git a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/StartupIT.java b/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/StartupIT.java deleted file mode 100644 index 047087df80..0000000000 --- a/management/testing/integration-tests/src/test/java/org/terracotta/management/integration/tests/StartupIT.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright Terracotta, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.terracotta.management.integration.tests; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.terracotta.management.model.cluster.Cluster; -import org.terracotta.management.model.cluster.Server; -import org.terracotta.management.model.message.Message; -import org.terracotta.management.model.notification.ContextualNotification; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.core.IsCollectionContaining.hasItem; -import static org.junit.Assert.assertThat; - -/** - * @author Mathieu Carbou - */ -@Ignore // TODO activate -public class StartupIT extends AbstractHATest { - - @Before - @Override - public void setUp() throws Exception { - // this sequence is so tha twe can have a stripe of 2 servers bu starting with only 1 active - // galvan does not have an easier way to do that - voltron.getClusterControl().waitForActive(); - voltron.getClusterControl().waitForRunningPassivesInStandby(); - voltron.getClusterControl().terminateOnePassive(); - - commonSetUp(voltron); - tmsAgentService.readMessages(); - - // start a passive after management is connected to active - voltron.getClusterControl().startOneServer(); - voltron.getClusterControl().waitForRunningPassivesInStandby(); - } - - @Test - public void get_notifications_when_passive_joins() throws Exception { - Server active = tmsAgentService.readTopology().serverStream().filter(Server::isActive).findFirst().get(); - Server passive = tmsAgentService.readTopology().serverStream().filter(server -> !server.isActive()).findFirst().get(); - assertThat(active.getState(), equalTo(Server.State.ACTIVE)); - assertThat(passive.getState(), equalTo(Server.State.PASSIVE)); - - // read messages - List messages = tmsAgentService.readMessages(); - assertThat(messages.size(), equalTo(20)); - Map> map = messages.stream().collect(Collectors.groupingBy(Message::getType)); - assertThat(map.size(), equalTo(2)); - assertThat(map.keySet(), hasItem("TOPOLOGY")); - assertThat(map.keySet(), hasItem("NOTIFICATION")); - assertThat(map.get("NOTIFICATION").size(), equalTo(19)); - - List notifs = map.get("NOTIFICATION").stream() - .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) - .collect(Collectors.toList()); - - assertThat( - notifs.stream().map(ContextualNotification::getType).collect(Collectors.toList()), - equalTo(Arrays.asList( - "SERVER_JOINED", - "SERVER_STATE_CHANGED", "SERVER_STATE_CHANGED", - "SERVER_ENTITY_CREATED", - "ENTITY_REGISTRY_AVAILABLE", "ENTITY_REGISTRY_UPDATED", "SERVER_CACHE_CREATED", - "SYNC_START", "SYNC_END", - "SERVER_ENTITY_CREATED", "ENTITY_REGISTRY_AVAILABLE", "SERVER_ENTITY_CREATED", "ENTITY_REGISTRY_AVAILABLE", "ENTITY_REGISTRY_UPDATED", "SERVER_CACHE_CREATED", - "SYNC_START", "SYNC_END", - "SERVER_ENTITY_CREATED", "SERVER_STATE_CHANGED"))); - - List serverStateNotifs = messages.stream() - .filter(message -> message.getType().equals("NOTIFICATION")) - .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) - .filter(notif -> notif.getType().equals("SERVER_STATE_CHANGED")) - .collect(Collectors.toList()); - - assertThat( - serverStateNotifs.stream().map(notif -> notif.getContext().get(Server.NAME_KEY)).collect(Collectors.toList()), - equalTo(Arrays.asList(passive.getServerName(), passive.getServerName(), passive.getServerName()))); - - assertThat( - serverStateNotifs.stream().map(notif -> notif.getAttributes().get("state")).collect(Collectors.toList()), - equalTo(Arrays.asList("UNINITIALIZED", "SYNCHRONIZING", "PASSIVE"))); - } - - @Test - public void get_server_states_when_passive_joins() throws Exception { - Server active = tmsAgentService.readTopology().serverStream().filter(Server::isActive).findFirst().get(); - Server passive = tmsAgentService.readTopology().serverStream().filter(server -> !server.isActive()).findFirst().get(); - assertThat(active.getState(), equalTo(Server.State.ACTIVE)); - assertThat(passive.getState(), equalTo(Server.State.PASSIVE)); - - // read messages - List messages = tmsAgentService.readMessages(); - List notifs = messages.stream() - .filter(message -> message.getType().equals("NOTIFICATION")) - .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) - .filter(notif -> notif.getType().equals("SERVER_STATE_CHANGED")) - .collect(Collectors.toList()); - - - } - - @Test - public void failover_management() throws Exception { - Cluster cluster = tmsAgentService.readTopology(); - Server active = cluster.serverStream().filter(Server::isActive).findFirst().get(); - Server passive = cluster.serverStream().filter(server -> !server.isActive()).findFirst().get(); - assertThat(active.getState(), equalTo(Server.State.ACTIVE)); - assertThat(passive.getState(), equalTo(Server.State.PASSIVE)); - - // clear buffer - tmsAgentService.readMessages(); - - // kill active - passive should take the active role - voltron.getClusterControl().terminateActive(); - voltron.getClusterControl().waitForActive(); - - cluster = tmsAgentService.readTopology(); - Server newActive = cluster.serverStream().filter(Server::isActive).findFirst().get(); - assertThat(newActive.getState(), equalTo(Server.State.ACTIVE)); - assertThat(newActive.getServerName(), equalTo(passive.getServerName())); - - // read messages - List messages = tmsAgentService.readMessages(); - assertThat(messages.size(), equalTo(3)); - - List notifs = messages.stream() - .filter(message -> message.getType().equals("NOTIFICATION")) - .flatMap(message -> message.unwrap(ContextualNotification.class).stream()) - .filter(notif -> notif.getType().equals("SERVER_STATE_CHANGED")) - .collect(Collectors.toList()); - - assertThat( - notifs.stream().map(notif -> notif.getContext().get(Server.NAME_KEY)).collect(Collectors.toList()), - equalTo(Arrays.asList(newActive.getServerName(), newActive.getServerName()))); - - assertThat( - notifs.stream().map(notif -> notif.getAttributes().get("state")).collect(Collectors.toList()), - equalTo(Arrays.asList("ACTIVE", "ACTIVE"))); - - //TODO: complete with Galvan - //- test topology (like topology_includes_passives), client should have re-exposed their management metadata - //- check notifications: server states - //- check notification that might be there: CLIENT_RECONNECTED and SERVER_ENTITY_FAILOVER_COMPLETE - } - -} diff --git a/management/testing/integration-tests/src/test/resources/passive.json b/management/testing/integration-tests/src/test/resources/passive.json new file mode 100644 index 0000000000..253962c765 --- /dev/null +++ b/management/testing/integration-tests/src/test/resources/passive.json @@ -0,0 +1,447 @@ +{ + "id": "stripe-PASSIVE", + "serverEntities": [ + { + "id": "ManagementAgent:org.terracotta.management.entity.management.client.ManagementAgentEntity", + "type": "org.terracotta.management.entity.management.client.ManagementAgentEntity", + "name": "ManagementAgent", + "consumerId": 2, + "managementRegistry": null + }, + { + "id": "PassiveTopologyIT:org.terracotta.management.entity.tms.client.TmsAgentEntity", + "type": "org.terracotta.management.entity.tms.client.TmsAgentEntity", + "name": "PassiveTopologyIT", + "consumerId": 1, + "managementRegistry": { + "contextContainer": { + "consumerId": "1", + "subContexts": [] + }, + "capabilities": [ + { + "name": "OffHeapResourceSettings", + "context": [ + { + "name": "consumerId", + "required": true + }, + { + "name": "type", + "required": true + }, + { + "name": "alias", + "required": true + } + ], + "descriptors": [ + { + "consumerId": "1", + "alias": "primary-server-resource", + "type": "OffHeapResource", + "capacity": 67108864, + "availableAtTime": 67108864 + }, + { + "type": "OffHeapResourceSettingsManagementProvider", + "time": 0 + } + ] + }, + { + "name": "OffHeapResourceStatistics", + "context": [ + { + "name": "consumerId", + "required": true + }, + { + "name": "type", + "required": true + }, + { + "name": "alias", + "required": true + } + ], + "descriptors": [ + { + "name": "OffHeapResource:AllocatedMemory", + "type": "SIZE_HISTORY" + } + ], + "properties": { + "averageWindowDuration": 1, + "averageWindowUnit": "MINUTES", + "historyInterval": 1, + "historyIntervalUnit": "SECONDS", + "historySize": 100, + "timeToDisable": 5, + "timeToDisableUnit": "SECONDS" + } + }, + { + "name": "StatisticCollectorCapability", + "context": [ + { + "name": "consumerId", + "required": true + } + ], + "descriptors": [ + { + "name": "startStatisticCollector", + "returnType": "void", + "parameters": [] + }, + { + "name": "stopStatisticCollector", + "returnType": "void", + "parameters": [] + }, + { + "name": "updateCollectedStatistics", + "returnType": "void", + "parameters": [ + { + "name": "capabilityName", + "type": "java.lang.String" + }, + { + "name": "statisticNames", + "type": "java.util.Collection" + } + ] + } + ] + } + ] + } + }, + { + "id": "pet-clinic/clients:org.terracotta.management.entity.sample.client.CacheEntity", + "type": "org.terracotta.management.entity.sample.client.CacheEntity", + "name": "pet-clinic/clients", + "consumerId": 4, + "managementRegistry": { + "contextContainer": { + "consumerId": "4", + "subContexts": [] + }, + "capabilities": [ + { + "name": "ServerCacheCalls", + "context": [ + { + "name": "consumerId", + "required": true + }, + { + "name": "cacheName", + "required": true + } + ], + "descriptors": [ + { + "name": "clear", + "returnType": "void", + "parameters": [] + }, + { + "name": "get", + "returnType": "java.lang.String", + "parameters": [ + { + "name": "key", + "type": "java.lang.String" + } + ] + }, + { + "name": "put", + "returnType": "void", + "parameters": [ + { + "name": "key", + "type": "java.lang.String" + }, + { + "name": "value", + "type": "java.lang.String" + } + ] + }, + { + "name": "size", + "returnType": "int", + "parameters": [] + } + ] + }, + { + "name": "ServerCacheSettings", + "context": [ + { + "name": "consumerId", + "required": true + }, + { + "name": "type", + "required": true + }, + { + "name": "alias", + "required": true + } + ], + "descriptors": [ + { + "consumerId": "4", + "alias": "pet-clinic/clients", + "type": "ServerCache", + "size": 0 + }, + { + "type": "ServerCacheSettings", + "time": 0 + } + ] + }, + { + "name": "ServerCacheStatistics", + "context": [ + { + "name": "consumerId", + "required": true + }, + { + "name": "type", + "required": true + }, + { + "name": "alias", + "required": true + } + ], + "descriptors": [ + { + "name": "Cluster:ClearCount", + "type": "COUNTER_HISTORY" + }, + { + "name": "Cluster:ClearRate", + "type": "RATE_HISTORY" + }, + { + "name": "Cluster:HitCount", + "type": "COUNTER_HISTORY" + }, + { + "name": "Cluster:HitRate", + "type": "RATE_HISTORY" + }, + { + "name": "Cluster:HitRatio", + "type": "RATIO_HISTORY" + }, + { + "name": "Cluster:MissCount", + "type": "COUNTER_HISTORY" + }, + { + "name": "Cluster:MissRate", + "type": "RATE_HISTORY" + }, + { + "name": "Cluster:MissRatio", + "type": "RATIO_HISTORY" + }, + { + "name": "ServerCache:Size", + "type": "SIZE_HISTORY" + } + ], + "properties": { + "averageWindowDuration": 1, + "averageWindowUnit": "MINUTES", + "historyInterval": 1, + "historyIntervalUnit": "SECONDS", + "historySize": 100, + "timeToDisable": 5, + "timeToDisableUnit": "SECONDS" + } + } + ] + } + }, + { + "id": "pet-clinic/pets:org.terracotta.management.entity.sample.client.CacheEntity", + "type": "org.terracotta.management.entity.sample.client.CacheEntity", + "name": "pet-clinic/pets", + "consumerId": 3, + "managementRegistry": { + "contextContainer": { + "consumerId": "3", + "subContexts": [] + }, + "capabilities": [ + { + "name": "ServerCacheCalls", + "context": [ + { + "name": "consumerId", + "required": true + }, + { + "name": "cacheName", + "required": true + } + ], + "descriptors": [ + { + "name": "clear", + "returnType": "void", + "parameters": [] + }, + { + "name": "get", + "returnType": "java.lang.String", + "parameters": [ + { + "name": "key", + "type": "java.lang.String" + } + ] + }, + { + "name": "put", + "returnType": "void", + "parameters": [ + { + "name": "key", + "type": "java.lang.String" + }, + { + "name": "value", + "type": "java.lang.String" + } + ] + }, + { + "name": "size", + "returnType": "int", + "parameters": [] + } + ] + }, + { + "name": "ServerCacheSettings", + "context": [ + { + "name": "consumerId", + "required": true + }, + { + "name": "type", + "required": true + }, + { + "name": "alias", + "required": true + } + ], + "descriptors": [ + { + "consumerId": "3", + "alias": "pet-clinic/pets", + "type": "ServerCache", + "size": 0 + }, + { + "type": "ServerCacheSettings", + "time": 0 + } + ] + }, + { + "name": "ServerCacheStatistics", + "context": [ + { + "name": "consumerId", + "required": true + }, + { + "name": "type", + "required": true + }, + { + "name": "alias", + "required": true + } + ], + "descriptors": [ + { + "name": "Cluster:ClearCount", + "type": "COUNTER_HISTORY" + }, + { + "name": "Cluster:ClearRate", + "type": "RATE_HISTORY" + }, + { + "name": "Cluster:HitCount", + "type": "COUNTER_HISTORY" + }, + { + "name": "Cluster:HitRate", + "type": "RATE_HISTORY" + }, + { + "name": "Cluster:HitRatio", + "type": "RATIO_HISTORY" + }, + { + "name": "Cluster:MissCount", + "type": "COUNTER_HISTORY" + }, + { + "name": "Cluster:MissRate", + "type": "RATE_HISTORY" + }, + { + "name": "Cluster:MissRatio", + "type": "RATIO_HISTORY" + }, + { + "name": "ServerCache:Size", + "type": "SIZE_HISTORY" + } + ], + "properties": { + "averageWindowDuration": 1, + "averageWindowUnit": "MINUTES", + "historyInterval": 1, + "historyIntervalUnit": "SECONDS", + "historySize": 100, + "timeToDisable": 5, + "timeToDisableUnit": "SECONDS" + } + } + ] + } + } + ], + "serverName": "stripe-PASSIVE", + "hostName": "localhost", + "hostAddress": "127.0.0.1", + "bindAddress": "0.0.0.0", + "bindPort": 0, + "groupPort": 0, + "state": "PASSIVE", + "version": "", + "buildId": "Build ID", + "startTime": 0, + "upTimeSec": 5, + "activateTime": 0 +} \ No newline at end of file