aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-06-04 13:38:35 +0200
committerHarald Musum <musum@oath.com>2018-06-04 13:38:35 +0200
commit24dc8672eb5ab45393b9b0074d1369a0717f968d (patch)
treef7f62d814e6ea6ff87ed05f7dfa12d7b78d55054 /configserver
parent1abbafeaab7a203125fcfec4f5c2e655c54a61ef (diff)
parentd4297ad79053fd359abf6cdf43bb5428461682e5 (diff)
Merge branch 'master' into hmusum/remove-debug-from-response
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java28
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java13
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java8
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java13
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java11
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java10
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java6
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java26
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantHandlerProvider.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java18
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java15
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java7
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java8
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java9
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java12
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java4
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionHandlerTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java8
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java28
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java33
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionFactoryTest.java12
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/MockTenantProvider.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java9
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java91
38 files changed, 284 insertions, 153 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 5b0c7314b80..1d162a7b794 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
@@ -51,7 +51,9 @@ import com.yahoo.vespa.config.server.tenant.TenantRepository;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UncheckedIOException;
import java.net.URI;
+import java.nio.file.attribute.BasicFileAttributes;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
@@ -71,6 +73,8 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
+import static java.nio.file.Files.readAttributes;
+
/**
* The API for managing applications.
*
@@ -180,6 +184,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
/**
* Creates a new deployment from the active application, if available.
+ * This is used for system internal redeployments, not on application package changes.
*
* @param application the active application to be redeployed
* @return a new deployment from the local active, or empty if a local active application
@@ -192,6 +197,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
/**
* Creates a new deployment from the active application, if available.
+ * This is used for system internal redeployments, not on application package changes.
*
* @param application the active application to be redeployed
* @param timeout the timeout to use for each individual deployment operation
@@ -206,7 +212,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
LocalSession activeSession = getActiveSession(tenant, application);
if (activeSession == null) return Optional.empty();
TimeoutBudget timeoutBudget = new TimeoutBudget(clock, timeout);
- LocalSession newSession = tenant.getSessionFactory().createSessionFromExisting(activeSession, logger, timeoutBudget);
+ LocalSession newSession = tenant.getSessionFactory().createSessionFromExisting(activeSession, logger, true, timeoutBudget);
tenant.getLocalSessionRepo().addSession(newSession);
// Keep manually deployed tenant applications on the latest version, don't change version otherwise
@@ -313,10 +319,11 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
fileReferencesOnDisk.addAll(Arrays.stream(filesOnDisk).map(File::getName).collect(Collectors.toSet()));
log.log(LogLevel.INFO, "File references on disk (in " + fileReferencesPath + "): " + fileReferencesOnDisk);
- // TODO: Only consider the ones modified more than some time (14 days?) ago
+ Instant instant = Instant.now().minus(Duration.ofDays(14));
Set<String> fileReferencesToDelete = fileReferencesOnDisk
.stream()
.filter(fileReference -> ! fileReferencesInUse.contains(fileReference))
+ .filter(fileReference -> isFileLastModifiedBefore(new File(fileReferencesPath, fileReference), instant))
.collect(Collectors.toSet());
if (deleteFromDisk) {
log.log(LogLevel.INFO, "Will delete file references not in use: " + fileReferencesToDelete);
@@ -347,6 +354,16 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
.collect(Collectors.toSet());
}
+ private boolean isFileLastModifiedBefore(File fileReference, Instant instant) {
+ BasicFileAttributes fileAttributes;
+ try {
+ fileAttributes = readAttributes(fileReference.toPath(), BasicFileAttributes.class);
+ return fileAttributes.lastModifiedTime().toInstant().isBefore(instant);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
// ---------------- Convergence ----------------------------------------------------------------
public HttpResponse checkServiceForConfigConvergence(ApplicationId applicationId, String hostAndPort, URI uri) {
@@ -385,12 +402,15 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
throw new IllegalStateException("Session not prepared: " + sessionId);
}
- public long createSessionFromExisting(ApplicationId applicationId, DeployLogger logger, TimeoutBudget timeoutBudget) {
+ public long createSessionFromExisting(ApplicationId applicationId,
+ DeployLogger logger,
+ boolean internalRedeploy,
+ TimeoutBudget timeoutBudget) {
Tenant tenant = tenantRepository.getTenant(applicationId.tenant());
LocalSessionRepo localSessionRepo = tenant.getLocalSessionRepo();
SessionFactory sessionFactory = tenant.getSessionFactory();
LocalSession fromSession = getExistingSession(tenant, applicationId);
- LocalSession session = sessionFactory.createSessionFromExisting(fromSession, logger, timeoutBudget);
+ LocalSession session = sessionFactory.createSessionFromExisting(fromSession, logger, internalRedeploy, timeoutBudget);
localSessionRepo.addSession(session);
return session.getSessionId();
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java b/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java
index ea14b9194e8..6c9b7216e59 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java
@@ -9,8 +9,7 @@ import com.yahoo.vespa.config.server.tenant.TenantRepository;
/**
* Contains the context for serving getconfig requests so that this information does not have to be looked up multiple times.
*
- * @author lulf
- * @since 5.8
+ * @author Ulf Lilleengen
*/
public class GetConfigContext {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java
index 8e865f96db3..f723ca2fe91 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/SuperModelController.java
@@ -51,7 +51,7 @@ public class SuperModelController {
ConfigKey<?> configKey = request.getConfigKey();
InnerCNode targetDef = getConfigDefinition(request.getConfigKey(), request.getDefContent());
ConfigPayload payload = model.getConfig(configKey);
- return responseFactory.createResponse(payload, targetDef, generation);
+ return responseFactory.createResponse(payload, targetDef, generation, false);
}
private InnerCNode getConfigDefinition(ConfigKey<?> configKey, DefContent defContent) {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java
index a73fc95eb05..64123420622 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java
@@ -32,23 +32,26 @@ import java.util.Set;
* a Vespa application, i.e. generation, model and zookeeper data, as well as methods for resolving config
* and other queries against the model.
*
- * @author Harald Musum
+ * @author hmusum
*/
public class Application implements ModelResult {
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(Application.class.getName());
private final long appGeneration; // The generation of the set of configs belonging to an application
+ private final boolean internalRedeploy;
private final Version vespaVersion;
private final Model model;
private final ServerCache cache;
private final MetricUpdater metricUpdater;
private final ApplicationId app;
- public Application(Model model, ServerCache cache, long appGeneration, Version vespaVersion, MetricUpdater metricUpdater, ApplicationId app) {
+ public Application(Model model, ServerCache cache, long appGeneration, boolean internalRedeploy,
+ Version vespaVersion, MetricUpdater metricUpdater, ApplicationId app) {
Objects.requireNonNull(model, "The model cannot be null");
this.model = model;
this.cache = cache;
this.appGeneration = appGeneration;
+ this.internalRedeploy = internalRedeploy;
this.vespaVersion = vespaVersion;
this.metricUpdater = metricUpdater;
this.app = app;
@@ -106,7 +109,7 @@ public class Application implements ModelResult {
debug("Resolving config " + cacheKey);
}
- if (!req.noCache()) {
+ if ( ! req.noCache()) {
ConfigResponse config = cache.get(cacheKey);
if (config != null) {
if (logDebug()) {
@@ -131,9 +134,9 @@ public class Application implements ModelResult {
throw new ConfigurationRuntimeException("Unable to resolve config " + configKey);
}
- ConfigResponse configResponse = responseFactory.createResponse(payload, def.getCNode(), appGeneration);
+ ConfigResponse configResponse = responseFactory.createResponse(payload, def.getCNode(), appGeneration, internalRedeploy);
metricUpdater.incrementProcTime(System.currentTimeMillis() - start);
- if (!req.noCache()) {
+ if ( ! req.noCache()) {
cache.put(cacheKey, configResponse, configResponse.getConfigMd5());
metricUpdater.setCacheConfigElems(cache.configElems());
metricUpdater.setCacheChecksumElems(cache.checkSumElems());
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java
index 22ce952481d..68c129d1e42 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ZooKeeperDeployer.java
@@ -13,7 +13,7 @@ import java.util.Map;
* Interface for initializing zookeeper and deploying an application package to zookeeper.
* Initialize must be called before each deploy.
*
- * @author lulf
+ * @author Ulf Lilleengen
*/
public class ZooKeeperDeployer {
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 74c85829ef2..26ef79ebe02 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
@@ -58,7 +58,7 @@ public class SessionCreateHandler extends SessionHandler {
long sessionId;
if (request.hasProperty("from")) {
ApplicationId applicationId = getFromApplicationId(request);
- sessionId = applicationRepository.createSessionFromExisting(applicationId, logger, timeoutBudget);
+ sessionId = applicationRepository.createSessionFromExisting(applicationId, logger, false, timeoutBudget);
} else {
validateDataAndHeader(request);
String name = getNameProperty(request, logger);
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
index 9d583d27341..d83548dcc3d 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
@@ -88,7 +88,9 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> {
new com.yahoo.component.Version(modelFactory.getVersion().toString()),
wantedNodeVespaVersion);
MetricUpdater applicationMetricUpdater = metrics.getOrCreateMetricUpdater(Metrics.createDimensions(applicationId));
- return new Application(modelFactory.createModel(modelContext), cache, appGeneration, modelFactory.getVersion(),
+ return new Application(modelFactory.createModel(modelContext), cache, appGeneration,
+ applicationPackage.getMetaData().isInternalRedeploy(),
+ modelFactory.getVersion(),
applicationMetricUpdater, applicationId);
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java
index 07e07fa2595..247ae388639 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactory.java
@@ -9,17 +9,19 @@ import com.yahoo.vespa.config.protocol.ConfigResponse;
* Represents a component that creates config responses from a payload. Different implementations
* can do transformations of the payload such as compression.
*
- * @author lulf
- * @since 5.19
+ * @author Ulf Lilleengen
*/
public interface ConfigResponseFactory {
/**
* Create a {@link ConfigResponse} for a given payload and generation.
+ *
* @param payload The {@link com.yahoo.vespa.config.ConfigPayload} to put in the response.
* @param defFile The {@link com.yahoo.config.codegen.InnerCNode} def file for this config.
* @param generation The payload generation. @return A {@link ConfigResponse} that can be sent to the client.
+ * @param internalRedeployment whether this config generation was produced by an internal redeployment,
+ * not a change to the application package
*/
- ConfigResponse createResponse(ConfigPayload payload, InnerCNode defFile, long generation);
+ ConfigResponse createResponse(ConfigPayload payload, InnerCNode defFile, long generation, boolean internalRedeployment);
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java
index b37d013cc6b..970fe9f169b 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java
@@ -22,7 +22,6 @@ import java.util.logging.Logger;
/**
* @author hmusum
-* @since 5.1
*/
class GetConfigProcessor implements Runnable {
@@ -30,8 +29,9 @@ class GetConfigProcessor implements Runnable {
private static final String localHostName = HostName.getLocalhost();
private final JRTServerConfigRequest request;
+
/* True only when this request has expired its server timeout and we need to respond to the client */
- private boolean forceResponse = false;
+ private final boolean forceResponse;
private final RpcServer rpcServer;
private String logPre = "";
@@ -64,7 +64,7 @@ class GetConfigProcessor implements Runnable {
// TODO: Increment statistics (Metrics) failed counters when requests fail
public void run() {
//Request has already been detached
- if (!request.validateParameters()) {
+ if ( ! request.validateParameters()) {
// Error code is set in verifyParameters if parameters are not OK.
log.log(LogLevel.WARNING, "Parameters for request " + request + " did not validate: " + request.errorCode() + " : " + request.errorMessage());
respond(request);
@@ -121,7 +121,7 @@ class GetConfigProcessor implements Runnable {
// config == null is not an error, but indicates that the config will be returned later.
if ((config != null) && (!config.hasEqualConfig(request) || config.hasNewerGeneration(request) || forceResponse)) {
// debugLog(trace, "config response before encoding:" + config.toString());
- request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), config.getConfigMd5());
+ request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), config.isInternalRedeploy(), config.getConfigMd5());
if (logDebug(trace)) {
debugLog(trace, "return response: " + request.getShortDescription());
}
@@ -146,8 +146,8 @@ class GetConfigProcessor implements Runnable {
private void returnEmpty(JRTServerConfigRequest request) {
ConfigPayload emptyPayload = ConfigPayload.empty();
String configMd5 = ConfigUtils.getMd5(emptyPayload);
- ConfigResponse config = SlimeConfigResponse.fromConfigPayload(emptyPayload, null, 0, configMd5);
- request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), config.getConfigMd5());
+ ConfigResponse config = SlimeConfigResponse.fromConfigPayload(emptyPayload, null, 0, false, configMd5);
+ request.addOkResponse(request.payloadFromResponse(config), config.getGeneration(), false, config.getConfigMd5());
respond(request);
}
@@ -161,4 +161,5 @@ class GetConfigProcessor implements Runnable {
trace.trace(RpcServer.TRACELEVEL_DEBUG, logPre + message);
}
}
+
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java
index 609f1d5f79f..ff15eb7bfa7 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/LZ4ConfigResponseFactory.java
@@ -14,19 +14,22 @@ import com.yahoo.vespa.config.util.ConfigUtils;
/**
* Compressor that compresses config payloads to lz4.
*
- * @author lulf
- * @since 5.19
+ * @author Ulf Lilleengen
*/
public class LZ4ConfigResponseFactory implements ConfigResponseFactory {
private static LZ4PayloadCompressor compressor = new LZ4PayloadCompressor();
@Override
- public ConfigResponse createResponse(ConfigPayload payload, InnerCNode defFile, long generation) {
+ public ConfigResponse createResponse(ConfigPayload payload,
+ InnerCNode defFile,
+ long generation,
+ boolean internalRedeployment) {
Utf8Array rawPayload = payload.toUtf8Array(true);
String configMd5 = ConfigUtils.getMd5(rawPayload);
CompressionInfo info = CompressionInfo.create(CompressionType.LZ4, rawPayload.getByteLength());
Utf8Array compressed = new Utf8Array(compressor.compress(rawPayload.getBytes()));
- return new SlimeConfigResponse(compressed, defFile, generation, configMd5, info);
+ return new SlimeConfigResponse(compressed, defFile, generation, internalRedeployment, configMd5, info);
}
+
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java
index ac3cfa2fda1..995e981e0f3 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/UncompressedConfigResponseFactory.java
@@ -13,17 +13,19 @@ import com.yahoo.vespa.config.util.ConfigUtils;
/**
* Simply returns an uncompressed payload.
*
- * @author lulf
- * @since 5.19
+ * @author Ulf Lilleengen
*/
public class UncompressedConfigResponseFactory implements ConfigResponseFactory {
@Override
- public ConfigResponse createResponse(ConfigPayload payload, InnerCNode defFile, long generation) {
+ public ConfigResponse createResponse(ConfigPayload payload,
+ InnerCNode defFile,
+ long generation,
+ boolean internalRedeployment) {
Utf8Array rawPayload = payload.toUtf8Array(true);
String configMd5 = ConfigUtils.getMd5(rawPayload);
CompressionInfo info = CompressionInfo.create(CompressionType.UNCOMPRESSED, rawPayload.getByteLength());
- return new SlimeConfigResponse(rawPayload, defFile, generation, configMd5, info);
+ return new SlimeConfigResponse(rawPayload, defFile, generation, internalRedeployment, configMd5, info);
}
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java
index 653df81f296..3978a1f25f8 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java
@@ -9,8 +9,7 @@ import com.yahoo.vespa.config.server.tenant.TenantRepository;
* class represents the common stuff between sessions working on the local file
* system ({@link LocalSession}s) and sessions working on zookeeper {@link RemoteSession}s.
*
- * @author lulf
- * @since 5.1
+ * @author Ulf Lilleengen
*/
public abstract class Session {
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 bd9da36a2ba..a3dea83d50c 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
@@ -10,7 +10,7 @@ import java.io.File;
/**
* A session factory responsible for creating deploy sessions.
*
- * @author lulf
+ * @author Ulf Lilleengen
*/
public interface SessionFactory {
@@ -31,9 +31,11 @@ public interface SessionFactory {
*
* @param existingSession The session to use as base
* @param logger a deploy logger where the deploy log will be written.
+ * @param internalRedeploy if this session is for a system internal redeploy not an application package change
* @param timeoutBudget Timeout for creating session and waiting for other servers.
* @return a new session
*/
- LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger, TimeoutBudget timeoutBudget);
+ LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger,
+ boolean internalRedeploy, TimeoutBudget timeoutBudget);
}
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 7285ff905ff..10590a26690 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
@@ -74,9 +74,12 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader {
this.clock = globalComponentRegistry.getClock();
}
+ /** Create a session for a true application package change */
@Override
- public LocalSession createSession(File applicationFile, ApplicationId applicationId, TimeoutBudget timeoutBudget) {
- return create(applicationFile, applicationId, nonExistingActiveSession, timeoutBudget);
+ public LocalSession createSession(File applicationFile,
+ ApplicationId applicationId,
+ TimeoutBudget timeoutBudget) {
+ return create(applicationFile, applicationId, nonExistingActiveSession, false, timeoutBudget);
}
private void ensureZKPathDoesNotExist(Path sessionPath) {
@@ -89,13 +92,14 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader {
File configApplicationDir,
String applicationName,
long sessionId,
- long currentlyActiveSession) {
+ long currentlyActiveSession,
+ boolean internalRedeploy) {
long deployTimestamp = System.currentTimeMillis();
String user = System.getenv("USER");
if (user == null) {
user = "unknown";
}
- DeployData deployData = new DeployData(user, userDir.getAbsolutePath(), applicationName, deployTimestamp, sessionId, currentlyActiveSession);
+ DeployData deployData = new DeployData(user, userDir.getAbsolutePath(), applicationName, deployTimestamp, internalRedeploy, sessionId, currentlyActiveSession);
return FilesApplicationPackage.fromFileWithDeployData(configApplicationDir, deployData);
}
@@ -119,19 +123,21 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader {
@Override
public LocalSession createSessionFromExisting(LocalSession existingSession,
DeployLogger logger,
+ boolean internalRedeploy,
TimeoutBudget timeoutBudget) {
File existingApp = getSessionAppDir(existingSession.getSessionId());
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, existingApplicationId, liveApp, timeoutBudget);
+ LocalSession session = create(existingApp, existingApplicationId, liveApp, internalRedeploy, timeoutBudget);
session.setApplicationId(existingApplicationId);
session.setVespaVersion(existingSession.getVespaVersion());
return session;
}
- private LocalSession create(File applicationFile, ApplicationId applicationId, long currentlyActiveSession, TimeoutBudget timeoutBudget) {
+ private LocalSession create(File applicationFile, ApplicationId applicationId, long currentlyActiveSession,
+ boolean internalRedeploy, 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());
@@ -145,8 +151,12 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader {
nodeFlavors);
File userApplicationDir = tenantFileSystemDirs.getUserApplicationDir(sessionId);
IOUtils.copyDirectory(applicationFile, userApplicationDir);
- ApplicationPackage applicationPackage = createApplication(applicationFile, userApplicationDir,
- applicationId.application().value(), sessionId, currentlyActiveSession);
+ ApplicationPackage applicationPackage = createApplication(applicationFile,
+ userApplicationDir,
+ applicationId.application().value(),
+ sessionId,
+ currentlyActiveSession,
+ internalRedeploy);
applicationPackage.writeMetaData();
return createSessionFromApplication(applicationPackage, sessionId, sessionZooKeeperClient, timeoutBudget, clock);
} catch (Exception e) {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantHandlerProvider.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantHandlerProvider.java
index 8c774fd35ce..b19f8bf8d0b 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantHandlerProvider.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantHandlerProvider.java
@@ -7,8 +7,7 @@ import com.yahoo.vespa.config.server.RequestHandler;
/**
* Represents something that can provide request and reload handlers of a tenant.
*
- * @author lulf
- * @since 5.3
+ * @author Ulf Lilleengen
*/
public interface TenantHandlerProvider {
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 ecbeb5d7d20..f7e76c2b3bb 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
@@ -120,10 +120,10 @@ public class ApplicationRepositoryTest {
public void deleteUnusedFileReferences() throws IOException {
File fileReferencesDir = temporaryFolder.newFolder();
- // Add file reference that is not in use and should be deleted
- File filereferenceDir = new File(fileReferencesDir, "foo");
- assertTrue(filereferenceDir.mkdir());
- IOUtils.writeFile(new File(filereferenceDir, "bar"), Utf8.toBytes("test"));
+ // Add file reference that is not in use and should be deleted (older than 14 days)
+ File filereferenceDir = createFilereferenceOnDisk(new File(fileReferencesDir, "foo"), Instant.now().minus(Duration.ofDays(15)));
+ // Add file reference that is not in use, but should not be deleted (not older than 14 days)
+ File filereferenceDir2 = createFilereferenceOnDisk(new File(fileReferencesDir, "baz"), Instant.now());
tenantRepository.addTenant(tenantName);
tenant = tenantRepository.getTenant(tenantName);
@@ -139,11 +139,21 @@ public class ApplicationRepositoryTest {
Set<String> toBeDeleted = applicationRepository.deleteUnusedFiledistributionReferences(fileReferencesDir, deleteFiles);
assertEquals(Collections.singleton("foo"), toBeDeleted);
assertTrue(filereferenceDir.exists());
+ assertTrue(filereferenceDir2.exists());
deleteFiles = true;
toBeDeleted = applicationRepository.deleteUnusedFiledistributionReferences(fileReferencesDir, deleteFiles);
assertEquals(Collections.singleton("foo"), toBeDeleted);
assertFalse(filereferenceDir.exists());
+ assertTrue(filereferenceDir2.exists());
+ }
+
+ private File createFilereferenceOnDisk(File filereferenceDir, Instant lastModifiedTime) {
+ assertTrue(filereferenceDir.mkdir());
+ File bar = new File(filereferenceDir, "file");
+ IOUtils.writeFile(bar, Utf8.toBytes("test"));
+ assertTrue(filereferenceDir.setLastModified(lastModifiedTime.toEpochMilli()));
+ return filereferenceDir;
}
private PrepareResult prepareAndActivateApp(File application) throws IOException {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java
index c1db543d386..b93b3fa28e0 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ServerCacheTest.java
@@ -50,9 +50,9 @@ public class ServerCacheTest {
cache.addDef(fooBimDefKey, new ConfigDefinition("mynode", new String[0]));
- cache.put(fooBarCacheKey, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload.getCNode(), 2, configMd5), configMd5);
- cache.put(bazQuuxCacheKey, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload.getCNode(), 2, configMd5), configMd5);
- cache.put(fooBarCacheKeyDifferentMd5, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload_2.getCNode(), 2, configMd5_2), configMd5_2);
+ cache.put(fooBarCacheKey, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload.getCNode(), 2, false, configMd5), configMd5);
+ cache.put(bazQuuxCacheKey, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload.getCNode(), 2, false, configMd5), configMd5);
+ cache.put(fooBarCacheKeyDifferentMd5, SlimeConfigResponse.fromConfigPayload(ConfigPayload.empty(), payload_2.getCNode(), 2, false, configMd5_2), configMd5_2);
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
index bc07ac7d79c..2b72db63d55 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelRequestHandlerTest.java
@@ -122,12 +122,11 @@ public class SuperModelRequestHandlerTest {
}
private static class TestApplication extends Application {
- private long version = 0;
public TestApplication(VespaModel vespaModel, ServerCache cache, long appGeneration, ApplicationId app, long version) {
- super(vespaModel, cache, appGeneration, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), app);
- this.version = version;
+ super(vespaModel, cache, appGeneration, false, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), app);
}
+
}
public static NodeFlavors emptyNodeFlavors() {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java
index a83f2676a4d..233c0e99ed8 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationMapperTest.java
@@ -31,9 +31,9 @@ public class ApplicationMapperTest {
vespaVersions.add(Version.fromString("1.2.3"));
vespaVersions.add(Version.fromString("1.2.4"));
vespaVersions.add(Version.fromString("1.2.5"));
- applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(0), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
- applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(1), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
- applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(2), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
+ applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(0), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
+ applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(1), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
+ applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(2), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java
index 98bedb76599..94bb81021dc 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationSetTest.java
@@ -29,9 +29,9 @@ public class ApplicationSetTest {
vespaVersions.add(Version.fromString("1.2.3"));
vespaVersions.add(Version.fromString("1.2.4"));
vespaVersions.add(Version.fromString("1.2.5"));
- applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(0), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
- applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(1), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
- applications.add(new Application(new ModelStub(), null, 0, vespaVersions.get(2), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
+ applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(0), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
+ applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(1), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
+ applications.add(new Application(new ModelStub(), null, 0, false, vespaVersions.get(2), MetricUpdater.createTestUpdater(), ApplicationId.defaultId()));
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java
index 02cf6303ba8..90a27c39736 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationTest.java
@@ -42,8 +42,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
- * @author lulf
- * @since 5.1.14
+ * @author Ulf Lilleengen
*/
public class ApplicationTest {
@@ -53,7 +52,7 @@ public class ApplicationTest {
ApplicationName.from("foobar"), InstanceName.defaultName());
ServerCache cache = new ServerCache();
Version vespaVersion = Version.fromIntValues(1, 2, 3);
- Application app = new Application(new ModelStub(), cache, 1337, vespaVersion, MetricUpdater.createTestUpdater(), appId);
+ Application app = new Application(new ModelStub(), cache, 1337L, false, vespaVersion, MetricUpdater.createTestUpdater(), appId);
assertThat(app.getApplicationGeneration(), is(1337l));
assertNotNull(app.getModel());
assertThat(app.getCache(), is(cache));
@@ -71,24 +70,24 @@ public class ApplicationTest {
File testApp = new File("src/test/apps/app");
ServerCache cache = createCacheAndAddContent();
VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(testApp));
- final ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("foo").build();
- handler = new Application(model, cache, 1, Version.fromIntValues(1, 2, 3),
+ ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("foo").build();
+ handler = new Application(model, cache, 1L, false, Version.fromIntValues(1, 2, 3),
new MetricUpdater(Metrics.createTestMetrics(), Metrics.createDimensions(applicationId)), applicationId);
}
private static ServerCache createCacheAndAddContent() {
ServerCache cache = new ServerCache();
- final ConfigDefinitionKey key = new ConfigDefinitionKey(SimpletypesConfig.CONFIG_DEF_NAME, SimpletypesConfig.CONFIG_DEF_NAMESPACE);
+ ConfigDefinitionKey key = new ConfigDefinitionKey(SimpletypesConfig.CONFIG_DEF_NAME, SimpletypesConfig.CONFIG_DEF_NAMESPACE);
com.yahoo.vespa.config.buildergen.ConfigDefinition def = getDef(key, SimpletypesConfig.CONFIG_DEF_SCHEMA);
// TODO Why do we have to use empty def md5 here?
cache.addDef(key, def);
- final ConfigDefinitionKey key2 = new ConfigDefinitionKey(SlobroksConfig.CONFIG_DEF_NAME, SlobroksConfig.CONFIG_DEF_NAMESPACE);
+ ConfigDefinitionKey key2 = new ConfigDefinitionKey(SlobroksConfig.CONFIG_DEF_NAME, SlobroksConfig.CONFIG_DEF_NAMESPACE);
com.yahoo.vespa.config.buildergen.ConfigDefinition def2 = getDef(key2, SlobroksConfig.CONFIG_DEF_SCHEMA);
cache.addDef(key2, def2);
- final ConfigDefinitionKey key3 = new ConfigDefinitionKey(LogdConfig.CONFIG_DEF_NAME, LogdConfig.CONFIG_DEF_NAMESPACE);
+ ConfigDefinitionKey key3 = new ConfigDefinitionKey(LogdConfig.CONFIG_DEF_NAME, LogdConfig.CONFIG_DEF_NAMESPACE);
com.yahoo.vespa.config.buildergen.ConfigDefinition def3 = getDef(key3, LogdConfig.CONFIG_DEF_SCHEMA);
cache.addDef(key3, def3);
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java
index 6c00b5a9083..98f88071bb4 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/ConfigConvergenceCheckerTest.java
@@ -43,7 +43,12 @@ public class ConfigConvergenceCheckerTest {
@Before
public void setup() {
Model mockModel = MockModel.createContainer("localhost", 1337);
- application = new Application(mockModel, new ServerCache(), 3, Version.fromIntValues(0, 0, 0), MetricUpdater.createTestUpdater(), appId);
+ application = new Application(mockModel,
+ new ServerCache(),
+ 3,
+ false,
+ Version.fromIntValues(0, 0, 0),
+ MetricUpdater.createTestUpdater(), appId);
checker = new ConfigConvergenceChecker(
(client, serviceUri) -> () -> string2json("{\"config\":{\"generation\":3}}"));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java
index 76204d5c5f2..c2ddec7e795 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/FileDistributionStatusTest.java
@@ -161,7 +161,13 @@ public class FileDistributionStatusTest {
private Application createApplication(List<String> hostnames) {
Model mockModel = MockModel.createConfigProxies(hostnames, 1337);
- return new Application(mockModel, new ServerCache(), 3, Version.fromIntValues(0, 0, 0), MetricUpdater.createTestUpdater(), appId);
+ return new Application(mockModel,
+ new ServerCache(),
+ 3,
+ false,
+ Version.fromIntValues(0, 0, 0),
+ MetricUpdater.createTestUpdater(),
+ appId);
}
HttpResponse getStatus(FileDistributionStatus fileDistributionStatus, Application application) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java
index 9b40784018a..b151ac57352 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java
@@ -15,6 +15,7 @@ import com.yahoo.config.provision.Zone;
import com.yahoo.test.ManualClock;
import static com.yahoo.vespa.config.server.deploy.DeployTester.CountingModelFactory;
+import com.yahoo.vespa.config.server.session.LocalSession;
import org.junit.Ignore;
import org.junit.Test;
@@ -50,12 +51,18 @@ public class HostedDeployTest {
@Test
public void testRedeploy() {
DeployTester tester = new DeployTester("src/test/apps/hosted/", createConfigserverConfig());
- tester.deployApp("myApp", Instant.now());
+ ApplicationId appId = tester.deployApp("myApp", Instant.now());
+ LocalSession s1 = tester.applicationRepository().getActiveSession(appId);
+ System.out.println("First session: " + s1.getSessionId());
+ assertFalse(tester.applicationRepository().getActiveSession(appId).getMetaData().isInternalRedeploy());
Optional<com.yahoo.config.provision.Deployment> deployment = tester.redeployFromLocalActive();
assertTrue(deployment.isPresent());
deployment.get().prepare();
deployment.get().activate();
+ LocalSession s2 = tester.applicationRepository().getActiveSession(appId);
+ System.out.println("Second session: " + s2.getSessionId());
+ assertTrue(tester.applicationRepository().getActiveSession(appId).getMetaData().isInternalRedeploy());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java
index bf7f7038c1a..945c7d60750 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/ZooKeeperClientTest.java
@@ -43,7 +43,14 @@ public class ZooKeeperClientTest extends TestWithCurator {
public void setupZK() throws IOException {
this.zk = ConfigCurator.create(curator);
ZooKeeperClient zkc = new ZooKeeperClient(zk, new BaseDeployLogger(), true, Path.fromString(appPath));
- ApplicationPackage app = FilesApplicationPackage.fromFileWithDeployData(new File("src/test/apps/zkfeed"), new DeployData("foo", "/bar/baz", "appName", 1345l, 3l, 2l));
+ ApplicationPackage app = FilesApplicationPackage.fromFileWithDeployData(new File("src/test/apps/zkfeed"),
+ new DeployData("foo",
+ "/bar/baz",
+ "appName",
+ 1345L,
+ true,
+ 3L,
+ 2L));
Map<Version, FileRegistry> fileRegistries = createFileRegistries();
app.writeMetaData();
zkc.setupZooKeeper();
@@ -97,7 +104,7 @@ public class ZooKeeperClientTest extends TestWithCurator {
// TODO: Evaluate if we want this or not
@Test
@Ignore
- public void testFeedComponentsFileReferencesToZooKeeper() throws IOException {
+ public void testFeedComponentsFileReferencesToZooKeeper() {
final String appDir = "src/test/apps/app_sdbundles";
ConfigCurator zk = ConfigCurator.create(new MockCurator());
BaseDeployLogger logger = new BaseDeployLogger();
@@ -120,6 +127,7 @@ public class ZooKeeperClientTest extends TestWithCurator {
ApplicationMetaData metaData = ApplicationMetaData.fromJsonString(zk.getData(appPath, ConfigCurator.META_ZK_PATH));
assertThat(metaData.getApplicationName(), is("appName"));
assertTrue(metaData.getCheckSum().length() > 0);
+ assertTrue(metaData.isInternalRedeploy());
assertThat(metaData.getDeployedByUser(), is("foo"));
assertThat(metaData.getDeployPath(), is("/bar/baz"));
assertThat(metaData.getDeployTimestamp(), is(1345l));
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java
index 9b82beb860e..5b166155a45 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpConfigResponseTest.java
@@ -29,7 +29,7 @@ public class HttpConfigResponseTest {
// TODO: Hope to be able to remove this mess soon.
DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
InnerCNode targetDef = dParser.getTree();
- ConfigResponse configResponse = SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5");
+ ConfigResponse configResponse = SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, false, "mymd5");
HttpConfigResponse response = HttpConfigResponse.createFromConfig(configResponse);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
index b19d6e2e257..f3800d66330 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
@@ -55,7 +55,7 @@ public class HttpGetConfigHandlerTest {
final long generation = 1L;
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
- mockRequestHandler.responses.put(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
+ mockRequestHandler.responses.put(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, false, "mymd5"));
HttpResponse response = handler.handle(HttpRequest.createTestRequest(configUri, GET));
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
@@ -82,7 +82,7 @@ public class HttpGetConfigHandlerTest {
long generation = 1L;
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
- mockRequestHandler.responses.put(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
+ mockRequestHandler.responses.put(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, false, "mymd5"));
final HttpRequest request = HttpRequest.createTestRequest(configUri, GET, null, Collections.singletonMap("nocache", "true"));
HttpResponse response = handler.handle(request);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
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 930ae98c9e9..eb5dc7a2abf 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,7 +191,8 @@ public class SessionHandlerTest {
public String applicationName;
@Override
- public LocalSession createSession(File applicationDirectory, ApplicationId applicationId, TimeoutBudget timeoutBudget) {
+ public LocalSession createSession(File applicationDirectory, ApplicationId applicationId,
+ TimeoutBudget timeoutBudget) {
createCalled = true;
this.applicationName = applicationId.application().value();
if (doThrow) {
@@ -208,7 +209,8 @@ public class SessionHandlerTest {
}
@Override
- public LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger, TimeoutBudget timeoutBudget) {
+ public LocalSession createSessionFromExisting(LocalSession existingSession, DeployLogger logger,
+ boolean internalRedeploy, TimeoutBudget timeoutBudget) {
if (doThrow) {
throw new RuntimeException("foo");
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
index 5226ff38ce3..bc583c64206 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
@@ -60,7 +60,7 @@ public class HttpGetConfigHandlerTest {
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
mockRequestHandler.responses.put(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").build(),
- SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
+ SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, false, "mymd5"));
HttpResponse response = handler.handle(HttpRequest.createTestRequest(configUri, GET));
assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
}
@@ -75,7 +75,7 @@ public class HttpGetConfigHandlerTest {
mockRequestHandler.responses.put(new ApplicationId.Builder()
.tenant(tenant)
.applicationName("myapplication").instanceName("myinstance").build(),
- SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
+ SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, false, "mymd5"));
HttpResponse response = handler.handle(HttpRequest.createTestRequest(uriLongAppId, GET));
assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
}
@@ -123,7 +123,7 @@ public class HttpGetConfigHandlerTest {
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
mockRequestHandler.responses.put(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").build(),
- SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
+ SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, false, "mymd5"));
final HttpRequest request = HttpRequest.createTestRequest(configUri, GET, null, Collections.singletonMap("nocache", "true"));
HttpResponse response = handler.handle(request);
assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
index 030963aa9a1..fba4e40000d 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java
@@ -285,7 +285,13 @@ public class SessionActiveHandlerTest extends SessionHandlerTest {
ActivateRequest(long sessionId, long previousSessionId, Session.Status initialStatus, String subPath, Clock clock) {
this.sessionId = sessionId;
this.initialStatus = initialStatus;
- this.deployData = new DeployData("foo", "bar", appName, 0l, sessionId, previousSessionId);
+ this.deployData = new DeployData("foo",
+ "bar",
+ appName,
+ 0l,
+ false,
+ sessionId,
+ previousSessionId);
this.subPath = subPath;
this.clock = clock;
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java
index 9193c2409c7..7c1d5fa8dbc 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/ConfigResponseFactoryTest.java
@@ -13,38 +13,38 @@ import org.junit.Test;
import java.io.StringReader;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
/**
- * @author lulf
- * @since 5.19
+ * @author Ulf Lilleengen
*/
public class ConfigResponseFactoryTest {
- private InnerCNode def;
+ private InnerCNode def;
@Before
public void setup() {
- DefParser dParser = new DefParser(SimpletypesConfig.getDefName(), new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
+ DefParser dParser = new DefParser(SimpletypesConfig.getDefName(),
+ new StringReader(StringUtilities.implode(SimpletypesConfig.CONFIG_DEF_SCHEMA, "\n")));
def = dParser.getTree();
}
@Test
public void testUncompressedFacory() {
UncompressedConfigResponseFactory responseFactory = new UncompressedConfigResponseFactory();
- ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3);
- assertThat(response.getCompressionInfo().getCompressionType(), is(CompressionType.UNCOMPRESSED));
- assertThat(response.getGeneration(), is(3l));
- assertThat(response.getPayload().getByteLength(), is(2));
+ ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3, false);
+ assertEquals(CompressionType.UNCOMPRESSED, response.getCompressionInfo().getCompressionType());
+ assertEquals(3L,response.getGeneration());
+ assertEquals(2, response.getPayload().getByteLength());
}
@Test
public void testLZ4CompressedFacory() {
LZ4ConfigResponseFactory responseFactory = new LZ4ConfigResponseFactory();
- ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3);
- assertThat(response.getCompressionInfo().getCompressionType(), is(CompressionType.LZ4));
- assertThat(response.getGeneration(), is(3l));
- assertThat(response.getPayload().getByteLength(), is(3));
+ ConfigResponse response = responseFactory.createResponse(ConfigPayload.empty(), def, 3, false);
+ assertEquals(CompressionType.LZ4, response.getCompressionInfo().getCompressionType());
+ assertEquals(3L, response.getGeneration());
+ assertEquals(3, response.getPayload().getByteLength());
}
+
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java
index aa4678fb01b..1a4d04d0323 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessorTest.java
@@ -108,6 +108,9 @@ public class GetConfigProcessorTest {
}
@Override
+ public boolean isInternalRedeploy() { return false; }
+
+ @Override
public String getConfigMd5() {
return "mymd5";
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java
index 62ff13093ea..ebdee8f58e5 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRequestHandler.java
@@ -15,15 +15,15 @@ import java.util.*;
/**
* Test utility class
- * @author lulf
- * @since 5.25
+ *
+ * @author Ulf Lilleengen
*/
public class MockRequestHandler implements RequestHandler, ReloadHandler, TenantHandlerProvider {
volatile boolean throwException = false;
private Set<ConfigKey<?>> allConfigs = new HashSet<>();
public volatile ConfigResponse responseConfig = null; // for some v1 mocking
- public Map<ApplicationId, ConfigResponse> responses = new LinkedHashMap<>(); // for v2 mocking
+ public Map<ApplicationId, ConfigResponse> responses = new LinkedHashMap<>(); // for v3 mocking
private final boolean pretendToHaveLoadedAnyApplication;
public MockRequestHandler() {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
index 3cfe6aa7c6d..9807045e122 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
@@ -32,8 +32,7 @@ import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
/**
- * @author lulf
- * @since 5.1
+ * @author Ulf Lilleengen
*/
public class RpcServerTest extends TestWithRpc {
@@ -70,10 +69,15 @@ public class RpcServerTest extends TestWithRpc {
return clientReq;
}
-
private void testEnabled() throws IOException, SAXException {
generationCounter.increment();
- Application app = new Application(new VespaModel(MockApplicationPackage.createEmpty()), new ServerCache(), 2l, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), ApplicationId.defaultId());
+ Application app = new Application(new VespaModel(MockApplicationPackage.createEmpty()),
+ new ServerCache(),
+ 2L,
+ false,
+ Version.fromIntValues(1, 2, 3),
+ MetricUpdater.createTestUpdater(),
+ ApplicationId.defaultId());
ApplicationSet appSet = ApplicationSet.fromSingle(app);
rpcServer.configActivated(TenantName.defaultName(), appSet);
ConfigKey<?> key = new ConfigKey<>(LbServicesConfig.class, "*");
@@ -95,12 +99,17 @@ public class RpcServerTest extends TestWithRpc {
public void testGetConfig() {
((MockRequestHandler)tenantProvider.getRequestHandler()).throwException = false;
ConfigKey<?> key = new ConfigKey<>(SimpletypesConfig.class, "brim");
- ((MockRequestHandler)tenantProvider.getRequestHandler()).responses.put(ApplicationId.defaultId(), createResponse());
- JRTClientConfigRequest req = JRTClientConfigRequestV3.createFromRaw(new RawConfig(key, SimpletypesConfig.CONFIG_DEF_MD5), 120_000, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty());
+ ((MockRequestHandler)tenantProvider.getRequestHandler()).responses.put(ApplicationId.defaultId(), createResponse(true));
+ JRTClientConfigRequest req = JRTClientConfigRequestV3.createFromRaw(new RawConfig(key, SimpletypesConfig.CONFIG_DEF_MD5),
+ 120_000,
+ Trace.createDummy(),
+ CompressionType.UNCOMPRESSED,
+ Optional.empty());
assertTrue(req.validateParameters());
performRequest(req.getRequest());
assertThat(req.errorCode(), is(0));
assertTrue(req.validateResponse());
+ assertTrue(req.responseIsInternalRedeploy());
ConfigPayload payload = ConfigPayload.fromUtf8Array(req.getNewPayload().getData());
assertNotNull(payload);
SimpletypesConfig.Builder builder = new SimpletypesConfig.Builder();
@@ -109,13 +118,19 @@ public class RpcServerTest extends TestWithRpc {
assertThat(config.intval(), is(123));
}
- public ConfigResponse createResponse() {
+ public ConfigResponse createResponse(boolean internalRedeploy) {
SimpletypesConfig.Builder builder = new SimpletypesConfig.Builder();
builder.intval(123);
SimpletypesConfig responseConfig = new SimpletypesConfig(builder);
ConfigPayload responsePayload = ConfigPayload.fromInstance(responseConfig);
- InnerCNode targetDef = new DefParser(SimpletypesConfig.CONFIG_DEF_NAME, new StringReader(Joiner.on("\n").join(SimpletypesConfig.CONFIG_DEF_SCHEMA))).getTree();
- return SlimeConfigResponse.fromConfigPayload(responsePayload, targetDef, 3l, ConfigUtils.getMd5(responsePayload));
+ InnerCNode targetDef = new DefParser(SimpletypesConfig.CONFIG_DEF_NAME,
+ new StringReader(Joiner.on("\n").join(SimpletypesConfig.CONFIG_DEF_SCHEMA)))
+ .getTree();
+ return SlimeConfigResponse.fromConfigPayload(responsePayload,
+ targetDef,
+ 3L,
+ internalRedeploy,
+ ConfigUtils.getMd5(responsePayload));
}
public void testPrintStatistics() {
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 531a2e3745b..0ca487cfb67 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
@@ -31,8 +31,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
- * @author lulf
- * @since 5.1
+ * @author Ulf Lilleengen
*/
public class SessionFactoryTest extends TestWithTenant {
private SessionFactory factory;
@@ -64,10 +63,13 @@ public class SessionFactoryTest extends TestWithTenant {
public void require_that_session_can_be_created_from_existing() throws IOException {
LocalSession session = getLocalSession();
assertNotNull(session);
- assertThat(session.getSessionId(), is(2l));
- LocalSession session2 = factory.createSessionFromExisting(session, new BaseDeployLogger(), TimeoutBudgetTest.day());
+ assertThat(session.getSessionId(), is(2L));
+ LocalSession session2 = factory.createSessionFromExisting(session,
+ new BaseDeployLogger(),
+ false,
+ TimeoutBudgetTest.day());
assertNotNull(session2);
- assertThat(session2.getSessionId(), is(3l));
+ assertThat(session2.getSessionId(), is(3L));
}
@Test(expected = RuntimeException.class)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/MockTenantProvider.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/MockTenantProvider.java
index 77505006b77..4d01f8a609d 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/MockTenantProvider.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/MockTenantProvider.java
@@ -7,8 +7,7 @@ import com.yahoo.vespa.config.server.ReloadHandler;
import com.yahoo.vespa.config.server.RequestHandler;
/**
- * @author lulf
- * @since 5.
+ * @author Ulf Lilleengen
*/
public class MockTenantProvider implements TenantHandlerProvider {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
index 9a4b0b05186..f47ed69ad14 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
@@ -65,8 +65,13 @@ public class TenantRepositoryTest extends TestWithCurator {
@Test
public void testListenersAdded() throws IOException, SAXException {
tenantRepository.getTenant(tenant1).getReloadHandler().reloadConfig(ApplicationSet.fromSingle(
- new Application(new VespaModel(MockApplicationPackage.createEmpty()), new ServerCache(), 4l,
- Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), ApplicationId.defaultId())));
+ new Application(new VespaModel(MockApplicationPackage.createEmpty()),
+ new ServerCache(),
+ 4L,
+ false,
+ Version.fromIntValues(1, 2, 3),
+ MetricUpdater.createTestUpdater(),
+ ApplicationId.defaultId())));
assertThat(listener.reloaded.get(), is(1));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java
index ef320f0f084..cecbab2d9ec 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandlerTest.java
@@ -3,8 +3,10 @@ package com.yahoo.vespa.config.server.tenant;
import com.yahoo.config.ConfigInstance;
import com.yahoo.config.SimpletypesConfig;
+import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.NullConfigModelRegistry;
import com.yahoo.config.model.application.provider.BaseDeployLogger;
+import com.yahoo.config.model.application.provider.DeployData;
import com.yahoo.config.model.application.provider.FilesApplicationPackage;
import com.yahoo.config.model.application.provider.MockFileRegistry;
import com.yahoo.config.provision.ApplicationName;
@@ -54,8 +56,7 @@ import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
/**
- * @author lulf
- * @since 5.1
+ * @author Ulf Lilleengen
*/
public class TenantRequestHandlerTest extends TestWithCurator {
@@ -70,9 +71,13 @@ public class TenantRequestHandlerTest extends TestWithCurator {
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
+ private ApplicationId defaultApp() {
+ return new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build();
+ }
+
@Before
- public void setUp() throws IOException, SAXException {
- feedApp(app1, 1);
+ public void setUp() throws IOException {
+ feedApp(app1, 1, defaultApp(), false);
Metrics sh = Metrics.createTestMetrics();
List<ReloadListener> listeners = new ArrayList<>();
listeners.add(listener);
@@ -80,11 +85,7 @@ public class TenantRequestHandlerTest extends TestWithCurator {
componentRegistry = new TestComponentRegistry.Builder().curator(curator).modelFactoryRegistry(createRegistry()).build();
}
- private void feedApp(File appDir, long sessionId) throws IOException {
- feedApp(appDir, sessionId, new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build());
- }
-
- private void feedApp(File appDir, long sessionId, ApplicationId appId) throws IOException {
+ private void feedApp(File appDir, long sessionId, ApplicationId appId, boolean internalRedeploy) throws IOException {
SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, configCurator,
TenantRepository.getSessionsPath(tenant).append(String.valueOf(sessionId)),
new TestConfigDefinitionRepo(),
@@ -93,7 +94,17 @@ public class TenantRequestHandlerTest extends TestWithCurator {
File app = tempFolder.newFolder();
IOUtils.copyDirectory(appDir, app);
ZooKeeperDeployer deployer = zkc.createDeployer(new BaseDeployLogger());
- deployer.deploy(FilesApplicationPackage.fromFile(appDir), Collections.singletonMap(vespaVersion, new MockFileRegistry()), AllocatedHosts.withHosts(Collections.emptySet()));
+ DeployData deployData = new DeployData("user",
+ appDir.toString(),
+ appId.application().toString(),
+ 0L,
+ internalRedeploy,
+ 0L,
+ 0L);
+ ApplicationPackage appPackage = FilesApplicationPackage.fromFileWithDeployData(appDir, deployData);
+ deployer.deploy(appPackage,
+ Collections.singletonMap(vespaVersion, new MockFileRegistry()),
+ AllocatedHosts.withHosts(Collections.emptySet()));
}
private ApplicationSet reloadConfig(long id, Clock clock) {
@@ -115,12 +126,21 @@ public class TenantRequestHandlerTest extends TestWithCurator {
new TestModelFactory(Version.fromIntValues(3, 2, 1))));
}
- public <T extends ConfigInstance> T resolve(Class<T> clazz, TenantRequestHandler tenantRequestHandler, String configId) {
- return resolve(clazz, tenantRequestHandler, new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build(), vespaVersion, configId);
+ public <T extends ConfigInstance> T resolve(Class<T> clazz,
+ TenantRequestHandler tenantRequestHandler,
+ ApplicationId appId,
+ Version vespaVersion,
+ String configId) {
+ ConfigResponse response = getConfigResponse(clazz, tenantRequestHandler, appId, vespaVersion, configId);
+ return ConfigPayload.fromUtf8Array(response.getPayload()).toInstance(clazz, configId);
}
- public <T extends ConfigInstance> T resolve(final Class<T> clazz, TenantRequestHandler tenantRequestHandler, ApplicationId appId, Version vespaVersion, final String configId) {
- ConfigResponse response = tenantRequestHandler.resolveConfig(appId, new GetConfigRequest() {
+ public <T extends ConfigInstance> ConfigResponse getConfigResponse(Class<T> clazz,
+ TenantRequestHandler tenantRequestHandler,
+ ApplicationId appId,
+ Version vespaVersion,
+ String configId) {
+ return tenantRequestHandler.resolveConfig(appId, new GetConfigRequest() {
@Override
public ConfigKey<T> getConfigKey() {
return new ConfigKey<T>(clazz, configId);
@@ -141,23 +161,24 @@ public class TenantRequestHandlerTest extends TestWithCurator {
return false;
}
}, Optional.empty());
- return ConfigPayload.fromUtf8Array(response.getPayload()).toInstance(clazz, configId);
}
@Test
- public void testReloadConfig() throws IOException, SAXException {
+ public void testReloadConfig() throws IOException {
Clock clock = Clock.systemUTC();
ApplicationId applicationId = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build();
server.reloadConfig(reloadConfig(1, clock));
assertThat(listener.reloaded.get(), is(1));
// Using only payload list for this simple test
- SimpletypesConfig config = resolve(SimpletypesConfig.class, server, "");
+ SimpletypesConfig config = resolve(SimpletypesConfig.class, server, defaultApp(), vespaVersion, "");
assertThat(config.intval(), is(1337));
assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(1l));
- server.reloadConfig(reloadConfig(1l, clock));
- config = resolve(SimpletypesConfig.class, server, "");
+ server.reloadConfig(reloadConfig(1L, clock));
+ ConfigResponse configResponse = getConfigResponse(SimpletypesConfig.class, server, defaultApp(), vespaVersion, "");
+ assertFalse(configResponse.isInternalRedeploy());
+ config = resolve(SimpletypesConfig.class, server, defaultApp(), vespaVersion, "");
assertThat(config.intval(), is(1337));
assertThat(listener.reloaded.get(), is(2));
assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(1l));
@@ -165,9 +186,11 @@ public class TenantRequestHandlerTest extends TestWithCurator {
assertThat(server.resolveApplicationId("mytesthost"), is(applicationId));
listener.reloaded.set(0);
- feedApp(app2, 2);
- server.reloadConfig(reloadConfig(2l, clock));
- config = resolve(SimpletypesConfig.class, server, "");
+ feedApp(app2, 2, defaultApp(), true);
+ server.reloadConfig(reloadConfig(2L, clock));
+ configResponse = getConfigResponse(SimpletypesConfig.class, server, defaultApp(), vespaVersion, "");
+ assertTrue(configResponse.isInternalRedeploy());
+ config = resolve(SimpletypesConfig.class, server, defaultApp(), vespaVersion,"");
assertThat(config.intval(), is(1330));
assertThat(listener.reloaded.get(), is(1));
assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(2l));
@@ -183,7 +206,7 @@ public class TenantRequestHandlerTest extends TestWithCurator {
@Test
public void testResolveForAppId() {
- long id = 1l;
+ long id = 1L;
SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, configCurator,
TenantRepository.getSessionsPath(tenant).append(String.valueOf(id)),
new TestConfigDefinitionRepo(),
@@ -199,7 +222,7 @@ public class TenantRequestHandlerTest extends TestWithCurator {
}
@Test
- public void testResolveMultipleApps() throws IOException, SAXException {
+ public void testResolveMultipleApps() throws IOException {
ApplicationId appId1 = new ApplicationId.Builder()
.tenant(tenant)
.applicationName("myapp1").instanceName("myinst1").build();
@@ -228,7 +251,7 @@ public class TenantRequestHandlerTest extends TestWithCurator {
}
private void feedAndReloadApp(File appDir, long sessionId, ApplicationId appId) throws IOException {
- feedApp(appDir, sessionId, appId);
+ feedApp(appDir, sessionId, appId, false);
SessionZooKeeperClient zkc = new SessionZooKeeperClient(curator, TenantRepository.getSessionsPath(tenant).append(String.valueOf(sessionId)));
zkc.writeApplicationId(appId);
RemoteSession session = new RemoteSession(tenant, sessionId, componentRegistry, zkc, Clock.systemUTC());
@@ -263,7 +286,8 @@ public class TenantRequestHandlerTest extends TestWithCurator {
public void testHasApplication() throws IOException, SAXException {
assertdefaultAppNotFound();
server.reloadConfig(reloadConfig(1l, Clock.systemUTC()));
- assertTrue(server.hasApplication(new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build(), Optional.of(vespaVersion)));
+ assertTrue(server.hasApplication(new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build(),
+ Optional.of(vespaVersion)));
}
private void assertdefaultAppNotFound() {
@@ -286,18 +310,17 @@ public class TenantRequestHandlerTest extends TestWithCurator {
@Test
public void testListConfigs() throws IOException, SAXException {
assertdefaultAppNotFound();
- /*assertTrue(server.allConfigIds(ApplicationId.defaultId()).isEmpty());
- assertTrue(server.allConfigsProduced(ApplicationId.defaultId()).isEmpty());
- assertTrue(server.listConfigs(ApplicationId.defaultId(), false).isEmpty());
- assertTrue(server.listConfigs(ApplicationId.defaultId(), true).isEmpty());*/
VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(new File("src/test/apps/app")));
- server.reloadConfig(ApplicationSet.fromSingle(new Application(model, new ServerCache(), 1, vespaVersion, MetricUpdater.createTestUpdater(), ApplicationId.defaultId())));
+ server.reloadConfig(ApplicationSet.fromSingle(new Application(model,
+ new ServerCache(),
+ 1,
+ false,
+ vespaVersion,
+ MetricUpdater.createTestUpdater(),
+ ApplicationId.defaultId())));
Set<ConfigKey<?>> configNames = server.listConfigs(ApplicationId.defaultId(), Optional.of(vespaVersion), false);
assertTrue(configNames.contains(new ConfigKey<>("sentinel", "hosts", "cloud.config")));
- //for (ConfigKey<?> ck : configNames) {
- // assertTrue(!"".equals(ck.getConfigId()));
- //}
configNames = server.listConfigs(ApplicationId.defaultId(), Optional.of(vespaVersion), true);
System.out.println(configNames);