summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-08-19 08:02:03 +0200
committerHarald Musum <musum@verizonmedia.com>2020-08-19 08:02:03 +0200
commite9735d15b741882eb410bb4bfd4f2ddf9570e8b4 (patch)
tree9ce13ab681d9c1b6814a650d3006de847bc20029
parent2f0ccbe4e07afee74513e9e89a2a037db47fd542 (diff)
Use just one constructor for SessionZooKeeperClient
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java7
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/MockSessionZKClient.java7
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java14
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java7
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java6
5 files changed, 26 insertions, 15 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java
index cf1e07788ff..f0a82a4da7e 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java
@@ -11,7 +11,6 @@ import com.yahoo.config.provision.AllocatedHosts;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.AthenzDomain;
import com.yahoo.config.provision.DockerImage;
-import com.yahoo.config.provision.NodeFlavors;
import com.yahoo.path.Path;
import com.yahoo.text.Utf8;
import com.yahoo.transaction.Transaction;
@@ -52,12 +51,6 @@ public class SessionZooKeeperClient {
private final Path sessionStatusPath;
private final String serverId; // hostname
- // Only for testing
- // TODO: Remove, use the constructor below
- public SessionZooKeeperClient(Curator curator, Path sessionPath) {
- this(curator, ConfigCurator.create(curator), sessionPath, "1");
- }
-
public SessionZooKeeperClient(Curator curator,
ConfigCurator configCurator,
Path sessionPath,
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/MockSessionZKClient.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/MockSessionZKClient.java
index 692510b8b6d..296fbf56b3d 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/MockSessionZKClient.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/MockSessionZKClient.java
@@ -6,6 +6,8 @@ import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.provision.AllocatedHosts;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
+import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
+import com.yahoo.vespa.config.util.ConfigUtils;
import com.yahoo.vespa.curator.Curator;
import java.util.Optional;
@@ -30,7 +32,10 @@ public class MockSessionZKClient extends SessionZooKeeperClient {
}
MockSessionZKClient(Curator curator, TenantName tenantName, long sessionId, ApplicationPackage application) {
- super(curator, TenantRepository.getSessionsPath(tenantName).append(String.valueOf(sessionId)));
+ super(curator,
+ ConfigCurator.create(curator),
+ TenantRepository.getSessionsPath(tenantName).append(String.valueOf(sessionId)),
+ ConfigUtils.getCanonicalHostName());
this.app = application;
curator.create(TenantRepository.getSessionsPath(tenantName).append(String.valueOf(sessionId)));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java
index e53f9270983..1fa7ceed755 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java
@@ -43,6 +43,7 @@ import com.yahoo.vespa.config.server.tenant.ContainerEndpointsCache;
import com.yahoo.vespa.config.server.tenant.EndpointCertificateMetadataStore;
import com.yahoo.vespa.config.server.tenant.EndpointCertificateRetriever;
import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
+import com.yahoo.vespa.config.util.ConfigUtils;
import com.yahoo.vespa.curator.mock.MockCurator;
import com.yahoo.vespa.flags.Flags;
import com.yahoo.vespa.flags.InMemoryFlagSource;
@@ -172,7 +173,7 @@ public class SessionPreparerTest {
HostRegistry<ApplicationId> hostValidator = new HostRegistry<>();
hostValidator.update(applicationId("foo"), Collections.singletonList("mytesthost"));
preparer.prepare(hostValidator, new BaseDeployLogger(), new PrepareParams.Builder().applicationId(applicationId("default")).build(),
- Optional.empty(), tenantPath, Instant.now(), app.getAppDir(), app, new SessionZooKeeperClient(curator, sessionsPath));
+ Optional.empty(), tenantPath, Instant.now(), app.getAppDir(), app, createSessionZooKeeperClient());
}
@Test
@@ -187,7 +188,7 @@ public class SessionPreparerTest {
hostValidator.update(applicationId, Collections.singletonList("mytesthost"));
preparer.prepare(hostValidator, logger, new PrepareParams.Builder().applicationId(applicationId).build(),
Optional.empty(), tenantPath, Instant.now(), app.getAppDir(), app,
- new SessionZooKeeperClient(curator, sessionsPath));
+ createSessionZooKeeperClient());
assertEquals(logged.toString(), "");
}
@@ -199,9 +200,8 @@ public class SessionPreparerTest {
.applicationName("foo").instanceName("quux").build();
PrepareParams params = new PrepareParams.Builder().applicationId(origId).build();
prepare(testApp, params);
- SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, sessionsPath);
assertTrue(configCurator.exists(sessionsPath.append(SessionZooKeeperClient.APPLICATION_ID_PATH).getAbsolute()));
- assertThat(zkc.readApplicationId(), is(origId));
+ assertThat(createSessionZooKeeperClient().readApplicationId(), is(origId));
}
@Test
@@ -336,7 +336,7 @@ public class SessionPreparerTest {
FilesApplicationPackage applicationPackage = getApplicationPackage(app);
return preparer.prepare(new HostRegistry<>(), getLogger(), params,
Optional.empty(), tenantPath, Instant.now(), applicationPackage.getAppDir(),
- applicationPackage, new SessionZooKeeperClient(curator, sessionsPath));
+ applicationPackage, createSessionZooKeeperClient());
}
private FilesApplicationPackage getApplicationPackage(File testFile) throws IOException {
@@ -360,6 +360,10 @@ public class SessionPreparerTest {
ApplicationName.from(applicationName), InstanceName.defaultName());
}
+ private SessionZooKeeperClient createSessionZooKeeperClient() {
+ return new SessionZooKeeperClient(curator, configCurator, sessionsPath, ConfigUtils.getCanonicalHostName());
+ }
+
private static class FailWithTransientExceptionProvisioner implements Provisioner {
@Override
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
index 13a27e570c2..9b9682faf5f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
@@ -11,6 +11,8 @@ import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
+import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
+import com.yahoo.vespa.config.util.ConfigUtils;
import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
import com.yahoo.vespa.flags.FlagSource;
@@ -153,7 +155,10 @@ public class SessionRepositoryTest {
}
private void createSession(long sessionId, boolean wait, SessionRepository sessionRepository) {
- SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, sessionRepository.getSessionPath(sessionId));
+ SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator,
+ ConfigCurator.create(curator),
+ sessionRepository.getSessionPath(sessionId),
+ ConfigUtils.getCanonicalHostName());
zkc.createNewSession(Instant.now());
if (wait) {
Curator.CompletionWaiter waiter = zkc.getUploadWaiter();
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
index 1d7df7acfd0..fd0e34b9814 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java
@@ -6,6 +6,7 @@ import com.yahoo.config.provision.ApplicationId;
import com.yahoo.path.Path;
import com.yahoo.text.Utf8;
import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
+import com.yahoo.vespa.config.util.ConfigUtils;
import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
import org.junit.Before;
@@ -112,7 +113,10 @@ public class SessionZooKeeperClientTest {
}
private SessionZooKeeperClient createSessionZKClient(String sessionId) {
- SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, Path.fromString(sessionId));
+ SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator,
+ ConfigCurator.create(curator),
+ Path.fromString(sessionId),
+ ConfigUtils.getCanonicalHostName());
zkc.createNewSession(Instant.now());
return zkc;
}