Verified Commit 941a0ccc authored by Julian Dehm's avatar Julian Dehm Committed by Julian Dehm

Fix a regression in the performance tests causing the db key to be regenerated everytime.

parent e5112ae9
Pipeline #2054 passed with stage
in 11 minutes and 52 seconds
package org.briarproject.bramble.db; package org.briarproject.bramble.db;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DatabaseConfig; import org.briarproject.bramble.api.db.DatabaseConfig;
import org.briarproject.bramble.api.db.DbException; import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.system.Clock; import org.briarproject.bramble.api.system.Clock;
...@@ -26,6 +27,7 @@ public abstract class DatabasePerformanceComparisonTest ...@@ -26,6 +27,7 @@ public abstract class DatabasePerformanceComparisonTest
* How many blocks of each condition to compare. * How many blocks of each condition to compare.
*/ */
private static final int COMPARISON_BLOCKS = 10; private static final int COMPARISON_BLOCKS = 10;
private SecretKey databaseKey = getSecretKey();
abstract Database<Connection> createDatabase(boolean conditionA, abstract Database<Connection> createDatabase(boolean conditionA,
DatabaseConfig databaseConfig, Clock clock); DatabaseConfig databaseConfig, Clock clock);
...@@ -72,7 +74,7 @@ public abstract class DatabasePerformanceComparisonTest ...@@ -72,7 +74,7 @@ public abstract class DatabasePerformanceComparisonTest
throws DbException { throws DbException {
Database<Connection> db = createDatabase(conditionA, Database<Connection> db = createDatabase(conditionA,
new TestDatabaseConfig(testDir, MAX_SIZE), new SystemClock()); new TestDatabaseConfig(testDir, MAX_SIZE), new SystemClock());
db.open(getSecretKey(), null); db.open(databaseKey, null);
return db; return db;
} }
......
package org.briarproject.bramble.db; package org.briarproject.bramble.db;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DatabaseConfig; import org.briarproject.bramble.api.db.DatabaseConfig;
import org.briarproject.bramble.api.db.DbException; import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.system.Clock; import org.briarproject.bramble.api.system.Clock;
...@@ -20,6 +21,8 @@ import static org.briarproject.bramble.test.TestUtils.getSecretKey; ...@@ -20,6 +21,8 @@ import static org.briarproject.bramble.test.TestUtils.getSecretKey;
public abstract class DatabaseTraceTest extends DatabasePerformanceTest { public abstract class DatabaseTraceTest extends DatabasePerformanceTest {
private SecretKey databaseKey = getSecretKey();
abstract Database<Connection> createDatabase(DatabaseConfig databaseConfig, abstract Database<Connection> createDatabase(DatabaseConfig databaseConfig,
Clock clock); Clock clock);
...@@ -44,7 +47,7 @@ public abstract class DatabaseTraceTest extends DatabasePerformanceTest { ...@@ -44,7 +47,7 @@ public abstract class DatabaseTraceTest extends DatabasePerformanceTest {
private Database<Connection> openDatabase() throws DbException { private Database<Connection> openDatabase() throws DbException {
Database<Connection> db = createDatabase( Database<Connection> db = createDatabase(
new TestDatabaseConfig(testDir, MAX_SIZE), new SystemClock()); new TestDatabaseConfig(testDir, MAX_SIZE), new SystemClock());
db.open(getSecretKey(), null); db.open(databaseKey, null);
return db; return db;
} }
......
package org.briarproject.bramble.db; package org.briarproject.bramble.db;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DatabaseConfig; import org.briarproject.bramble.api.db.DatabaseConfig;
import org.briarproject.bramble.api.db.DbException; import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.system.Clock; import org.briarproject.bramble.api.system.Clock;
...@@ -22,6 +23,8 @@ public abstract class SingleDatabasePerformanceTest ...@@ -22,6 +23,8 @@ public abstract class SingleDatabasePerformanceTest
abstract Database<Connection> createDatabase(DatabaseConfig databaseConfig, abstract Database<Connection> createDatabase(DatabaseConfig databaseConfig,
Clock clock); Clock clock);
private SecretKey databaseKey = getSecretKey();
@Override @Override
protected void benchmark(String name, protected void benchmark(String name,
BenchmarkTask<Database<Connection>> task) throws Exception { BenchmarkTask<Database<Connection>> task) throws Exception {
...@@ -41,7 +44,7 @@ public abstract class SingleDatabasePerformanceTest ...@@ -41,7 +44,7 @@ public abstract class SingleDatabasePerformanceTest
private Database<Connection> openDatabase() throws DbException { private Database<Connection> openDatabase() throws DbException {
Database<Connection> db = createDatabase( Database<Connection> db = createDatabase(
new TestDatabaseConfig(testDir, MAX_SIZE), new SystemClock()); new TestDatabaseConfig(testDir, MAX_SIZE), new SystemClock());
db.open(getSecretKey(), null); db.open(databaseKey, null);
return db; return db;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment