You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by es...@apache.org on 2020/01/30 22:47:17 UTC
[geode] 01/01: Revert "GEODE-7109: add test case that multiple
sessions can be maintained. (#4633)"
This is an automated email from the ASF dual-hosted git repository.
eshu11 pushed a commit to branch revert-4633-feature/GEODE-7109
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 46325e3a944da11fd6abdb57435c59a925cd5a25
Author: Eric Shu <es...@pivotal.io>
AuthorDate: Thu Jan 30 14:46:48 2020 -0800
Revert "GEODE-7109: add test case that multiple sessions can be maintained. (#4633)"
This reverts commit b254cace99e6e6c1ca294f865f545ae6f8f2b6fc.
---
.../org/apache/geode/session/tests/Client.java | 4 -
.../apache/geode/session/tests/CargoTestBase.java | 45 ++---
.../apache/geode/session/tests/Tomcat6Test.java | 2 +-
.../apache/geode/session/tests/Tomcat7Test.java | 2 +-
.../apache/geode/session/tests/Tomcat8Test.java | 2 +-
.../apache/geode/session/tests/Tomcat9Test.java | 2 +-
.../session/tests/TomcatClientServerTest.java | 28 +--
.../org/apache/geode/session/tests/TomcatTest.java | 206 ---------------------
8 files changed, 27 insertions(+), 264 deletions(-)
diff --git a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/Client.java b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/Client.java
index 56eacb3..d9257e8 100644
--- a/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/Client.java
+++ b/geode-assembly/geode-assembly-test/src/main/java/org/apache/geode/session/tests/Client.java
@@ -248,10 +248,6 @@ public class Client {
}
}
- public String getCookie() {
- return cookie;
- }
-
private String getCookieHeader(CloseableHttpResponse resp) {
Header lastHeader = resp.getLastHeader("Set-Cookie");
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
index 89fc089..6299a8f 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/CargoTestBase.java
@@ -14,7 +14,6 @@
*/
package org.apache.geode.session.tests;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
@@ -59,8 +58,6 @@ public abstract class CargoTestBase {
protected ContainerManager manager;
protected ContainerInstall install;
protected MemberVM locatorVM;
- protected boolean dumpLogs = true;
- protected int numberOfContainers = 2;
/**
* Should only be called once per test.
@@ -91,7 +88,7 @@ public abstract class CargoTestBase {
install = getInstall(portSupplier::getAvailablePort);
install.setDefaultLocatorPort(locatorVM.getPort());
- manager.addContainers(numberOfContainers, install);
+ manager.addContainers(2, install);
customizeContainers();
}
@@ -107,9 +104,7 @@ public abstract class CargoTestBase {
manager.stopAllActiveContainers();
} finally {
try {
- if (dumpLogs) {
- manager.dumpLogs();
- }
+ manager.dumpLogs();
} finally {
try {
manager.cleanUp();
@@ -126,12 +121,6 @@ public abstract class CargoTestBase {
*/
public void getKeyValueDataOnAllClients(String key, String expectedValue, String expectedCookie)
throws IOException, URISyntaxException {
- getKeyValueDataOnAllClients(client, key, expectedValue, expectedCookie);
- }
-
- public void getKeyValueDataOnAllClients(Client client, String key, String expectedValue,
- String expectedCookie)
- throws IOException, URISyntaxException {
for (int i = 0; i < manager.numContainers(); i++) {
// Set the port for this server
client.setPort(Integer.parseInt(manager.getContainerPort(i)));
@@ -150,25 +139,22 @@ public abstract class CargoTestBase {
String value = resp.getResponse();
if (!expectedValue.equals(value)) {
LogService.getLogger().info("verifying container {} for expected value of {}"
- + " for key {}, but gets response value of {}. Waiting for update from server. for client {}",
- i,
- expectedValue, key, value, client);
+ + " for key {}, but gets response value of {}. Waiting for update from server.", i,
+ expectedValue, key, value);
}
- GeodeAwaitility.await().pollInSameThread().untilAsserted(
- () -> assertThat(getResponseValue(client, key)).isEqualTo(expectedValue));
+ GeodeAwaitility.await().until(() -> expectedValue.equals(getResponseValue(client, key)));
} else {
// either p2p cache or client cache which has proxy/empty region - retrieving session from
// servers
- assertEquals("Session data is not replicating properly for key " + key, expectedValue,
- resp.getResponse());
+ assertEquals("Session data is not replicating properly", expectedValue, resp.getResponse());
}
}
}
private String getResponseValue(Client client, String key)
throws IOException, URISyntaxException {
- Client.Response response = client.get(key);
- String value = response.getResponse();
+ String value = client.get(key).getResponse();
+ LogService.getLogger().info("client gets response value of {}", value);
return value;
}
@@ -204,8 +190,8 @@ public abstract class CargoTestBase {
}
/**
- * Test that when a container fails, session attributes that were previously set in that
- * container are still available in other containers
+ * Test that when a container fails, session attributes that were previously set in that container
+ * are still available in other containers
*/
@Test
public void failureShouldStillAllowOtherContainersDataAccess()
@@ -307,8 +293,8 @@ public abstract class CargoTestBase {
/**
- * Test that if one container is accessing a session, that will prevent the session from
- * expiring in all containers.
+ * Test that if one container is accessing a session, that will prevent the session from expiring
+ * in all containers.
*/
@Test
public void containersShouldShareSessionExpirationReset()
@@ -343,8 +329,7 @@ public abstract class CargoTestBase {
}
/**
- * Test that if a session attribute is removed in one container, it is removed from all
- * containers
+ * Test that if a session attribute is removed in one container, it is removed from all containers
*/
@Test
public void containersShouldShareDataRemovals() throws IOException, URISyntaxException {
@@ -365,8 +350,8 @@ public abstract class CargoTestBase {
}
/**
- * Test that a container added to the system after puts still can access the correct sessions
- * and data.
+ * Test that a container added to the system after puts still can access the correct sessions and
+ * data.
*/
@Test
public void newContainersShouldShareDataAccess() throws Exception {
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
index 42511c8..60dface 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat6Test.java
@@ -19,7 +19,7 @@ import static org.apache.geode.session.tests.TomcatInstall.TomcatVersion.TOMCAT6
import java.util.function.IntSupplier;
-public class Tomcat6Test extends TomcatTest {
+public class Tomcat6Test extends CargoTestBase {
@Override
public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
return new TomcatInstall(getClass().getSimpleName(), TOMCAT6, PEER_TO_PEER, portSupplier);
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
index 4b6836d..1922fdb 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat7Test.java
@@ -19,7 +19,7 @@ import static org.apache.geode.session.tests.TomcatInstall.TomcatVersion.TOMCAT7
import java.util.function.IntSupplier;
-public class Tomcat7Test extends TomcatTest {
+public class Tomcat7Test extends CargoTestBase {
@Override
public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
return new TomcatInstall(getClass().getSimpleName(), TOMCAT7, PEER_TO_PEER, portSupplier);
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
index 97b73d9..93a7441 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat8Test.java
@@ -19,7 +19,7 @@ import static org.apache.geode.session.tests.TomcatInstall.TomcatVersion.TOMCAT8
import java.util.function.IntSupplier;
-public class Tomcat8Test extends TomcatTest {
+public class Tomcat8Test extends CargoTestBase {
@Override
public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
return new TomcatInstall(getClass().getSimpleName(), TOMCAT8, PEER_TO_PEER, portSupplier);
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
index 90f5392..b7777d1 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/Tomcat9Test.java
@@ -19,7 +19,7 @@ import static org.apache.geode.session.tests.TomcatInstall.TomcatVersion.TOMCAT9
import java.util.function.IntSupplier;
-public class Tomcat9Test extends TomcatTest {
+public class Tomcat9Test extends CargoTestBase {
@Override
public ContainerInstall getInstall(IntSupplier portSupplier) throws Exception {
return new TomcatInstall(getClass().getSimpleName(), TOMCAT9, PEER_TO_PEER, portSupplier);
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/TomcatClientServerTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/TomcatClientServerTest.java
index d8db317..75af639 100644
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/TomcatClientServerTest.java
+++ b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/TomcatClientServerTest.java
@@ -15,7 +15,6 @@
package org.apache.geode.session.tests;
import java.io.File;
-import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
@@ -32,9 +31,9 @@ import org.apache.geode.test.junit.rules.GfshCommandRule;
*
* Sets up the server needed for the client container to connect to
*/
-public abstract class TomcatClientServerTest extends TomcatTest {
- private final ArrayList<String> serverList = new ArrayList<>();
- private final int numberOfServers = 2;
+public abstract class TomcatClientServerTest extends CargoTestBase {
+ private String serverName1;
+ private String serverName2;
@Rule
public transient TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -48,9 +47,8 @@ public abstract class TomcatClientServerTest extends TomcatTest {
*/
@Before
public void startServer() throws Exception {
- for (int i = 0; i < numberOfServers; i++) {
- serverList.add(startAServer(i));
- }
+ serverName1 = startAServer(1);
+ serverName2 = startAServer(2);
afterStartServers();
}
@@ -75,13 +73,7 @@ public abstract class TomcatClientServerTest extends TomcatTest {
binDirJars + File.pathSeparator + libDirJars);
command.addOption(CliStrings.START_SERVER__LOCATORS,
locatorVM.invoke(() -> ClusterStartupRule.getLocator().asString()));
- // statistic file
- command.addOption(CliStrings.START_SERVER__STATISTIC_ARCHIVE_FILE, "statArchive.gfs");
-
command.addOption(CliStrings.START_SERVER__J, "-Dgemfire.member-timeout=60000");
- command.addOption(CliStrings.START_SERVER__J, "-Dgemfire.statistic-sampling-enabled=true");
- command.addOption(CliStrings.START_SERVER__J, "-XX:+HeapDumpOnOutOfMemoryError");
- command.addOption(CliStrings.START_SERVER__J, "-XX:+JavaMonitorsInStackTrace");
// Start server
gfsh.executeAndAssertThat(command.toString()).statusIsSuccess();
@@ -93,13 +85,9 @@ public abstract class TomcatClientServerTest extends TomcatTest {
* Stops the server for the client Tomcat container is has been connecting to
*/
@After
- public void stopServer() {
- for (int i = 0; i < numberOfServers; i++) {
- try {
- stopAServer(serverList.get(i));
- } catch (Exception ignore) {
- }
- }
+ public void stopServer() throws Exception {
+ stopAServer(serverName1);
+ stopAServer(serverName2);
}
private void stopAServer(String serverName) {
diff --git a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/TomcatTest.java b/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/TomcatTest.java
deleted file mode 100644
index 7e4321a..0000000
--- a/geode-assembly/src/distributedTest/java/org/apache/geode/session/tests/TomcatTest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to You 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.apache.geode.session.tests;
-
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CountDownLatch;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ErrorCollector;
-
-import org.apache.geode.logging.internal.log4j.api.LogService;
-import org.apache.geode.test.junit.rules.ExecutorServiceRule;
-
-public abstract class TomcatTest extends CargoTestBase {
- @Rule
- public ExecutorServiceRule executorServiceRule = new ExecutorServiceRule();
-
- @Rule
- public ErrorCollector errorCollector = new ErrorCollector();
-
- protected int numberOfConcurrentClients;
- protected CountDownLatch latch;
- protected CountDownLatch finishLatch;
- private final Random random = new Random();
- private final Map<Client, HashMap<String, String>> clientAttributesMap =
- new ConcurrentHashMap<>();
- private int counter = 0;
-
- @Test
- public void multipleClientsCanMaintainOwnSessions() throws Throwable {
- dumpLogs = false;
- numberOfConcurrentClients = 20;
- latch = new CountDownLatch(numberOfConcurrentClients);
- finishLatch = new CountDownLatch(numberOfConcurrentClients);
- manager.startAllInactiveContainers();
-
- for (int i = 0; i < numberOfConcurrentClients; i++) {
- executorServiceRule.submit(() -> doSessionOps(20));
- }
- finishLatch.await();
-
- }
-
- protected void doSessionOps(int maxNumOfOperations) {
- String key = "key";
- String value = "Foo55";
- String key1 = "key1";
- String value1 = "Bar1226";
-
- Client client = new Client();
- int whichContainer = random.nextInt(numberOfContainers);
- try {
- client.setPort(Integer.parseInt(manager.getContainerPort(whichContainer)));
- LogService.getLogger().info(
- "doing work for client " + client + " on Container whichContainer " + whichContainer);
- LogService.getLogger().info("putting key " + key + " value " + value);
- Client.Response resp = client.set(key, value);
- getKeyValueDataOnAllClients(client, key, value, resp.getSessionCookie());
- resp = client.set(key1, value1);
- getKeyValueDataOnAllClients(client, key, value, resp.getSessionCookie());
- resp = client.set(key, null);
- getKeyValueDataOnAllClients(client, key, "", resp.getSessionCookie());
- getKeyValueDataOnAllClients(client, key1, value1, resp.getSessionCookie());
- doSetsAndVerifyGets(client, maxNumOfOperations);
- } catch (Throwable e) {
- errorCollector.addError(e);
- } finally {
- latch.countDown();
- }
- try {
- verifySessionAllAttributes(client, clientAttributesMap.get(client), client.get(key, true));
- } catch (Throwable e) {
- errorCollector.addError(e);
- } finally {
- finishLatch.countDown();
- }
- }
-
- private synchronized void updateDoneCounter() {
- ++counter;
- LogService.getLogger().info("finished {} of sessions", counter);
- }
-
- private void doSetsAndVerifyGets(Client client, int maxNumberOfOperations) throws Exception {
- HashMap<String, String> attributes = new HashMap();
- clientAttributesMap.put(client, attributes);
-
- int numberOfOperations = random.nextInt(maxNumberOfOperations) + 1;
- LogService.getLogger().info("performing {} of operations", numberOfOperations);
- for (int i = 0; i < numberOfOperations; i++) {
- if (i % 2 == 0) {
- doGetsAndSets(client, attributes);
- } else {
- doSetsAndGetWithUpdate(client, attributes);
- }
- }
- LogService.getLogger().info("finished doSetsAndVerifyGets ops for {} times",
- numberOfOperations);
- updateDoneCounter();
- }
-
- private void doGetsAndSets(Client client, HashMap<String, String> attributes)
- throws IOException, URISyntaxException {
- String key = getKey(client, attributes);
- int maxLength = 100;
- String value = getRandomVarChar(client, attributes, maxLength);
- attributes.put(key, value);
- int whichContainer = random.nextInt(numberOfContainers);
- client.setPort(Integer.parseInt(manager.getContainerPort(whichContainer)));
- Client.Response resp = client.set(key, value);
- getKeyValueDataOnAllClients(client, key, value, resp.getSessionCookie());
- verifySessionGets(client, attributes, resp);
- }
-
- private void doSetsAndGetWithUpdate(Client client, HashMap<String, String> attributes)
- throws IOException, URISyntaxException {
- String key = getKey(client, attributes);
- if (random.nextInt(10) == 1) {
- // do update on an existing attribute
- key = "key";
- }
- int maxLength = 100;
- String value = getRandomVarChar(client, attributes, maxLength);
- attributes.put(key, value);
- client.setPort(Integer.parseInt(manager.getContainerPort(random.nextInt(numberOfContainers))));
- Client.Response resp = client.set(key, value);
- if (!isCachingClient()) {
- getKeyValueDataOnAllClients(client, key, value, resp.getSessionCookie());
- verifySessionGets(client, attributes, resp);
- }
- }
-
- protected String getKey(Client client, Map attributes) {
- return "key" + (attributes.size() + 1) + "_" + client.getCookie();
- }
-
- protected String getRandomVarChar(Client client, Map attributes, int length) {
- if (length == 0) {
- return "";
- }
- StringBuffer buffer = new StringBuffer();
- buffer.append("value" + (attributes.size() + 1) + "_" + client.getCookie());
- int randomLength = random.nextInt(length) + 1;
-
- int sp = ' ';
- int tilde = '~';
- for (int j = 0; j < randomLength; j++) {
- buffer.append((char) (random.nextInt(tilde - sp) + sp));
- }
- return buffer.toString();
- }
-
- private void verifySessionGets(Client client, HashMap<String, String> attributes,
- Client.Response resp) throws IOException, URISyntaxException {
- int count = 0;
- int whichOne = random.nextInt(attributes.size());
- Iterator iterator = attributes.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator.next();
- if (count == whichOne) {
- String key = (String) entry.getKey();
- String expectedValue = (String) entry.getValue();
- getKeyValueDataOnAllClients(client, key, expectedValue,
- resp.getSessionCookie());
- break;
- }
- count++;
- }
- }
-
- private void verifySessionAllAttributes(Client client, HashMap<String, String> attributes,
- Client.Response resp) throws IOException, URISyntaxException {
- Iterator iterator = attributes.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator.next();
- String key = (String) entry.getKey();
- String expectedValue = (String) entry.getValue();
- getKeyValueDataOnAllClients(client, key, expectedValue,
- resp.getSessionCookie());
- }
- }
-
- private boolean isCachingClient() {
- return install.getConnectionType() == ContainerInstall.ConnectionType.CACHING_CLIENT_SERVER;
- }
-}