summaryrefslogtreecommitdiffstats
path: root/configserver/src/test
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2017-09-20 17:26:02 +0200
committerHarald Musum <musum@oath.com>2017-09-20 17:26:02 +0200
commit479fce58d41a46c3453e4b864c7d0efc673ca87f (patch)
tree9f7537b094fa40a8321b8036e6e3a3e20a44b77c /configserver/src/test
parent8faaf301ec0ccd47048ba6f6d9d644c327b629e6 (diff)
Document and rename to make code easier to understand
Diffstat (limited to 'configserver/src/test')
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/MockSessionZKClient.java14
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java15
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClientTest.java11
5 files changed, 24 insertions, 28 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java
index be98f41c82a..df011dd9307 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java
@@ -155,10 +155,10 @@ public class LocalSessionTest {
}
private LocalSession createSession(TenantName tenant, long sessionId, SessionTest.MockSessionPreparer preparer, Optional<AllocatedHosts> allocatedHosts) throws Exception {
- Path appPath = Path.fromString("/" + sessionId);
- SessionZooKeeperClient zkc = new MockSessionZKClient(curator, appPath, allocatedHosts);
+ Path sessionPath = Path.fromString("/" + sessionId);
+ SessionZooKeeperClient zkc = new MockSessionZKClient(curator, sessionPath, allocatedHosts);
zkc.createWriteStatusTransaction(Session.Status.NEW).commit();
- ZooKeeperClient zkClient = new ZooKeeperClient(configCurator, new BaseDeployLogger(), false, appPath);
+ ZooKeeperClient zkClient = new ZooKeeperClient(configCurator, new BaseDeployLogger(), false, sessionPath);
if (allocatedHosts.isPresent()) {
zkClient.write(allocatedHosts.get());
}
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 412e7881a26..62b0ecbada2 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
@@ -19,20 +19,20 @@ import java.util.Optional;
public class MockSessionZKClient extends SessionZooKeeperClient {
private ApplicationPackage app = null;
- private Optional<AllocatedHosts> info = null;
+ private Optional<AllocatedHosts> info = Optional.empty();
private Session.Status sessionStatus;
- public MockSessionZKClient(Curator curator, Path rootPath) {
- this(curator, rootPath, (ApplicationPackage)null);
+ public MockSessionZKClient(Curator curator, Path sessionPath) {
+ this(curator, sessionPath, (ApplicationPackage)null);
}
- public MockSessionZKClient(Curator curator, Path rootPath, Optional<AllocatedHosts> allocatedHosts) {
- this(curator, rootPath);
+ public MockSessionZKClient(Curator curator, Path sessionPath, Optional<AllocatedHosts> allocatedHosts) {
+ this(curator, sessionPath);
this.info = allocatedHosts;
}
- public MockSessionZKClient(Curator curator, Path rootPath, ApplicationPackage application) {
- super(curator, rootPath);
+ public MockSessionZKClient(Curator curator, Path sessionPath, ApplicationPackage application) {
+ super(curator, sessionPath);
this.app = application;
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java
index e4972e0b9b3..462062ce8a8 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java
@@ -52,9 +52,9 @@ public class RemoteSessionRepoTest extends TestWithCurator {
private void createSession(String root, long sessionId, boolean wait) {
- Path rootPath = Path.fromString(root).append("sessions");
- curator.create(rootPath);
- SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, rootPath.append(String.valueOf(sessionId)));
+ Path sessionsPath = Path.fromString(root).append("sessions");
+ curator.create(sessionsPath);
+ SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, sessionsPath.append(String.valueOf(sessionId)));
zkc.createNewSession(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
if (wait) {
Curator.CompletionWaiter waiter = zkc.getUploadWaiter();
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 13815e30bbd..265eaa501a2 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
@@ -54,14 +54,15 @@ import static org.junit.Assert.*;
*/
public class SessionPreparerTest extends TestWithCurator {
- private static final Path appPath = Path.createRoot().append("testapp");
+ private static final Path tenantPath = Path.createRoot();
+ private static final Path sessionsPath = tenantPath.append("sessions").append("testapp");
private static final File testApp = new File("src/test/apps/app");
private static final File invalidTestApp = new File("src/test/apps/illegalApp");
private SessionPreparer preparer;
private TestComponentRegistry componentRegistry;
private MockFileDistributionFactory fileDistributionFactory;
- private Path tenantPath = appPath;
+
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@@ -116,7 +117,7 @@ public class SessionPreparerTest extends TestWithCurator {
preparer.prepare(getContext(getApplicationPackage(testApp)), getLogger(),
new PrepareParams.Builder().dryRun(true).timeoutBudget(TimeoutBudgetTest.day()).build(),
Optional.empty(), tenantPath, Instant.now());
- assertFalse(configCurator.exists(appPath.append(ConfigCurator.USERAPP_ZK_SUBPATH).append("services.xml").getAbsolute()));
+ assertFalse(configCurator.exists(sessionsPath.append(ConfigCurator.USERAPP_ZK_SUBPATH).append("services.xml").getAbsolute()));
}
@Test
@@ -136,7 +137,7 @@ public class SessionPreparerTest extends TestWithCurator {
assertThat(fileDistributionFactory.mockFileDistributionProvider.getMockFileDBHandler().limitSendingOfDeployedFilesToCalled, is(2));
// Should be called only once no matter how many model versions are built
assertThat(fileDistributionFactory.mockFileDistributionProvider.getMockFileDBHandler().reloadDeployFileDistributorCalled, is(1));
- assertTrue(configCurator.exists(appPath.append(ConfigCurator.USERAPP_ZK_SUBPATH).append("services.xml").getAbsolute()));
+ assertTrue(configCurator.exists(sessionsPath.append(ConfigCurator.USERAPP_ZK_SUBPATH).append("services.xml").getAbsolute()));
}
@Test
@@ -185,8 +186,8 @@ public class SessionPreparerTest extends TestWithCurator {
.applicationName("foo").instanceName("quux").build();
PrepareParams params = new PrepareParams.Builder().applicationId(origId).build();
preparer.prepare(getContext(getApplicationPackage(testApp)), getLogger(), params, Optional.empty(), tenantPath, Instant.now());
- SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, appPath);
- assertTrue(configCurator.exists(appPath.append(SessionZooKeeperClient.APPLICATION_ID_PATH).getAbsolute()));
+ SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, sessionsPath);
+ assertTrue(configCurator.exists(sessionsPath.append(SessionZooKeeperClient.APPLICATION_ID_PATH).getAbsolute()));
assertThat(zkc.readApplicationId(), is(origId));
}
@@ -245,7 +246,7 @@ public class SessionPreparerTest extends TestWithCurator {
}
private SessionContext getContext(FilesApplicationPackage app) throws IOException {
- return new SessionContext(app, new SessionZooKeeperClient(curator, appPath), app.getAppDir(), new MemoryTenantApplications(), new HostRegistry<>(), new SuperModelGenerationCounter(curator));
+ return new SessionContext(app, new SessionZooKeeperClient(curator, sessionsPath), app.getAppDir(), new MemoryTenantApplications(), new HostRegistry<>(), new SuperModelGenerationCounter(curator));
}
private FilesApplicationPackage getApplicationPackage(File testFile) throws IOException {
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 6b733bd7ba1..98ba3d4e178 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
@@ -1,7 +1,6 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.session;
-import com.yahoo.config.provision.TenantName;
import com.yahoo.path.Path;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.text.Utf8;
@@ -105,13 +104,9 @@ public class SessionZooKeeperClientTest extends TestWithCurator {
assertThat(zkId.serializedForm(), is(expectedIdString));
}
- private SessionZooKeeperClient createSessionZKClient(String generation) {
- return createSessionZKClient(generation, 100);
- }
-
- private SessionZooKeeperClient createSessionZKClient(String generation, long createTimeInMillis) {
- SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, Path.fromString(generation));
- zkc.createNewSession(createTimeInMillis, TimeUnit.MILLISECONDS);
+ private SessionZooKeeperClient createSessionZKClient(String sessionId) {
+ SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, Path.fromString(sessionId));
+ zkc.createNewSession(100, TimeUnit.MILLISECONDS);
return zkc;
}