blob: 9fe56cceec530f6424bb5d78fe06db47b8da58fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package com.yahoo.vespa.clustercontroller.core;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.TestWatcher;
public class CleanupZookeeperLogsOnSuccess implements TestWatcher {
public CleanupZookeeperLogsOnSuccess() {}
@Override
public void testFailed(ExtensionContext context, Throwable cause) {
System.err.println("TEST FAILED - NOT cleaning up zookeeper directory");
shutdownZooKeeper(context, false);
}
@Override
public void testSuccessful(ExtensionContext context) {
System.err.println("TEST SUCCEEDED - cleaning up zookeeper directory");
shutdownZooKeeper(context, true);
}
private void shutdownZooKeeper(ExtensionContext ctx, boolean cleanupZooKeeperDir) {
FleetControllerTest test = (FleetControllerTest) ctx.getTestInstance().orElseThrow();
if (test.zooKeeperServer != null) {
test.zooKeeperServer.shutdown(cleanupZooKeeperDir);
test.zooKeeperServer = null;
}
}
}
|