forked from Terracotta-OSS/terracotta-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ Terracotta-OSS#191: Failover Galvan tests
- Loading branch information
1 parent
31275e3
commit 8edc6ea
Showing
14 changed files
with
804 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
management/testing/doc/src/main/java/org/terracotta/management/doc/StartSampleEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.terracotta.management.doc; | ||
|
||
import org.terracotta.connection.ConnectionException; | ||
import org.terracotta.management.entity.sample.Cache; | ||
import org.terracotta.management.entity.sample.client.CacheFactory; | ||
import org.terracotta.management.registry.collect.StatisticConfiguration; | ||
|
||
import java.net.URI; | ||
import java.util.Random; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
/** | ||
* @author Mathieu Carbou | ||
*/ | ||
public class StartSampleEntity { | ||
public static void main(String[] args) throws ConnectionException, ExecutionException, TimeoutException, InterruptedException { | ||
StatisticConfiguration statisticConfiguration = new StatisticConfiguration() | ||
.setAverageWindowDuration(1, TimeUnit.MINUTES) | ||
.setHistorySize(100) | ||
.setHistoryInterval(1, TimeUnit.SECONDS) | ||
.setTimeToDisable(5, TimeUnit.SECONDS); | ||
CacheFactory cacheFactory = new CacheFactory(URI.create("terracotta://localhost:9510/pet-clinic"), statisticConfiguration); | ||
|
||
cacheFactory.init(); | ||
|
||
Cache pets = cacheFactory.getCache("pets"); | ||
|
||
while (true) { | ||
|
||
String key = "pet-" + new Random().nextInt(100); | ||
System.out.println("put(" + key + ")"); | ||
pets.put(key, "Garfield"); | ||
|
||
key = "pet-" + new Random().nextInt(100); | ||
System.out.println("get(" + key + ")"); | ||
pets.get(key); | ||
|
||
Thread.sleep(1_000); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
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. | ||
--> | ||
<tc-config xmlns="http://www.terracotta.org/config" | ||
xmlns:ohr="http://www.terracotta.org/config/offheap-resource"> | ||
|
||
<plugins> | ||
<config> | ||
<ohr:offheap-resources> | ||
<ohr:resource name="primary" unit="MB">64</ohr:resource> | ||
</ohr:offheap-resources> | ||
</config> | ||
</plugins> | ||
|
||
<servers> | ||
<server host="localhost" name="server1"> | ||
<logs>./logs/server1</logs> | ||
<tsa-port>9510</tsa-port> | ||
<tsa-group-port>9530</tsa-group-port> | ||
</server> | ||
<server host="localhost" name="server2"> | ||
<logs>./logs/server2</logs> | ||
<tsa-port>9511</tsa-port> | ||
<tsa-group-port>9531</tsa-group-port> | ||
</server> | ||
</servers> | ||
|
||
</tc-config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...ation-tests/src/test/java/org/terracotta/management/integration/tests/PassiveLeaveIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Message> 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()))); | ||
} | ||
|
||
} |
Oops, something went wrong.