Skip to content

Commit 27846c0

Browse files
authored
Re enable auto test (#3558)
This allows one to run `@AutomatedTest` tests. These tests are added to the nightly build. I have tested individual tests locally, but not the overall build, and integration.
1 parent cd41f9a commit 27846c0

File tree

9 files changed

+61
-63
lines changed

9 files changed

+61
-63
lines changed

fdb-relational-core/fdb-relational-core.gradle

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,11 @@ dependencies {
6363
testFixturesImplementation(project(coreProject))
6464
}
6565

66-
/*
67-
task autoTest(type: Test){
68-
description = 'Runs the Automated end-to-end tests.'
69-
group = 'verification'
70-
// testClassesDir = sourceSets.test.output.classesDirs
71-
classpath = sourceSets.test.runtimeClasspath
72-
73-
useJUnitPlatform {
74-
includeEngines 'auto-test'
75-
excludeEngines 'junit-jupiter'
76-
}
77-
78-
reports {
79-
junitXml.outputLocation = layout.buildDirectory.dir("autotest-test-results")
80-
}
66+
// The engine is defined in relational-core. If we move it somewhere such that other subprojects can use it, this
67+
// task should be moved to testing.gradle
68+
tasks.withType(Test).configureEach { theTask ->
69+
theTask.testFramework.options.includeEngines.add('auto-test')
8170
}
82-
*/
8371

8472
publishing {
8573
publications {

fdb-relational-core/src/test/java/com/apple/foundationdb/relational/autotest/WorkloadConfig.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,28 @@
2929
import java.util.Map;
3030

3131
public class WorkloadConfig implements ParameterResolver {
32-
public static final String SEED_KEY = "seed";
3332
public static final String SAMPLE_SIZE = "sampleSize";
3433
public static final String INSERT_BATCH_SIZE = "insertBatchSize";
35-
public static final String REPORT_DIRECTORY = "reportDirectory";
3634

35+
private final long seed;
36+
private final String reportDirectory;
3737
private final Map<String, Object> configs;
3838

39-
public WorkloadConfig(Map<String, Object> configs) {
40-
this.configs = new HashMap<>(configs);
39+
public WorkloadConfig(String reportDirectory, Map<String, Object> otherConfigs) {
40+
// Eventually we should change `includeRandom` to get it from the property like RandomizedTestUtils, but
41+
// these tests seem to fail pretty reliably once the random seed is put in, which would really mess with
42+
// the nightly builds.
43+
this.seed = Long.parseLong(System.getProperty("tests.autoSeed", "2363712622230246740"));
44+
this.reportDirectory = reportDirectory;
45+
this.configs = new HashMap<>(otherConfigs);
4146
}
4247

43-
public WorkloadConfig() {
44-
this.configs = new HashMap<>();
48+
public long getSeed() {
49+
return seed;
50+
}
51+
52+
public String getReportDirectory() {
53+
return reportDirectory;
4554
}
4655

4756
public Object get(String key) {

fdb-relational-core/src/test/java/com/apple/foundationdb/relational/autotest/cases/DirectPrimaryKeyScanTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import com.apple.foundationdb.relational.memory.InMemoryCatalog;
4444
import com.apple.foundationdb.relational.memory.InMemoryRelationalConnection;
4545
import com.apple.foundationdb.relational.recordlayer.EmbeddedRelationalExtension;
46-
4746
import org.junit.jupiter.api.extension.RegisterExtension;
4847

4948
import java.net.URI;
@@ -53,6 +52,7 @@
5352
import java.util.Collection;
5453
import java.util.List;
5554
import java.util.Map;
55+
import java.util.UUID;
5656
import java.util.stream.Stream;
5757

5858
@AutomatedTest
@@ -61,18 +61,18 @@ public class DirectPrimaryKeyScanTest {
6161
public static final EmbeddedRelationalExtension relational = new EmbeddedRelationalExtension();
6262

6363
@WorkloadConfiguration
64-
public WorkloadConfig config = new WorkloadConfig(Map.of(
65-
"seed", 1L,
66-
WorkloadConfig.REPORT_DIRECTORY, System.getProperty("user.dir") + "/.out/reports/autoTest/" + getClass().getSimpleName(),
67-
"maxStringLength", 10,
68-
"maxBytesLength", 10,
69-
"maxArrayLength", 10,
70-
"maxTables", 1,
71-
"maxStructs", 2,
72-
"maxColumns", 5,
73-
"numSchemas", 2,
74-
"recordsPerTable", 10
75-
));
64+
public WorkloadConfig config = new WorkloadConfig(
65+
System.getProperty("user.dir") + "/.out/reports/autoTest/" + getClass().getSimpleName(),
66+
Map.of(
67+
"maxStringLength", 10,
68+
"maxBytesLength", 10,
69+
"maxArrayLength", 10,
70+
"maxTables", 1,
71+
"maxStructs", 2,
72+
"maxColumns", 5,
73+
"numSchemas", 2,
74+
"recordsPerTable", 10
75+
));
7676

7777
@Connection
7878
public Connector relationalConnector = new Connector() {
@@ -104,14 +104,14 @@ public String getLabel() {
104104

105105
@Schema
106106
public Stream<SchemaDescription> getSchemas(WorkloadConfig cfg) throws SQLException {
107-
RandomDataSource rds = new UniformDataSource(cfg.getLong("seed"),
107+
RandomDataSource rds = new UniformDataSource(cfg.getSeed(),
108108
cfg.getInt("maxStringLength"),
109109
cfg.getInt("maxBytesLength"));
110110
SchemaGenerator generator = new SchemaGenerator(rds, cfg.getInt("maxTables"),
111111
cfg.getInt("maxStructs"),
112112
cfg.getInt("maxColumns"));
113113

114-
String baseTemplateName = this.getClass().getSimpleName();
114+
String baseTemplateName = this.getClass().getSimpleName() + "_" + String.valueOf(UUID.randomUUID()).replace("-", "_");
115115

116116
int numSchemasToGen = cfg.getInt("numSchemas");
117117
List<SchemaDescription> schemas = new ArrayList<>();
@@ -125,7 +125,7 @@ public Stream<SchemaDescription> getSchemas(WorkloadConfig cfg) throws SQLExcept
125125

126126
@Data
127127
public final DataSet dataSet() {
128-
return new RandomDataSet(config.getLong("seed"),
128+
return new RandomDataSet(config.getSeed(),
129129
config.getInt("maxArrayLength"),
130130
config.getInt("recordsPerTable"),
131131
config.getInt("maxStringLength"),

fdb-relational-core/src/test/java/com/apple/foundationdb/relational/autotest/cases/KnownPkGetTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import com.apple.foundationdb.relational.memory.InMemoryCatalog;
4444
import com.apple.foundationdb.relational.memory.InMemoryRelationalConnection;
4545
import com.apple.foundationdb.relational.recordlayer.EmbeddedRelationalExtension;
46-
4746
import org.junit.jupiter.api.extension.RegisterExtension;
4847

4948
import java.net.URI;
@@ -53,6 +52,7 @@
5352
import java.util.Collection;
5453
import java.util.List;
5554
import java.util.Map;
55+
import java.util.UUID;
5656
import java.util.stream.Stream;
5757

5858
@AutomatedTest
@@ -61,18 +61,18 @@ public class KnownPkGetTest {
6161
public static final EmbeddedRelationalExtension relational = new EmbeddedRelationalExtension();
6262

6363
@WorkloadConfiguration
64-
public WorkloadConfig config = new WorkloadConfig(Map.of(
65-
"seed", 1L,
66-
WorkloadConfig.REPORT_DIRECTORY, System.getProperty("user.dir") + "/.out/reports/autoTest/" + KnownPkGetTest.class.getSimpleName(),
67-
"maxStringLength", 10,
68-
"maxBytesLength", 10,
69-
"maxArrayLength", 10,
70-
"maxTables", 1,
71-
"maxStructs", 2,
72-
"maxColumns", 5,
73-
"numSchemas", 5,
74-
"recordsPerTable", 20
75-
));
64+
public WorkloadConfig config = new WorkloadConfig(
65+
System.getProperty("user.dir") + "/.out/reports/autoTest/" + KnownPkGetTest.class.getSimpleName(),
66+
Map.of(
67+
"maxStringLength", 10,
68+
"maxBytesLength", 10,
69+
"maxArrayLength", 10,
70+
"maxTables", 1,
71+
"maxStructs", 2,
72+
"maxColumns", 5,
73+
"numSchemas", 5,
74+
"recordsPerTable", 20
75+
));
7676

7777
public KnownPkGetTest() {
7878
System.out.println("Running");
@@ -108,14 +108,14 @@ public String getLabel() {
108108

109109
@Schema
110110
public Stream<SchemaDescription> getSchemas(WorkloadConfig cfg) throws SQLException {
111-
RandomDataSource rds = new UniformDataSource(cfg.getLong("seed"),
111+
RandomDataSource rds = new UniformDataSource(cfg.getSeed(),
112112
cfg.getInt("maxStringLength"),
113113
cfg.getInt("maxBytesLength"));
114114
SchemaGenerator generator = new SchemaGenerator(rds, cfg.getInt("maxTables"),
115115
cfg.getInt("maxStructs"),
116116
cfg.getInt("maxColumns"));
117117

118-
String baseTemplateName = this.getClass().getSimpleName();
118+
String baseTemplateName = this.getClass().getSimpleName() + "_" + String.valueOf(UUID.randomUUID()).replace("-", "_");
119119

120120
int numSchemasToGen = cfg.getInt("numSchemas");
121121
List<SchemaDescription> schemas = new ArrayList<>();
@@ -129,7 +129,7 @@ public Stream<SchemaDescription> getSchemas(WorkloadConfig cfg) throws SQLExcept
129129

130130
@Data
131131
public final DataSet dataSet() {
132-
return new RandomDataSet(config.getLong("seed"),
132+
return new RandomDataSet(config.getSeed(),
133133
config.getInt("maxArrayLength"),
134134
config.getInt("recordsPerTable"),
135135
config.getInt("maxStringLength"),

fdb-relational-core/src/test/java/com/apple/foundationdb/relational/autotest/datagen/StructFieldGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private FieldGenerator getArrayFieldGenerator(@Nonnull String name, @Nonnull Arr
9090
if (arrayMetaData.getElementType() == Types.STRUCT) {
9191
componentGenerator = getStructFieldGenerator("na", arrayMetaData.getElementStructMetaData());
9292
} else {
93-
componentGenerator = getPrimitiveFieldGenerator("na", arrayMetaData.asRelationalType());
93+
componentGenerator = getPrimitiveFieldGenerator("na", arrayMetaData.asRelationalType().getElementType());
9494
}
9595
return new ArrayFieldGenerator(name, componentGenerator, randomSource, maxArraySize);
9696
}

fdb-relational-core/src/test/java/com/apple/foundationdb/relational/autotest/engine/AutoTestDescriptor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ class AutoTestDescriptor extends ClassTestDescriptor {
6262
private final QueryInvoker queryInvoker;
6363
private final List<ConnectionMaker> connectionMakers;
6464
private final ConfigurationInvoker configInvoker;
65-
private static final WorkloadConfig defaultConfig = new WorkloadConfig(Map.of(
66-
WorkloadConfig.SEED_KEY, System.currentTimeMillis(),
67-
WorkloadConfig.INSERT_BATCH_SIZE, 16,
68-
WorkloadConfig.SAMPLE_SIZE, 128,
69-
WorkloadConfig.REPORT_DIRECTORY, System.getProperty("user.dir")
65+
private static final WorkloadConfig defaultConfig = new WorkloadConfig(
66+
System.getProperty("user.dir"),
67+
Map.of(
68+
WorkloadConfig.INSERT_BATCH_SIZE, 16,
69+
WorkloadConfig.SAMPLE_SIZE, 128
7070
));
7171

7272
AutoTestDescriptor(UniqueId uniqueId,

fdb-relational-core/src/test/java/com/apple/foundationdb/relational/autotest/engine/WorkloadReporter.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public void publishWorkload(AutoWorkload workload) {
7171
workloadName = workload.getDisplayName();
7272
properties = new Properties();
7373
properties.put("SchemaDescription", workload.getSchema());
74+
properties.put("seed", workload.getConfig().getSeed());
75+
properties.put("reportDirectory", workload.getConfig().getReportDirectory());
7476
properties.putAll(workload.getConfig().asMap());
7577
timestamp = System.currentTimeMillis();
7678
}

fdb-relational-core/src/test/java/com/apple/foundationdb/relational/autotest/engine/WorkloadTestDescriptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public JupiterEngineExecutionContext execute(JupiterEngineExecutionContext conte
106106
* First, create the data
107107
*/
108108
context.getThrowableCollector().execute(() -> {
109-
WorkloadReporter reporter = new WorkloadReporter((String) workload.getConfig().get("reportDirectory"));
109+
WorkloadReporter reporter = new WorkloadReporter(workload.getConfig().getReportDirectory());
110110
reporter.publishWorkload(workload);
111111
try {
112112
loadSchema(workload);
@@ -279,7 +279,7 @@ private DataSample loadData(AutoWorkload workload) {
279279
//TODO(bfines) configure this
280280
final WorkloadConfig config = workload.getConfig();
281281
ReservoirSample<RelationalStruct> reservoir = new ReservoirSample<>(config.getInt(WorkloadConfig.SAMPLE_SIZE, 100),
282-
config.getLong(WorkloadConfig.SEED_KEY, System.currentTimeMillis()));
282+
config.getSeed());
283283
try (Stream<RelationalStruct> structs = dataSet.getData(table)) {
284284
/*
285285
* Read in a batch of records, and insert them to every connector

gradle/testing.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ test {
3131
useJUnitPlatform {
3232
excludeTags 'WipesFDB'
3333
excludeTags 'AutomatedTest'
34-
excludeEngines 'auto-test'
3534
}
3635
}
3736

0 commit comments

Comments
 (0)