diff options
4 files changed, 35 insertions, 9 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index cd3698eed78..9fe725453f4 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -206,7 +206,7 @@ public class SessionRepository { return getSessionList(curator.getChildren(sessionsPath)); } - public void addSession(RemoteSession session) { + public void addRemoteSession(RemoteSession session) { remoteSessionCache.addSession(session); metrics.incAddedSessions(); } @@ -274,7 +274,7 @@ public class SessionRepository { Curator.FileCache fileCache = curator.createFileCache(sessionPath.append(ConfigCurator.SESSIONSTATE_ZK_SUBPATH).getAbsolute(), false); fileCache.addListener(this::nodeChanged); loadSessionIfActive(session); - addSession(session); + addRemoteSession(session); remoteSessionStateWatchers.put(sessionId, new RemoteSessionStateWatcher(fileCache, reloadHandler, session, metrics, zkWatcherExecutor)); if (distributeApplicationPackage.value()) sessionFactory.createLocalSessionUsingDistributedApplicationPackage(sessionId); 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 d609f758c68..2c07d50b470 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 @@ -47,6 +47,9 @@ import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.curator.Curator; import com.yahoo.vespa.curator.mock.MockCurator; +import com.yahoo.vespa.flags.FlagSource; +import com.yahoo.vespa.flags.Flags; +import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.model.VespaModelFactory; import org.hamcrest.core.Is; import org.jetbrains.annotations.NotNull; @@ -113,16 +116,22 @@ public class ApplicationRepositoryTest { @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); + @Before public void setup() throws IOException { + setup(new InMemoryFlagSource()); + } + + public void setup(FlagSource flagSource) throws IOException { Curator curator = new MockCurator(); TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder() .curator(curator) .configServerConfig(new ConfigserverConfig.Builder() .payloadCompressionType(ConfigserverConfig.PayloadCompressionType.Enum.UNCOMPRESSED) - .configServerDBDir(tempFolder.newFolder("configserverdb").getAbsolutePath()) - .configDefinitionsDir(tempFolder.newFolder("configdefinitions").getAbsolutePath()) + .configServerDBDir(tempFolder.newFolder().getAbsolutePath()) + .configDefinitionsDir(tempFolder.newFolder().getAbsolutePath()) .build()) + .flagSource(flagSource) .build(); tenantRepository = new TenantRepository(componentRegistry, false); tenantRepository.addTenant(TenantRepository.HOSTED_VESPA_TENANT); @@ -658,6 +667,14 @@ public class ApplicationRepositoryTest { resolve(SimpletypesConfig.class, requestHandler, applicationId(), vespaVersion); } + @Test + public void testDistributionOfApplicationPackage() throws IOException { + FlagSource flagSource = new InMemoryFlagSource() + .withBooleanFlag(Flags.CONFIGSERVER_DISTRIBUTE_APPLICATION_PACKAGE.id(), true); + setup(flagSource); + applicationRepository.deploy(app1, prepareParams()); + } + private ApplicationRepository createApplicationRepository() { return new ApplicationRepository(tenantRepository, provisioner, diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java index ec5648757f1..bc16f44b405 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java @@ -60,6 +60,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private final StripedExecutor<TenantName> zkWatcherExecutor; private final ExecutorService zkCacheExecutor; private final SecretStore secretStore; + private final FlagSource flagSource; private TestComponentRegistry(Curator curator, ConfigCurator configCurator, Metrics metrics, ModelFactoryRegistry modelFactoryRegistry, @@ -74,7 +75,8 @@ public class TestComponentRegistry implements GlobalComponentRegistry { TenantListener tenantListener, Zone zone, Clock clock, - SecretStore secretStore) { + SecretStore secretStore, + FlagSource flagSource) { this.curator = curator; this.configCurator = configCurator; this.metrics = metrics; @@ -94,6 +96,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { this.zkWatcherExecutor = new StripedExecutor<>(new InThreadExecutorService()); this.zkCacheExecutor = new InThreadExecutorService(); this.secretStore = secretStore; + this.flagSource = flagSource; } public static class Builder { @@ -115,6 +118,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private Optional<Provisioner> hostProvisioner = Optional.empty(); private Zone zone = Zone.defaultZone(); private Clock clock = Clock.systemUTC(); + private FlagSource flagSource = new InMemoryFlagSource(); public Builder configServerConfig(ConfigserverConfig configserverConfig) { this.configserverConfig = configserverConfig; @@ -161,6 +165,11 @@ public class TestComponentRegistry implements GlobalComponentRegistry { return this; } + public Builder flagSource(FlagSource flagSource) { + this.flagSource = flagSource; + return this; + } + public TestComponentRegistry build() { final PermanentApplicationPackage permApp = this.permanentApplicationPackage .orElse(new PermanentApplicationPackage(configserverConfig)); @@ -172,11 +181,11 @@ public class TestComponentRegistry implements GlobalComponentRegistry { SessionPreparer sessionPreparer = new SessionPreparer(modelFactoryRegistry, fileDistributionProvider, hostProvisionerProvider, permApp, configserverConfig, defRepo, curator, - zone, new InMemoryFlagSource(), secretStore); + zone, flagSource, secretStore); return new TestComponentRegistry(curator, ConfigCurator.create(curator), metrics, modelFactoryRegistry, permApp, fileDistributionProvider, hostRegistries, configserverConfig, sessionPreparer, hostProvisioner, defRepo, reloadListener, tenantListener, - zone, clock, secretStore); + zone, clock, secretStore, flagSource); } } @@ -221,7 +230,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry { } @Override - public FlagSource getFlagSource() { return new InMemoryFlagSource(); } + public FlagSource getFlagSource() { return flagSource; } @Override public ExecutorService getZkCacheExecutor() { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java index ae113969ef4..457acf8c376 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java @@ -56,7 +56,7 @@ public class HostHandlerTest { TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder() .modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))) .build(); - tenant.getSessionRepo().addSession(new RemoteSession(tenant.getName(), sessionId, componentRegistry, new MockSessionZKClient(app))); + tenant.getSessionRepo().addRemoteSession(new RemoteSession(tenant.getName(), sessionId, componentRegistry, new MockSessionZKClient(app))); } @Before |