diff options
author | Harald Musum <musum@oath.com> | 2018-05-11 10:46:08 +0200 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2018-05-11 10:46:08 +0200 |
commit | 38a866b090f95d1266e1e2b4a1d65e1f093bb5e8 (patch) | |
tree | 512254c8a0a555d483037b5e3940ff945267c48b /configserver/src/test | |
parent | c69f9a0dfcbc09590a409d5d4eb10bbb7229f28b (diff) |
Minor refactoring to creating session
Diffstat (limited to 'configserver/src/test')
4 files changed, 26 insertions, 11 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index c489c51038f..90f0b5ee4e5 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -2,6 +2,9 @@ package com.yahoo.vespa.config.server; import com.yahoo.config.model.application.provider.FilesApplicationPackage; +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.ApplicationName; +import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.Provisioner; import com.yahoo.config.provision.TenantName; import com.yahoo.vespa.config.server.http.CompressedApplicationInputStream; @@ -80,20 +83,23 @@ public class ApplicationRepositoryTest { private PrepareResult prepareAndActivateApp(File application) throws IOException { FilesApplicationPackage appDir = FilesApplicationPackage.fromFile(application); - long sessionId = applicationRepository.createSession(tenant, timeoutBudget, appDir.getAppDir(), "testapp"); + long sessionId = applicationRepository.createSession(applicationId(), timeoutBudget, appDir.getAppDir()); return applicationRepository.prepareAndActivate(tenant, sessionId, prepareParams(), false, false, Instant.now()); } private PrepareResult createAndPrepareAndActivateApp() throws IOException { File file = CompressedApplicationInputStreamTest.createTarFile(); - return applicationRepository.deploy(tenant, - CompressedApplicationInputStream.createFromCompressedStream( + return applicationRepository.deploy(CompressedApplicationInputStream.createFromCompressedStream( new FileInputStream(file), ApplicationApiHandler.APPLICATION_X_GZIP), prepareParams(), false, false, Instant.now()); } private PrepareParams prepareParams() { - return new PrepareParams.Builder().build(); + return new PrepareParams.Builder().applicationId(applicationId()).build(); + } + + private ApplicationId applicationId() { + return ApplicationId.from(tenantName, ApplicationName.from("testapp"), InstanceName.defaultName()); } } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java index 266833ac7f3..ce53451ae2e 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java @@ -150,7 +150,7 @@ public class DeployTester { if (vespaVersion != null) paramsBuilder.vespaVersion(vespaVersion); - long sessionId = applicationRepository.createSession(tenant, timeoutBudget, testApp, appName); + long sessionId = applicationRepository.createSession(id, timeoutBudget, testApp); applicationRepository.prepare(tenant, sessionId, paramsBuilder.build(), now); applicationRepository.activate(tenant, sessionId, timeoutBudget, false, false); this.id = id; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java index 0f20ca3163b..930ae98c9e9 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java @@ -191,9 +191,9 @@ public class SessionHandlerTest { public String applicationName; @Override - public LocalSession createSession(File applicationDirectory, String applicationName, TimeoutBudget timeoutBudget) { + public LocalSession createSession(File applicationDirectory, ApplicationId applicationId, TimeoutBudget timeoutBudget) { createCalled = true; - this.applicationName = applicationName; + this.applicationName = applicationId.application().value(); if (doThrow) { throw new RuntimeException("foo"); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java index 7434bf411dd..531a2e3745b 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java @@ -4,6 +4,10 @@ package com.yahoo.vespa.config.server.session; import com.google.common.io.Files; import com.yahoo.config.application.api.ApplicationFile; import com.yahoo.config.model.application.provider.BaseDeployLogger; +import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.ApplicationName; +import com.yahoo.config.provision.InstanceName; +import com.yahoo.config.provision.TenantName; import com.yahoo.io.IOUtils; import com.yahoo.path.Path; import com.yahoo.vespa.config.server.*; @@ -34,7 +38,7 @@ public class SessionFactoryTest extends TestWithTenant { private SessionFactory factory; @Before - public void setup_test() throws Exception { + public void setup_test() { factory = tenant.getSessionFactory(); } @@ -67,8 +71,8 @@ public class SessionFactoryTest extends TestWithTenant { } @Test(expected = RuntimeException.class) - public void require_that_invalid_app_dir_is_handled() throws IOException { - factory.createSession(new File("doesnotpointtoavaliddir"), "music", TimeoutBudgetTest.day()); + public void require_that_invalid_app_dir_is_handled() { + createSession(new File("doesnotpointtoavaliddir"), "music"); } private LocalSession getLocalSession() throws IOException { @@ -78,6 +82,11 @@ public class SessionFactoryTest extends TestWithTenant { private LocalSession getLocalSession(String appName) throws IOException { CompressedApplicationInputStream app = CompressedApplicationInputStream.createFromCompressedStream( new FileInputStream(CompressedApplicationInputStreamTest.createTarFile()), ApplicationApiHandler.APPLICATION_X_GZIP); - return factory.createSession(app.decompress(Files.createTempDir()), appName, TimeoutBudgetTest.day()); + return createSession(app.decompress(Files.createTempDir()), appName); + } + + private LocalSession createSession(File applicationDirectory, String appName) { + ApplicationId applicationId = ApplicationId.from(TenantName.defaultName(), ApplicationName.from(appName), InstanceName.defaultName()); + return factory.createSession(applicationDirectory, applicationId, TimeoutBudgetTest.day()); } } |