Skip to content

Commit 1379c97

Browse files
stIncMalejoykim1005
authored andcommitted
Make sure TestDef is created and used only when there is enough data to do that (#1578)
When `com.mongodb.client.unified.UnifiedTest` is used by `com.mongodb.workload.WorkloadExecutor` for running tests with Astrolabe, `TestDef` shouldn't be created. JAVA-5716
1 parent e934934 commit 1379c97

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Diff for: driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java

+13-7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public abstract class UnifiedTest {
117117
private UnifiedTestContext rootContext;
118118
private boolean ignoreExtraEvents;
119119
private BsonDocument startingClusterTime;
120+
@Nullable
120121
private TestDef testDef;
121122

122123
private class UnifiedTestContext {
@@ -215,11 +216,13 @@ public void setUp(
215216
rootContext = new UnifiedTestContext();
216217
rootContext.getAssertionContext().push(ContextElement.ofTest(definition));
217218
ignoreExtraEvents = false;
218-
testDef = testDef(directoryName, fileDescription, testDescription, isReactive());
219-
UnifiedTestModifications.doSkips(testDef);
219+
if (directoryName != null && fileDescription != null && testDescription != null) {
220+
testDef = testDef(directoryName, fileDescription, testDescription, isReactive());
221+
UnifiedTestModifications.doSkips(testDef);
220222

221-
boolean skip = testDef.wasAssignedModifier(UnifiedTestModifications.Modifier.SKIP);
222-
assumeFalse(skip, "Skipping test");
223+
boolean skip = testDef.wasAssignedModifier(UnifiedTestModifications.Modifier.SKIP);
224+
assumeFalse(skip, "Skipping test");
225+
}
223226
skips(fileDescription, testDescription);
224227

225228
assertTrue(
@@ -268,8 +271,9 @@ public void setUp(
268271
this::createMongoClient,
269272
this::createGridFSBucket,
270273
this::createClientEncryption);
271-
272-
postSetUp(testDef);
274+
if (testDef != null) {
275+
postSetUp(testDef);
276+
}
273277
}
274278

275279
protected void postSetUp(final TestDef def) {
@@ -281,7 +285,9 @@ public void cleanUp() {
281285
failPoint.disableFailPoint();
282286
}
283287
entities.close();
284-
postCleanUp(testDef);
288+
if (testDef != null) {
289+
postCleanUp(testDef);
290+
}
285291
}
286292

287293
protected void postCleanUp(final TestDef testDef) {

Diff for: driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestModifications.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,9 @@ public static final class TestDef {
281281
private final List<Modifier> modifiers = new ArrayList<>();
282282

283283
private TestDef(final String dir, final String file, final String test, final boolean reactive) {
284-
this.dir = dir;
285-
this.file = file;
286-
this.test = test;
284+
this.dir = assertNotNull(dir);
285+
this.file = assertNotNull(file);
286+
this.test = assertNotNull(test);
287287
this.reactive = reactive;
288288
}
289289

0 commit comments

Comments
 (0)