Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only run drop all if database was used in the test #5870

Merged
merged 1 commit into from
May 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ private void verifyNoMultipleDatabases(SpecInfo spec) {
public void interceptSetupSpecMethod(IMethodInvocation invocation) throws Throwable {
final List<FieldInfo> containers = findAllContainers();
startContainers(containers, invocation);
dropAllDatabases();
dropAllDatabases(invocation);
invocation.proceed();
}

@Override
public void interceptSetupMethod(IMethodInvocation invocation) throws Throwable {
dropAllDatabases();
dropAllDatabases(invocation);
invocation.proceed();
}

Expand Down Expand Up @@ -125,14 +125,21 @@ private static TestSystem readContainerFromField(FieldInfo f, IMethodInvocation
*/
@Override
public void interceptCleanupSpecMethod(IMethodInvocation invocation) throws Throwable {
dropAllDatabases();
dropAllDatabases(invocation);
invocation.proceed();
}

private static void dropAllDatabases() throws Exception {
private void dropAllDatabases(IMethodInvocation invocation) throws Exception {
for (TestSystem startedTestSystem : startedTestSystems) {
if (startedTestSystem instanceof DatabaseTestSystem) {
runDropAll(((DatabaseTestSystem) startedTestSystem));
// Only drop the database if it was used in this test.
final List<FieldInfo> containers = findAllContainers();
for (FieldInfo field : containers) {
TestSystem testSystem = readContainerFromField(field, invocation);
if (testSystem == startedTestSystem) {
runDropAll(((DatabaseTestSystem) startedTestSystem));
}
}
}
}
// Start tests from a clean slate, otherwise the MDC will be polluted with info about the dropAll command.
Expand All @@ -142,7 +149,7 @@ private static void dropAllDatabases() throws Exception {

@Override
public void interceptCleanupMethod(IMethodInvocation invocation) throws Throwable {
dropAllDatabases();
dropAllDatabases(invocation);
invocation.proceed();
}

Expand Down
Loading