diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-02-26 09:12:06 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-02-26 09:12:06 +0100 |
commit | 5e444ba5af219de555edeeb78aeeaaaae9fd8335 (patch) | |
tree | 3d5d8ca68b9c11c76631f228e8ca8edcac0334ca /clustercontroller-core | |
parent | 3777557b0069026d0ba5ace3ff66fca6c7354d92 (diff) |
Nonfunctional changes only
Diffstat (limited to 'clustercontroller-core')
3 files changed, 24 insertions, 165 deletions
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java index b3716168300..7ef6d298885 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/StateChangeHandlerTest.java @@ -3,19 +3,29 @@ package com.yahoo.vespa.clustercontroller.core; import com.yahoo.vdslib.distribution.ConfiguredNode; import com.yahoo.vdslib.distribution.Distribution; -import com.yahoo.vdslib.state.*; +import com.yahoo.vdslib.state.ClusterState; +import com.yahoo.vdslib.state.Node; +import com.yahoo.vdslib.state.NodeState; +import com.yahoo.vdslib.state.NodeType; +import com.yahoo.vdslib.state.State; import com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo; import com.yahoo.vespa.clustercontroller.core.listeners.NodeStateOrHostInfoChangeHandler; import com.yahoo.vespa.clustercontroller.core.mocks.TestEventLog; import com.yahoo.vespa.clustercontroller.core.testutils.LogFormatter; -import junit.framework.TestCase; +import org.junit.Before; +import org.junit.Test; + import java.util.LinkedList; import java.util.Set; import java.util.TreeSet; import java.util.logging.Logger; -public class StateChangeHandlerTest extends TestCase { +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class StateChangeHandlerTest { + private static final Logger log = Logger.getLogger(StateChangeHandlerTest.class.getName()); private class Config { int nodeCount = 3; @@ -61,6 +71,7 @@ public class StateChangeHandlerTest extends TestCase { private TestNodeStateOrHostInfoChangeHandler nodeStateUpdateListener; private final ClusterStateGenerator.Params params = new ClusterStateGenerator.Params(); + @Before public void setUp() { LogFormatter.initializeLogging(); } @@ -141,7 +152,8 @@ public class StateChangeHandlerTest extends TestCase { assertEquals(0, cluster.getNodeInfo(node).getPrematureCrashCount()); } - public void testUnstableNodeInSlobrok() throws Exception { + @Test + public void testUnstableNodeInSlobrok() { initialize(new Config()); startWithStableStateClusterWithNodesUp(); Node node = new Node(NodeType.STORAGE, 0); @@ -169,4 +181,5 @@ public class StateChangeHandlerTest extends TestCase { verifyPrematureCrashCountCleared(node); } } + } diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperStressTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperStressTest.java deleted file mode 100644 index e1e5e7c6c15..00000000000 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/ZooKeeperStressTest.java +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2017 Yahoo Holdings. 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.vdslib.state.NodeState; -import com.yahoo.vdslib.state.Node; -import com.yahoo.vespa.clustercontroller.core.database.ZooKeeperDatabase; - -import java.util.Map; - -public class ZooKeeperStressTest extends junit.framework.TestCase { - private Object lock = new Object(); - private int waitTime = 0; - - class LoadGiver extends Thread { - ZooKeeperDatabase db; - public int count = 0; - public int errors = 0; - public int index; - public boolean stopNow = false; - - LoadGiver(ZooKeeperDatabase db, int index) { - this.db = db; - this.index = index; - } - - public void doStop() { - stopNow = true; - } - - public void run() { - try{ - while (!this.isInterrupted() && !stopNow) { - // Needs to take lock for each operation. Store new mastervote can not run at the same time as - // another store new master vote as they kill the ephemeral node - synchronized (lock) { - if (db.isClosed()) { System.err.println(this + " Session broke"); break; } - ++count; - if (db.retrieveLatestSystemStateVersion() == null) { - System.err.println("retrieveLatestSystemStateVersion() failed"); - ++errors; - } - } - Map<Node, NodeState> wantedStates; - synchronized (lock) { - if (db.isClosed()) { System.err.println(this + " Session broke"); break; } - ++count; - wantedStates = db.retrieveWantedStates(); - if (wantedStates == null) { - System.err.println("retrieveWantedStates() failed"); - ++errors; - } - } - synchronized (lock) { - if (db.isClosed()) { System.err.println(this + " Session broke"); break; } - ++count; - if (!db.storeLatestSystemStateVersion(5)) { - System.err.println("storeLastestSystemStateVersion() failed"); - ++errors; - } - } - synchronized (lock) { - if (db.isClosed()) { System.err.println(this + " Session broke"); break; } - ++count; - if (!db.storeMasterVote(0)) { - System.err.println("storeMasterVote() failed"); - ++errors; - } - } - synchronized (lock) { - if (db.isClosed()) { System.err.println(this + " Session broke"); break; } - if (wantedStates != null) { - ++count; - if (!db.storeWantedStates(wantedStates)) { - System.err.println("storeWantedState() failed"); - ++errors; - } - } - } - try{ Thread.sleep(waitTime); } catch (Exception e) {} - } - } catch (InterruptedException e) {} - } - - public String toString() { - return "LoadGiver(" + index + ": count " + count + ", errors " + errors + ")"; - } - } - - public void testNothing() throws Exception { - // Stupid junit fails if there's testclass without tests - } - - public void testZooKeeperStressed() throws Exception { - // Disabled for now.: Unstable - /* - ZooKeeperTestServer zooKeeperServer = new ZooKeeperTestServer(); - Database.DatabaseListener zksl = new Database.DatabaseListener() { - public void handleZooKeeperSessionDown() { - assertFalse("We lost session to ZooKeeper. Shouldn't happen", true); - } - - public void handleMasterData(Map<Integer, Integer> data) { - } - }; - VdsCluster cluster = new VdsCluster("mycluster", 10, 10, true); - int timeout = 30000; - ZooKeeperDatabase db = new ZooKeeperDatabase(cluster, 0, zooKeeperServer.getAddress(), timeout, zksl); - - Collection<LoadGiver> loadGivers = new ArrayList(); - long time = System.currentTimeMillis(); - for (int i = 0; i<10; ++i) { - loadGivers.add(new LoadGiver(db, i)); - } - for (LoadGiver lg : loadGivers) { - lg.start(); - } - for (int i = 0; i<30000; i += 100) { - Thread.sleep(100); - boolean failed = false; - for (LoadGiver lg : loadGivers) { - if (lg.errors > 0) { - failed = true; - } - } - if (failed) i += 5000; - } - int throughput = 0; - int errors = 0; - for (LoadGiver lg : loadGivers) { - assertTrue("Error check prior to attempting to stop: " + lg.toString(), lg.errors == 0); - } - for (LoadGiver lg : loadGivers) { - lg.doStop(); - throughput += lg.count; - errors += lg.errors; - } - time = System.currentTimeMillis() - time; - Double timesecs = new Double(time / 1000.0); - if (timesecs > 0.001) { - System.err.println("Throughput is " + (throughput / timesecs) + "msgs/sec, " + errors + " errors, total messages sent: " + throughput + ", waittime = " + waitTime); - } else { - System.err.println("too small time period " + time + " to calculate throughput"); - } - //try{ Thread.sleep(5000); } catch (Exception e) {} - for (LoadGiver lg : loadGivers) { - lg.join(); - } - for (LoadGiver lg : loadGivers) { - System.err.println(lg); - } - // Disabling test. This fails occasionally for some reason. - for (LoadGiver lg : loadGivers) { - // assertTrue("Error check after having stopped: " + lg.toString(), lg.errors == 0); - } - */ - } -} diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java index d318b63f8c1..f76cfd13af1 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/restapiv2/RequestTest.java @@ -2,15 +2,17 @@ package com.yahoo.vespa.clustercontroller.core.restapiv2; import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure; -import com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiException; -import junit.framework.TestCase; +import org.junit.Test; -public class RequestTest extends TestCase { +import static org.junit.Assert.assertTrue; +public class RequestTest { + + @Test public void testGetResultBeforeCompletion() { Request<String> r = new Request<String>(Request.MasterState.MUST_BE_MASTER) { @Override - public String calculateResult(Context context) throws StateRestApiException { + public String calculateResult(Context context) { return "foo"; } }; @@ -30,4 +32,5 @@ public class RequestTest extends TestCase { assertTrue(false); } } + } |