Skip to content
Snippets Groups Projects
Commit f5b9d959 authored by piotr.kupczyk@id.ethz.ch's avatar piotr.kupczyk@id.ethz.ch
Browse files

SSDM-13578 : 2PT : Database and V3 Implementation - integration tests

parent f6de16f2
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -118,7 +118,7 @@ public abstract class AbstractTransactionNode<T extends AbstractTransaction> ...@@ -118,7 +118,7 @@ public abstract class AbstractTransactionNode<T extends AbstractTransaction>
registerTransaction(transaction); registerTransaction(transaction);
operationLog.info( operationLog.info(
"Recovered transaction '" + transaction.getTransactionId() + "' found in the transaction log with last status '" "Recovered transaction '" + transaction.getTransactionId() + "' found in the transaction log with last status '"
+ transaction.getTransactionStatus() + "' ."); + transaction.getTransactionStatus() + "'.");
} }
} }
} }
......
...@@ -48,6 +48,7 @@ import org.eclipse.jetty.server.ServerConnector; ...@@ -48,6 +48,7 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.remoting.rmi.CodebaseAwareObjectInputStream; import org.springframework.remoting.rmi.CodebaseAwareObjectInputStream;
...@@ -104,7 +105,7 @@ public abstract class AbstractIntegrationTest ...@@ -104,7 +105,7 @@ public abstract class AbstractIntegrationTest
cleanupApplicationServerFolders(); cleanupApplicationServerFolders();
cleanupAfsServerFolders(); cleanupAfsServerFolders();
startApplicationServer(); startApplicationServer(true);
startApplicationServerProxy(); startApplicationServerProxy();
startAfsServer(); startAfsServer();
startAfsServerProxy(); startAfsServerProxy();
...@@ -119,30 +120,6 @@ public abstract class AbstractIntegrationTest ...@@ -119,30 +120,6 @@ public abstract class AbstractIntegrationTest
shutdownAfsServerProxy(); shutdownAfsServerProxy();
} }
private void shutdownApplicationServer()
{
applicationServer.setStopAtShutdown(true);
log("Shut down application server.");
}
private void shutdownApplicationServerProxy()
{
applicationServerProxy.setStopAtShutdown(true);
log("Shut down application server proxy.");
}
private void shutdownAfsServer() throws Exception
{
afsServer.shutdown(false);
log("Shut down afs server.");
}
private void shutdownAfsServerProxy()
{
afsServerProxy.setStopAtShutdown(true);
log("Shut down afs server proxy.");
}
@BeforeMethod @BeforeMethod
public void beforeMethod(Method method) public void beforeMethod(Method method)
{ {
...@@ -165,7 +142,7 @@ public abstract class AbstractIntegrationTest ...@@ -165,7 +142,7 @@ public abstract class AbstractIntegrationTest
private void cleanupApplicationServerFolders() throws Exception private void cleanupApplicationServerFolders() throws Exception
{ {
Properties configuration = getApplicationServerConfiguration(); Properties configuration = getApplicationServerConfiguration(true);
String transactionLogFolder = configuration.getProperty(TransactionConfiguration.TRANSACTION_LOG_FOLDER_PATH_PROPERTY_NAME); String transactionLogFolder = configuration.getProperty(TransactionConfiguration.TRANSACTION_LOG_FOLDER_PATH_PROPERTY_NAME);
cleanupFolderSafely(transactionLogFolder); cleanupFolderSafely(transactionLogFolder);
...@@ -209,9 +186,10 @@ public abstract class AbstractIntegrationTest ...@@ -209,9 +186,10 @@ public abstract class AbstractIntegrationTest
} }
} }
private void startApplicationServer() throws Exception private void startApplicationServer(boolean createDatabase) throws Exception
{ {
Properties configuration = getApplicationServerConfiguration(); log("Starting application server.");
Properties configuration = getApplicationServerConfiguration(createDatabase);
for (Object key : configuration.keySet()) for (Object key : configuration.keySet())
{ {
...@@ -246,10 +224,12 @@ public abstract class AbstractIntegrationTest ...@@ -246,10 +224,12 @@ public abstract class AbstractIntegrationTest
server.start(); server.start();
AbstractIntegrationTest.applicationServer = server; AbstractIntegrationTest.applicationServer = server;
log("Started application server.");
} }
private void startApplicationServerProxy() throws Exception private void startApplicationServerProxy() throws Exception
{ {
log("Starting application server proxy.");
Server server = new Server(); Server server = new Server();
HttpConfiguration httpConfig = new HttpConfiguration(); HttpConfiguration httpConfig = new HttpConfiguration();
ServerConnector connector = ServerConnector connector =
...@@ -299,18 +279,22 @@ public abstract class AbstractIntegrationTest ...@@ -299,18 +279,22 @@ public abstract class AbstractIntegrationTest
server.start(); server.start();
AbstractIntegrationTest.applicationServerProxy = server; AbstractIntegrationTest.applicationServerProxy = server;
log("Started application server proxy.");
} }
private void startAfsServer() throws Exception private void startAfsServer() throws Exception
{ {
log("Starting afs server.");
Configuration configuration = getAfsServerConfiguration(); Configuration configuration = getAfsServerConfiguration();
DummyServerObserver dummyServerObserver = new DummyServerObserver(); DummyServerObserver dummyServerObserver = new DummyServerObserver();
AbstractIntegrationTest.afsServer = new ch.ethz.sis.afsserver.server.Server<>(configuration, dummyServerObserver, dummyServerObserver); AbstractIntegrationTest.afsServer = new ch.ethz.sis.afsserver.server.Server<>(configuration, dummyServerObserver, dummyServerObserver);
log("Started afs server.");
} }
private void startAfsServerProxy() throws Exception private void startAfsServerProxy() throws Exception
{ {
log("Starting afs server proxy.");
Server server = new Server(); Server server = new Server();
HttpConfiguration httpConfig = new HttpConfiguration(); HttpConfiguration httpConfig = new HttpConfiguration();
ServerConnector connector = ServerConnector connector =
...@@ -375,13 +359,54 @@ public abstract class AbstractIntegrationTest ...@@ -375,13 +359,54 @@ public abstract class AbstractIntegrationTest
server.start(); server.start();
AbstractIntegrationTest.afsServerProxy = server; AbstractIntegrationTest.afsServerProxy = server;
log("Started afs server proxy.");
}
private void shutdownApplicationServer() throws Exception
{
// manually destroy EHCache (without it the new AS won't start in the same VM)
applicationServerSpringContext.getBean(EhCacheManagerFactoryBean.class).destroy();
applicationServer.stop();
log("Shut down application server.");
}
private void shutdownApplicationServerProxy()
{
applicationServerProxy.setStopAtShutdown(true);
log("Shut down application server proxy.");
}
private void shutdownAfsServer() throws Exception
{
afsServer.shutdown(false);
log("Shut down afs server.");
}
private void shutdownAfsServerProxy()
{
afsServerProxy.setStopAtShutdown(true);
log("Shut down afs server proxy.");
}
public void restartApplicationServer() throws Exception
{
log("Restarting application server.");
shutdownApplicationServer();
startApplicationServer(false);
}
public void restartAfsServer() throws Exception
{
log("Restarting afs server.");
shutdownAfsServer();
startAfsServer();
} }
private Properties getApplicationServerConfiguration() throws Exception private Properties getApplicationServerConfiguration(boolean createDatabase) throws Exception
{ {
Properties configuration = new Properties(); Properties configuration = new Properties();
configuration.load(new FileInputStream("../server-application-server/source/java/service.properties")); configuration.load(new FileInputStream("../server-application-server/source/java/service.properties"));
configuration.setProperty("database.create-from-scratch", "true"); configuration.setProperty("database.create-from-scratch", String.valueOf(createDatabase));
configuration.setProperty("database.kind", "integration"); configuration.setProperty("database.kind", "integration");
configuration.setProperty("script-folder", "../server-application-server/source"); configuration.setProperty("script-folder", "../server-application-server/source");
configuration.setProperty(TransactionConfiguration.COORDINATOR_KEY_PROPERTY_NAME, TEST_TRANSACTION_COORDINATOR_KEY); configuration.setProperty(TransactionConfiguration.COORDINATOR_KEY_PROPERTY_NAME, TEST_TRANSACTION_COORDINATOR_KEY);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment