diff options
author | Harald Musum <musum@yahooinc.com> | 2022-09-15 11:40:43 +0200 |
---|---|---|
committer | Harald Musum <musum@yahooinc.com> | 2022-09-15 11:40:43 +0200 |
commit | 5c528eac65693e4cec73339d4e42d9ddcef680e8 (patch) | |
tree | 3bfec4a78e730fdda7d2fb6162e20ad0d0b11b4e | |
parent | 886bb1426b970a7bfcf032a5053c68c28480ab2e (diff) |
Cleanup by using supervisor in superclass
5 files changed, 6 insertions, 62 deletions
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java index 409e8932867..0485bd80aa0 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ClusterFeedBlockTest.java @@ -1,8 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.clustercontroller.core; -import com.yahoo.jrt.Supervisor; -import com.yahoo.jrt.Transport; import com.yahoo.vdslib.state.Node; import com.yahoo.vdslib.state.NodeState; import com.yahoo.vdslib.state.NodeType; @@ -11,21 +9,19 @@ import com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler; import com.yahoo.vespa.clustercontroller.core.database.ZooKeeperDatabaseFactory; import com.yahoo.vespa.clustercontroller.core.status.StatusHandler; import com.yahoo.vespa.clustercontroller.utils.util.NoMetricReporter; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; - import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.createResourceUsageJson; import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.mapOf; import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.setOf; import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.usage; import static org.junit.jupiter.api.Assertions.assertEquals; -import static com.yahoo.vespa.clustercontroller.core.FeedBlockUtil.createResourceUsageJson; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -35,15 +31,9 @@ public class ClusterFeedBlockTest extends FleetControllerTest { private static final int NODE_COUNT = 3; // TODO dedupe fixture and setup stuff with other tests - private Supervisor supervisor; private FleetController ctrl; private DummyCommunicator communicator; - @BeforeEach - public void setUp() { - supervisor = new Supervisor(new Transport()); - } - private void initialize(FleetControllerOptions options) throws Exception { List<Node> nodes = new ArrayList<>(); for (int i = 0; i < options.nodes().size(); ++i) { @@ -78,14 +68,6 @@ public class ClusterFeedBlockTest extends FleetControllerTest { ctrl.tick(); } - public void tearDown() throws Exception { - if (supervisor != null) { - supervisor.transport().shutdown().join(); - supervisor = null; - } - super.tearDown(); - } - private static FleetControllerOptions createOptions(Map<String, Double> feedBlockLimits, double clusterFeedBlockNoiseLevel) { return defaultOptions("mycluster") .setStorageDistribution(DistributionBuilder.forFlatCluster(NODE_COUNT)) diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java index 4fff3023411..de01a290ec6 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java @@ -251,7 +251,8 @@ public abstract class FleetControllerTest implements Waiter { subsetWaiter.waitForState(expectedState); } - protected void tearDownSystem() { + @AfterEach + public void tearDown() { if (testName != null) { //log.log(Level.INFO, "STOPPING TEST " + testName); System.err.println("STOPPING TEST " + testName); @@ -278,11 +279,6 @@ public abstract class FleetControllerTest implements Waiter { } } - @AfterEach - public void tearDown() throws Exception { - tearDownSystem(); - } - public ClusterState waitForStableSystem() throws Exception { return waiter.waitForStableSystem(); } public ClusterState waitForStableSystem(int nodeCount) throws Exception { return waiter.waitForStableSystem(nodeCount); } public ClusterState waitForState(String state) throws Exception { return waiter.waitForState(state); } diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java index 0631485bba8..4b566bd2aab 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/MasterElectionTest.java @@ -35,8 +35,6 @@ public class MasterElectionTest extends FleetControllerTest { private static final Logger log = Logger.getLogger(MasterElectionTest.class.getName()); private static int defaultZkSessionTimeoutInMillis() { return 30_000; } - private Supervisor supervisor; - protected void setUpFleetControllers(int count, boolean useFakeTimer, FleetControllerOptions.Builder builder) throws Exception { if (zooKeeperServer == null) { zooKeeperServer = new ZooKeeperTestServer(); @@ -86,13 +84,6 @@ public class MasterElectionTest extends FleetControllerTest { } } - public void tearDown() throws Exception { - if (supervisor != null) { - supervisor.transport().shutdown().join(); - } - super.tearDown(); - } - @Test void testMasterElection() throws Exception { startingTest("MasterElectionTest::testMasterElection"); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java index f9eda9040d2..e61bdd566c3 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java @@ -44,15 +44,6 @@ public class RpcServerTest extends FleetControllerTest { public static Logger log = Logger.getLogger(RpcServerTest.class.getName()); - private Supervisor supervisor; - - public void tearDown() throws Exception { - if (supervisor != null) { - supervisor.transport().shutdown().join(); - } - super.tearDown(); - } - @Test void testRebinding() throws Exception { startingTest("RpcServerTest::testRebinding"); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java index 18691fc8747..5868ad723a4 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeTest.java @@ -1,8 +1,6 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.clustercontroller.core; -import com.yahoo.jrt.Supervisor; -import com.yahoo.jrt.Transport; import com.yahoo.vdslib.distribution.ConfiguredNode; import com.yahoo.vdslib.state.ClusterState; import com.yahoo.vdslib.state.Node; @@ -14,10 +12,8 @@ import com.yahoo.vespa.clustercontroller.core.database.ZooKeeperDatabaseFactory; import com.yahoo.vespa.clustercontroller.core.status.StatusHandler; import com.yahoo.vespa.clustercontroller.core.testutils.StateWaiter; import com.yahoo.vespa.clustercontroller.utils.util.NoMetricReporter; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; - import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; @@ -27,22 +23,18 @@ import java.util.logging.Logger; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; @ExtendWith(CleanupZookeeperLogsOnSuccess.class) public class StateChangeTest extends FleetControllerTest { public static Logger log = Logger.getLogger(StateChangeTest.class.getName()); - private Supervisor supervisor; private FleetController ctrl; private DummyCommunicator communicator; private EventLog eventLog; - @BeforeEach - public void setUp() { - supervisor = new Supervisor(new Transport()); - } - private void initialize(FleetControllerOptions options) throws Exception { List<Node> nodes = new ArrayList<>(); for (int i = 0; i < options.nodes().size(); ++i) { @@ -79,14 +71,6 @@ public class StateChangeTest extends FleetControllerTest { ctrl.tick(); } - public void tearDown() throws Exception { - if (supervisor != null) { - supervisor.transport().shutdown().join(); - supervisor = null; - } - super.tearDown(); - } - private void verifyNodeEvents(Node n, String correct) { String actual = ""; for (NodeEvent e : eventLog.getNodeEvents(n)) { |