diff options
author | Tor Brede Vekterli <vekterli@verizonmedia.com> | 2021-03-18 13:31:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 13:31:50 +0100 |
commit | 85ad07ca7b5a1625048155ee3d55dffcd4da38c5 (patch) | |
tree | 4a38a87ee532c4a091d2834e9581943a65242d48 /clustercontroller-core/src/test | |
parent | 97cab75cbccc5bacbf0ad1fcb4795180801277cd (diff) | |
parent | 5b135fb388bd6e5c98b10383cc79692d370646da (diff) |
Merge pull request #17029 from vespa-engine/vekterli/inhibit-db-connectivity-until-slobrok-is-ready
Inhibit ZooKeeper connections until our local Slobrok mirror is ready.
Diffstat (limited to 'clustercontroller-core/src/test')
2 files changed, 17 insertions, 1 deletions
diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java index 9c0a94309a5..7f664e65dc0 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DatabaseHandlerTest.java @@ -10,6 +10,7 @@ import org.junit.Test; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; @@ -65,11 +66,22 @@ public class DatabaseHandlerTest { } DatabaseHandler createHandler() throws Exception { - return new DatabaseHandler(mockDbFactory, mockTimer, databaseAddress, 0, monitor); + var handler = new DatabaseHandler(mockDbFactory, mockTimer, databaseAddress, 0, monitor); + handler.setConnectionEstablishmentIsAllowed(true); + return handler; } } @Test + public void can_not_connect_to_database_if_connectivity_is_not_allowed() throws Exception { + Fixture f = new Fixture(); + DatabaseHandler handler = f.createHandler(); + handler.setConnectionEstablishmentIsAllowed(false); + handler.doNextZooKeeperTask(f.createMockContext()); + assertTrue(handler.isClosed()); // No connectivity allowed yet + } + + @Test public void can_store_latest_cluster_state_bundle() throws Exception { Fixture f = new Fixture(); DatabaseHandler handler = f.createHandler(); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java index b322c62967a..d7bca47026f 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/DummyCommunicator.java @@ -154,4 +154,8 @@ public class DummyCommunicator implements Communicator, NodeLookup { return false; } + @Override + public boolean isReady() { + return true; + } } |