-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from mathieucarbou/ittests
Issue #191 : HA and Failover Galvan tests
- Loading branch information
Showing
24 changed files
with
1,301 additions
and
487 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
59 changes: 59 additions & 0 deletions
59
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,59 @@ | ||
/* | ||
* 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.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
55 changes: 55 additions & 0 deletions
55
...n-tests/src/test/java/org/terracotta/management/integration/tests/AbstractSingleTest.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,55 @@ | ||
/* | ||
* 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.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.terracotta.testing.rules.BasicExternalCluster; | ||
|
||
import java.io.File; | ||
|
||
import static java.util.Collections.emptyList; | ||
|
||
/** | ||
* @author Mathieu Carbou | ||
*/ | ||
public abstract class AbstractSingleTest extends AbstractTest { | ||
|
||
private final String offheapResource = "primary-server-resource"; | ||
private final String resourceConfig = | ||
"<config xmlns:ohr='http://www.terracotta.org/config/offheap-resource'>" | ||
+ "<ohr:offheap-resources>" | ||
+ "<ohr:resource name=\"" + offheapResource + "\" unit=\"MB\">64</ohr:resource>" | ||
+ "</ohr:offheap-resources>" + | ||
"</config>\n"; | ||
|
||
@Rule | ||
public org.terracotta.testing.rules.Cluster voltron = | ||
new BasicExternalCluster(new File("target/galvan"), 1, emptyList(), "", resourceConfig, ""); | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
voltron.getClusterControl().waitForActive(); | ||
commonSetUp(voltron); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
commonTearDown(); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.MapperFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import org.junit.Rule; | ||
|
@@ -56,7 +57,7 @@ | |
*/ | ||
public abstract class AbstractTest { | ||
|
||
private final ObjectMapper mapper = new ObjectMapper(); | ||
private final ObjectMapper mapper = new ObjectMapper().configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); | ||
|
||
private Connection managementConnection; | ||
private Cluster cluster; | ||
|
@@ -198,4 +199,25 @@ protected void queryAllRemoteStatsUntil(Predicate<List<? extends ContextualStati | |
assertTrue(test.test(statistics)); | ||
} | ||
|
||
protected String removeRandomValues(String currentTopo) { | ||
// removes all random values | ||
return currentTopo | ||
.replaceAll("\"(hostName)\":\"[^\"]*\"", "\"$1\":\"<hostname>\"") | ||
.replaceAll("\"hostAddress\":[^,]*", "\"hostAddress\":\"127\\.0\\.0\\.1\"") | ||
.replaceAll("\"bindPort\":[0-9]+", "\"bindPort\":0") | ||
.replaceAll("\"groupPort\":[0-9]+", "\"groupPort\":0") | ||
.replaceAll("\"port\":[0-9]+", "\"port\":0") | ||
.replaceAll("\"activateTime\":[0-9]+", "\"activateTime\":0") | ||
.replaceAll("\"time\":[0-9]+", "\"time\":0") | ||
.replaceAll("\"startTime\":[0-9]+", "\"startTime\":0") | ||
.replaceAll("\"upTimeSec\":[0-9]+", "\"upTimeSec\":0") | ||
.replaceAll("\"id\":\"[0-9]+@[^:]*:([^:]*):[^\"]*\",\"pid\":[0-9]+", "\"id\":\"[email protected]:$1:<uuid>\",\"pid\":0") | ||
.replaceAll("\"buildId\":\"[^\"]*\"", "\"buildId\":\"Build ID\"") | ||
.replaceAll("\"version\":\"[^\"]*\"", "\"version\":\"<version>\"") | ||
.replaceAll("\"clientId\":\"[0-9]+@[^:]*:([^:]*):[^\"]*\"", "\"clientId\":\"[email protected]:$1:<uuid>\"") | ||
.replaceAll("\"logicalConnectionUid\":\"[^\"]*\"", "\"logicalConnectionUid\":\"<uuid>\"") | ||
.replaceAll("\"id\":\"[^\"]*\",\"logicalConnectionUid\":\"[^\"]*\"", "\"id\":\"<uuid>:SINGLE:testServer0:127.0.0.1:0\",\"logicalConnectionUid\":\"<uuid>\"") | ||
.replaceAll("\"vmId\":\"[^\"]*\"", "\"vmId\":\"[email protected]\""); | ||
} | ||
|
||
} |
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
Oops, something went wrong.