[New] Added new versioning performance test

This commit is contained in:
Robert von Burg 2016-08-08 09:57:34 +02:00
parent 5559e4cb8a
commit e0bd53b001
6 changed files with 261 additions and 1 deletions

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<Privilege>
<Container>
<Parameters>
<!-- parameters for the container itself -->
<Parameter name="autoPersistOnPasswordChange" value="true" />
</Parameters>
<EncryptionHandler class="li.strolch.privilege.handler.DefaultEncryptionHandler">
<Parameters>
<Parameter name="hashAlgorithm" value="SHA-256" />
</Parameters>
</EncryptionHandler>
<PersistenceHandler class="li.strolch.privilege.handler.XmlPersistenceHandler">
<Parameters>
<Parameter name="usersXmlFile" value="PrivilegeUsers.xml" />
<Parameter name="rolesXmlFile" value="PrivilegeRoles.xml" />
</Parameters>
</PersistenceHandler>
</Container>
<Policies>
<Policy name="DefaultPrivilege" class="li.strolch.privilege.policy.DefaultPrivilege" />
</Policies>
</Privilege>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Roles>
<Role name="agent">
<Privilege name="li.strolch.privilege.handler.SystemUserAction" policy="DefaultPrivilege">
<Allow>li.strolch.agent.impl.StartRealms</Allow>
</Privilege>
</Role>
<Role name="AppUser">
<Privilege name="li.strolch.service.api.Service" policy="DefaultPrivilege">
<AllAllowed>true</AllAllowed>
</Privilege>
<Privilege name="li.strolch.model.query.StrolchQuery" policy="DefaultPrivilege">
<AllAllowed>true</AllAllowed>
</Privilege>
</Role>
</Roles>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<Users>
<User userId="1" username="agent">
<State>SYSTEM</State>
<Roles>
<Role>agent</Role>
</Roles>
</User>
<User userId="2" username="cached" password="9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08">
<Firstname>Application</Firstname>
<Lastname>Administrator</Lastname>
<State>ENABLED</State>
<Locale>en_GB</Locale>
<Roles>
<Role>AppUser</Role>
</Roles>
<Properties>
<Property name="realm" value="cached" />
</Properties>
</User>
<User userId="2" username="transactional" password="9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08">
<Firstname>Application</Firstname>
<Lastname>Administrator</Lastname>
<State>ENABLED</State>
<Locale>en_GB</Locale>
<Roles>
<Role>AppUser</Role>
</Roles>
<Properties>
<Property name="realm" value="transactional" />
</Properties>
</User>
</Users>

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<StrolchConfiguration>
<env id="dev">
<Runtime>
<applicationName>minimal</applicationName>
<Properties>
<locale>en</locale>
<verbose>true</verbose>
</Properties>
</Runtime>
<Component>
<name>PrivilegeHandler</name>
<api>li.strolch.runtime.privilege.PrivilegeHandler</api>
<impl>li.strolch.runtime.privilege.DefaultStrolchPrivilegeHandler</impl>
<Properties>
<privilegeConfigFile>PrivilegeConfig.xml</privilegeConfigFile>
</Properties>
</Component>
<Component>
<name>RealmHandler</name>
<api>li.strolch.agent.api.RealmHandler</api>
<impl>li.strolch.agent.impl.DefaultRealmHandler</impl>
<depends>PrivilegeHandler</depends>
<Properties>
<!--
EMPTY = only inmemory
TRANSIENT = only inmemory
TRANSACTIONAL = only DB
CACHED = inmemory with persistence in DB
-->
<realms>transactional, cached</realms>
<dataStoreMode.transactional>TRANSACTIONAL</dataStoreMode.transactional>
<enableAuditTrail.transactional>true</enableAuditTrail.transactional>
<enableVersioning.transactional>true</enableVersioning.transactional>
<dataStoreMode.cached>CACHED</dataStoreMode.cached>
<enableAuditTrail.cached>true</enableAuditTrail.cached>
<enableVersioning.cached>true</enableVersioning.cached>
</Properties>
</Component>
<Component>
<name>PersistenceHandler</name>
<api>li.strolch.persistence.api.PersistenceHandler</api>
<impl>li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler</impl>
<Properties>
<allowSchemaCreation>true</allowSchemaCreation>
<allowSchemaDrop>true</allowSchemaDrop>
<!-- cached -->
<db.url.cached>jdbc:postgresql://localhost/testdb</db.url.cached>
<db.username.cached>testuser</db.username.cached>
<db.password.cached>test</db.password.cached>
<db.pool.maximumPoolSize.cached>1</db.pool.maximumPoolSize.cached>
<!-- transactional -->
<db.url.transactional>jdbc:postgresql://localhost/testdb</db.url.transactional>
<db.username.transactional>testuser</db.username.transactional>
<db.password.transactional>test</db.password.transactional>
<db.pool.maximumPoolSize.transactional>1</db.pool.maximumPoolSize.transactional>
</Properties>
</Component>
<Component>
<name>ServiceHandler</name>
<api>li.strolch.service.api.ServiceHandler</api>
<impl>li.strolch.service.api.DefaultServiceHandler</impl>
<depends>RealmHandler</depends>
<depends>PrivilegeHandler</depends>
<Properties>
<verbose>true</verbose>
</Properties>
</Component>
</env>
</StrolchConfiguration>

