diff options
Diffstat (limited to 'configserver')
17 files changed, 105 insertions, 61 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 2347faf233b..ab825f14b68 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -146,15 +146,16 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } public PrepareResult deploy(CompressedApplicationInputStream in, PrepareParams prepareParams) { - Tenant tenant = tenantRepository.getTenant(prepareParams.getApplicationId().tenant()); - return deploy(tenant, in, prepareParams, false, false, clock.instant()); + return deploy(in, prepareParams, false, false, clock.instant()); } - public PrepareResult deploy(Tenant tenant, CompressedApplicationInputStream in, PrepareParams prepareParams, + public PrepareResult deploy(CompressedApplicationInputStream in, PrepareParams prepareParams, boolean ignoreLockFailure, boolean ignoreSessionStaleFailure, Instant now) { File tempDir = Files.createTempDir(); - long sessionId = createSession(tenant, prepareParams.getTimeoutBudget(), decompressApplication(in, tempDir), prepareParams.getApplicationName()); + ApplicationId applicationId = prepareParams.getApplicationId(); + long sessionId = createSession(applicationId, prepareParams.getTimeoutBudget(), decompressApplication(in, tempDir)); cleanupApplicationDirectory(tempDir, logger); + Tenant tenant = tenantRepository.getTenant(applicationId.tenant()); return prepareAndActivate(tenant, sessionId, prepareParams, ignoreLockFailure, ignoreSessionStaleFailure, now); } @@ -327,8 +328,8 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye throw new IllegalStateException("Session not prepared: " + sessionId); } - public long createSessionFromExisting(Tenant tenant, DeployLogger logger, - TimeoutBudget timeoutBudget, ApplicationId applicationId) { + public long createSessionFromExisting(ApplicationId applicationId, DeployLogger logger, TimeoutBudget timeoutBudget) { + Tenant tenant = tenantRepository.getTenant(applicationId.tenant()); LocalSessionRepo localSessionRepo = tenant.getLocalSessionRepo(); SessionFactory sessionFactory = tenant.getSessionFactory(); LocalSession fromSession = getExistingSession(tenant, applicationId); @@ -337,17 +338,18 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye return session.getSessionId(); } - public long createSession(Tenant tenant, TimeoutBudget timeoutBudget, InputStream in, String contentType, String applicationName) { + public long createSession(ApplicationId applicationId, TimeoutBudget timeoutBudget, InputStream in, String contentType) { File tempDir = Files.createTempDir(); - long sessionId = createSession(tenant, timeoutBudget, decompressApplication(in, contentType, tempDir), applicationName); + long sessionId = createSession(applicationId, timeoutBudget, decompressApplication(in, contentType, tempDir)); cleanupApplicationDirectory(tempDir, logger); return sessionId; } - public long createSession(Tenant tenant, TimeoutBudget timeoutBudget, File applicationDirectory, String applicationName) { + public long createSession(ApplicationId applicationId, TimeoutBudget timeoutBudget, File applicationDirectory) { + Tenant tenant = tenantRepository.getTenant(applicationId.tenant()); LocalSessionRepo localSessionRepo = tenant.getLocalSessionRepo(); SessionFactory sessionFactory = tenant.getSessionFactory(); - LocalSession session = sessionFactory.createSession(applicationDirectory, applicationName, timeoutBudget); + LocalSession session = sessionFactory.createSession(applicationDirectory, applicationId, timeoutBudget); localSessionRepo.addSession(session); return session.getSessionId(); } @@ -482,7 +484,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } } - private Slime createDeployLog() { + public Slime createDeployLog() { Slime deployLog = new Slime(); deployLog.setObject(); return deployLog; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/SessionHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/SessionHandler.java index f6547288702..f03173736c0 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/SessionHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/SessionHandler.java @@ -76,13 +76,6 @@ public class SessionHandler extends HttpHandler { return new DeployHandlerLogger(deployLog.get().setArray("log"), verbose, app); } - // TODO: Refactor to use the one in ApplicationRepository and remove - protected Slime createDeployLog() { - Slime deployLog = new Slime(); - deployLog.setObject(); - return deployLog; - } - protected static boolean shouldIgnoreLockFailure(HttpRequest request) { return request.getBooleanProperty("force"); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java index 9c19b4dce87..411e24cdbc6 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java @@ -68,8 +68,7 @@ public class ApplicationApiHandler extends SessionHandler { SessionCreateHandler.validateDataAndHeader(request); PrepareResult result = - applicationRepository.deploy(tenant, - CompressedApplicationInputStream.createFromCompressedStream(request.getData(), request.getHeader(contentTypeHeader)), + applicationRepository.deploy(CompressedApplicationInputStream.createFromCompressedStream(request.getData(), request.getHeader(contentTypeHeader)), prepareParams, shouldIgnoreLockFailure(request), shouldIgnoreSessionStaleFailure(request), diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java index 07858d3864c..74c85829ef2 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java @@ -5,6 +5,8 @@ import com.google.inject.Inject; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.application.api.DeployLogger; 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.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; @@ -13,7 +15,6 @@ import com.yahoo.log.LogLevel; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.deploy.DeployHandlerLogger; -import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.TimeoutBudget; import com.yahoo.vespa.config.server.http.BadRequestException; @@ -49,20 +50,21 @@ public class SessionCreateHandler extends SessionHandler { @Override protected HttpResponse handlePOST(HttpRequest request) { - Slime deployLog = createDeployLog(); + Slime deployLog = applicationRepository.createDeployLog(); final TenantName tenantName = Utils.getTenantNameFromSessionRequest(request); Utils.checkThatTenantExists(tenantRepository, tenantName); - Tenant tenant = tenantRepository.getTenant(tenantName); TimeoutBudget timeoutBudget = SessionHandler.getTimeoutBudget(request, zookeeperBarrierTimeout); DeployLogger logger = createLogger(request, deployLog, tenantName); long sessionId; if (request.hasProperty("from")) { ApplicationId applicationId = getFromApplicationId(request); - sessionId = applicationRepository.createSessionFromExisting(tenant, logger, timeoutBudget, applicationId); + sessionId = applicationRepository.createSessionFromExisting(applicationId, logger, timeoutBudget); } else { validateDataAndHeader(request); String name = getNameProperty(request, logger); - sessionId = applicationRepository.createSession(tenant, timeoutBudget, request.getData(), request.getHeader(ApplicationApiHandler.contentTypeHeader), name); + // TODO: we are always using instance name 'default' here, fix + ApplicationId applicationId = ApplicationId.from(tenantName, ApplicationName.from(name), InstanceName.defaultName()); + sessionId = applicationRepository.createSession(applicationId, timeoutBudget, request.getData(), request.getHeader(ApplicationApiHandler.contentTypeHeader)); } return createResponse(request, tenantName, deployLog, sessionId); } @@ -86,12 +88,12 @@ public class SessionCreateHandler extends SessionHandler { .instanceName(match.group(6)).build(); } - static DeployHandlerLogger createLogger(HttpRequest request, Slime deployLog, TenantName tenant) { + private static DeployHandlerLogger createLogger(HttpRequest request, Slime deployLog, TenantName tenant) { return SessionHandler.createLogger(deployLog, request, new ApplicationId.Builder().tenant(tenant).applicationName("-").build()); } - static String getNameProperty(HttpRequest request, DeployLogger logger) { + private static String getNameProperty(HttpRequest request, DeployLogger logger) { String name = request.getProperty("name"); // TODO: Do we need validation of this parameter? if (name == null) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java index 8a3ad96c078..2251c94a8e0 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java @@ -52,7 +52,7 @@ public class SessionPrepareHandler extends SessionHandler { long sessionId = getSessionIdV2(request); applicationRepository.validateThatRemoteSessionIsNotActive(tenant, sessionId); applicationRepository.validateThatRemoteSessionIsPrepared(tenant, sessionId); - return new SessionPrepareResponse(createDeployLog(), tenant.getName(), request, sessionId); + return new SessionPrepareResponse(applicationRepository.createDeployLog(), tenant.getName(), request, sessionId); } @Override diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/FileDistributionFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/FileDistributionFactory.java index 12cc76afc6b..32602ab70b8 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/FileDistributionFactory.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/FileDistributionFactory.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.ApplicationId; import com.yahoo.jrt.Supervisor; import com.yahoo.jrt.Transport; import com.yahoo.vespa.config.server.filedistribution.FileDistributionProvider; @@ -23,6 +22,7 @@ public class FileDistributionFactory { } @Override + @SuppressWarnings("deprecation") // finalize() is deprecated from Java 9 protected void finalize() throws Throwable { super.finalize(); supervisor.transport().shutdown().join(); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java index 172620a643a..bd9da36a2ba 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.config.server.session; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.config.server.TimeoutBudget; import java.io.File; @@ -19,11 +20,11 @@ public interface SessionFactory { * * * @param applicationDirectory a File pointing to an application. - * @param applicationName name of the application for this new session. + * @param applicationId application id for this new session. * @param timeoutBudget Timeout for creating session and waiting for other servers. * @return a new session */ - LocalSession createSession(File applicationDirectory, String applicationName, TimeoutBudget timeoutBudget); + LocalSession createSession(File applicationDirectory, ApplicationId applicationId, TimeoutBudget timeoutBudget); /** * Creates a new deployment session from an already existing session. diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java index f260fade41c..7285ff905ff 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.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.application.api.ApplicationMetaData; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.model.application.provider.*; @@ -64,7 +63,7 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { this.sessionPreparer = globalComponentRegistry.getSessionPreparer(); this.curator = globalComponentRegistry.getCurator(); this.configCurator = globalComponentRegistry.getConfigCurator(); - this.sessionCounter = new SessionCounter(globalComponentRegistry.getConfigCurator(), tenant);; + this.sessionCounter = new SessionCounter(globalComponentRegistry.getConfigCurator(), tenant); this.sessionsPath = TenantRepository.getSessionsPath(tenant); this.applicationRepo = applicationRepo; this.tenantFileSystemDirs = tenantFileSystemDirs; @@ -76,8 +75,8 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { } @Override - public LocalSession createSession(File applicationFile, String applicationName, TimeoutBudget timeoutBudget) { - return create(applicationFile, applicationName, nonExistingActiveSession, timeoutBudget); + public LocalSession createSession(File applicationFile, ApplicationId applicationId, TimeoutBudget timeoutBudget) { + return create(applicationFile, applicationId, nonExistingActiveSession, timeoutBudget); } private void ensureZKPathDoesNotExist(Path sessionPath) { @@ -122,18 +121,17 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { DeployLogger logger, TimeoutBudget timeoutBudget) { File existingApp = getSessionAppDir(existingSession.getSessionId()); - ApplicationMetaData metaData = FilesApplicationPackage.readMetaData(existingApp); ApplicationId existingApplicationId = existingSession.getApplicationId(); long liveApp = getLiveApp(existingApplicationId); logger.log(LogLevel.DEBUG, "Create from existing application id " + existingApplicationId + ", live app for it is " + liveApp); - LocalSession session = create(existingApp, metaData.getApplicationName(), liveApp, timeoutBudget); + LocalSession session = create(existingApp, existingApplicationId, liveApp, timeoutBudget); session.setApplicationId(existingApplicationId); session.setVespaVersion(existingSession.getVespaVersion()); return session; } - private LocalSession create(File applicationFile, String applicationName, long currentlyActiveSession, TimeoutBudget timeoutBudget) { + private LocalSession create(File applicationFile, ApplicationId applicationId, long currentlyActiveSession, TimeoutBudget timeoutBudget) { long sessionId = sessionCounter.nextSessionId(); Path sessionIdPath = sessionsPath.append(String.valueOf(sessionId)); log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant) + "Next session id is " + sessionId + " , sessionIdPath=" + sessionIdPath.getAbsolute()); @@ -147,7 +145,8 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { nodeFlavors); File userApplicationDir = tenantFileSystemDirs.getUserApplicationDir(sessionId); IOUtils.copyDirectory(applicationFile, userApplicationDir); - ApplicationPackage applicationPackage = createApplication(applicationFile, userApplicationDir, applicationName, sessionId, currentlyActiveSession); + ApplicationPackage applicationPackage = createApplication(applicationFile, userApplicationDir, + applicationId.application().value(), sessionId, currentlyActiveSession); applicationPackage.writeMetaData(); return createSessionFromApplication(applicationPackage, sessionId, sessionZooKeeperClient, timeoutBudget, clock); } catch (Exception e) { diff --git a/configserver/src/main/sh/start-configserver b/configserver/src/main/sh/start-configserver index daad42f7895..8c0ea810a9a 100755 --- a/configserver/src/main/sh/start-configserver +++ b/configserver/src/main/sh/start-configserver @@ -54,7 +54,16 @@ findroot () { exit 1 } +findhost () { + if [ "${VESPA_HOSTNAME}" = "" ]; then + VESPA_HOSTNAME=$(vespa-detect-hostname) || exit 1 + fi + vespa-validate-hostname "${VESPA_HOSTNAME}" || exit 1 + export VESPA_HOSTNAME +} + findroot +findhost # END environment bootstrap section @@ -82,6 +91,7 @@ fixddir () { fixddir ${VESPA_HOME}/conf/zookeeper fixfile ${VESPA_HOME}/conf/zookeeper/zookeeper.cfg +fixddir ${VESPA_HOME}/var/zookeeper fixfile ${VESPA_HOME}/var/zookeeper/myid fixddir ${VESPA_HOME}/var/zookeeper/version-2 diff --git a/configserver/src/main/sh/start-logd b/configserver/src/main/sh/start-logd index 848d8dee6aa..ce0b60a8d8d 100644 --- a/configserver/src/main/sh/start-logd +++ b/configserver/src/main/sh/start-logd @@ -54,7 +54,16 @@ findroot () { exit 1 } +findhost () { + if [ "${VESPA_HOSTNAME}" = "" ]; then + VESPA_HOSTNAME=$(vespa-detect-hostname) || exit 1 + fi + vespa-validate-hostname "${VESPA_HOSTNAME}" || exit 1 + export VESPA_HOSTNAME +} + findroot +findhost # END environment bootstrap section diff --git a/configserver/src/main/sh/stop-configserver b/configserver/src/main/sh/stop-configserver index 15ac6023a91..957fdb249c3 100755 --- a/configserver/src/main/sh/stop-configserver +++ b/configserver/src/main/sh/stop-configserver @@ -54,7 +54,16 @@ findroot () { exit 1 } +findhost () { + if [ "${VESPA_HOSTNAME}" = "" ]; then + VESPA_HOSTNAME=$(vespa-detect-hostname) || exit 1 + fi + vespa-validate-hostname "${VESPA_HOSTNAME}" || exit 1 + export VESPA_HOSTNAME +} + findroot +findhost # END environment bootstrap section diff --git a/configserver/src/main/sh/vespa-configserver-remove-state b/configserver/src/main/sh/vespa-configserver-remove-state index c781fcb0c0d..e3d348ecefa 100755 --- a/configserver/src/main/sh/vespa-configserver-remove-state +++ b/configserver/src/main/sh/vespa-configserver-remove-state @@ -54,7 +54,16 @@ findroot () { exit 1 } +findhost () { + if [ "${VESPA_HOSTNAME}" = "" ]; then + VESPA_HOSTNAME=$(vespa-detect-hostname) || exit 1 + fi + vespa-validate-hostname "${VESPA_HOSTNAME}" || exit 1 + export VESPA_HOSTNAME +} + findroot +findhost # END environment bootstrap section 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/filedistribution/FileServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java index b0dce359d58..157c36d7aef 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/filedistribution/FileServerTest.java @@ -5,6 +5,7 @@ import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.io.IOUtils; import com.yahoo.net.HostName; import com.yahoo.vespa.filedistribution.FileReferenceData; +import org.junit.After; import org.junit.Test; import java.io.File; @@ -21,8 +22,8 @@ import static org.junit.Assert.assertFalse; public class FileServerTest { - FileServer fs = new FileServer(new File(".")); - List<File> created = new LinkedList<>(); + private FileServer fs = new FileServer(new File(".")); + private List<File> created = new LinkedList<>(); private void createCleanDir(String name) throws IOException{ File dir = new File(name); @@ -70,7 +71,7 @@ public class FileServerTest { } @Test - public void requireThatDifferentNumberOfConfigServersWork() throws IOException { + public void requireThatDifferentNumberOfConfigServersWork() { // Empty connection pool in tests etc. ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder(); FileServer fileServer = new FileServer(new ConfigserverConfig(builder)); @@ -107,15 +108,10 @@ public class FileServerTest { } } - private void cleanup() { - created.forEach((file) -> IOUtils.recursiveDeleteDir(file)); + @After + public void cleanup() { + created.forEach(IOUtils::recursiveDeleteDir); created.clear(); } - @Override - protected void finalize() throws Throwable { - super.finalize(); - cleanup(); - } - } 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()); } } |