View File

@ -22,6 +22,7 @@ import java.text.MessageFormat;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.postgresql.Driver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -55,6 +56,10 @@ public class PerformancePostgreSqlTest extends PerformanceTest {
}
public static void dropSchema(String dbUrl, String dbUsername, String dbPassword) throws Exception {
if (!Driver.isRegistered())
Driver.register();
Version dbVersion = DbSchemaVersionCheck.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX,
PostgreSqlPersistenceHandler.class);
logger.info(MessageFormat.format("Dropping schema for expected version {0}", dbVersion));
@ -79,7 +84,7 @@ public class PerformancePostgreSqlTest extends PerformanceTest {
}
@AfterClass
public static void afterClass() {
public static void afterClass() throws Exception {
if (runtimeMock != null)
runtimeMock.destroyRuntime();
@ -87,5 +92,8 @@ public class PerformancePostgreSqlTest extends PerformanceTest {
if (rootPath.exists()) {
FileHelper.deleteFile(rootPath, false);
}
if (Driver.isRegistered())
Driver.deregister();
}
}

View File

@ -0,0 +1,99 @@
/*
* Copyright 2015 Robert von Burg <eitch@eitchnet.ch>
*
* 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 li.strolch.performance;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.text.MessageFormat;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.postgresql.Driver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import li.strolch.db.DbSchemaVersionCheck;
import li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler;
import li.strolch.testbase.runtime.RuntimeMock;
import li.strolch.utils.Version;
import li.strolch.utils.helper.FileHelper;
import li.strolch.utils.helper.StringHelper;
/**
* @author Robert von Burg <eitch@eitchnet.ch>
*/
public class PerformancePostgreVersioningSqlTest extends PerformanceTest {
public static final String RUNTIME_PATH = "target/runtime_postgresql_test/"; //$NON-NLS-1$
public static final String DB_STORE_PATH_DIR = "dbStore"; //$NON-NLS-1$
public static final String CONFIG_SRC = "src/runtime_postgresql_versioning"; //$NON-NLS-1$
public static final String DB_URL = "jdbc:postgresql://localhost/testdb"; //$NON-NLS-1$
public static final String DB_USERNAME = "testuser"; //$NON-NLS-1$
public static final String DB_PASSWORD = "test"; //$NON-NLS-1$
private static final Logger logger = LoggerFactory.getLogger(PerformancePostgreVersioningSqlTest.class);
protected static RuntimeMock runtimeMock;
@Override
protected RuntimeMock runtime() {
return runtimeMock;
}
public static void dropSchema(String dbUrl, String dbUsername, String dbPassword) throws Exception {
if (!Driver.isRegistered())
Driver.register();
Version dbVersion = DbSchemaVersionCheck.getExpectedDbVersion(PostgreSqlPersistenceHandler.SCRIPT_PREFIX,
PostgreSqlPersistenceHandler.class);
logger.info(MessageFormat.format("Dropping schema for expected version {0}", dbVersion));
String sql = DbSchemaVersionCheck.getSql(PostgreSqlPersistenceHandler.SCRIPT_PREFIX,
PostgreSqlPersistenceHandler.class, dbVersion, "drop"); //$NON-NLS-1$
logger.info(StringHelper.NEW_LINE + sql);
try (Connection connection = DriverManager.getConnection(dbUrl, dbUsername, dbPassword)) {
connection.prepareStatement(sql).execute();
}
}
@BeforeClass
public static void beforeClass() throws Exception {
dropSchema(DB_URL, DB_USERNAME, DB_PASSWORD);
File rootPath = new File(RUNTIME_PATH);
File configSrc = new File(CONFIG_SRC);
runtimeMock = new RuntimeMock();
runtimeMock.mockRuntime(rootPath, configSrc);
runtimeMock.startContainer();
}
@AfterClass
public static void afterClass() throws Exception {
if (runtimeMock != null)
runtimeMock.destroyRuntime();
File rootPath = new File(RUNTIME_PATH);
if (rootPath.exists()) {
FileHelper.deleteFile(rootPath, false);
}
if (Driver.isRegistered())
Driver.deregister();
}
}