diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-06-26 14:41:19 +0200 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-06-26 14:41:19 +0200 |
commit | b13c54c46999257f7ac983403860c7b2259931fc (patch) | |
tree | 149ad36bf5300bdd96d3f90b239b1e1691c99d19 /configserver | |
parent | 725efef01b4625f4a20f5d9120e641c3552571b6 (diff) | |
parent | d4d3e55248acbf07a9b9dd48453e085a1d4a41df (diff) |
Merge branch 'master' into hmusum/add-model-versions-to-response
Diffstat (limited to 'configserver')
9 files changed, 91 insertions, 99 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 c0eba789761..0557fa6e552 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 @@ -59,6 +59,7 @@ import com.yahoo.vespa.config.server.tenant.ContainerEndpointsCache; import com.yahoo.vespa.config.server.tenant.EndpointCertificateMetadataStore; 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.Lock; import com.yahoo.vespa.orchestrator.Orchestrator; @@ -389,11 +390,12 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } NestedTransaction transaction = new NestedTransaction(); - transaction.add(new ContainerEndpointsCache(tenant.getPath(), tenant.getCurator()).delete(applicationId)); // TODO: Not unit tested + Curator curator = tenantRepository.getCurator(); + transaction.add(new ContainerEndpointsCache(tenant.getPath(), curator).delete(applicationId)); // TODO: Not unit tested // Delete any application roles - transaction.add(new ApplicationRolesStore(tenant.getCurator(), tenant.getPath()).delete(applicationId)); + transaction.add(new ApplicationRolesStore(curator, tenant.getPath()).delete(applicationId)); // Delete endpoint certificates - transaction.add(new EndpointCertificateMetadataStore(tenant.getCurator(), tenant.getPath()).delete(applicationId)); + transaction.add(new EndpointCertificateMetadataStore(curator, tenant.getPath()).delete(applicationId)); // (When rotations are updated in zk, we need to redeploy the zone app, on the right config server // this is done asynchronously in application maintenance by the node repository) transaction.add(tenantApplications.createDeleteTransaction(applicationId)); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainer.java index b3c67859098..d3865f287cd 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainer.java @@ -4,8 +4,8 @@ package com.yahoo.vespa.config.server.maintenance; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.curator.Curator; +import java.time.Clock; import java.time.Duration; -import java.time.Instant; /** * Removes unused tenants (has no applications and was created more than 7 days ago) @@ -14,19 +14,19 @@ import java.time.Instant; */ public class TenantsMaintainer extends ConfigServerMaintainer { - private final Duration ttlForUnusedTenant; + static final Duration defaultTtlForUnusedTenant = Duration.ofDays(7); - TenantsMaintainer(ApplicationRepository applicationRepository, Curator curator, Duration interval) { - this(applicationRepository, curator, interval, Duration.ofDays(7)); - } + private final Duration ttlForUnusedTenant; + private final Clock clock; - private TenantsMaintainer(ApplicationRepository applicationRepository, Curator curator, Duration interval, Duration ttlForUnusedTenant) { + TenantsMaintainer(ApplicationRepository applicationRepository, Curator curator, Duration interval, Clock clock) { super(applicationRepository, curator, interval, interval); - this.ttlForUnusedTenant = ttlForUnusedTenant; + this.ttlForUnusedTenant = defaultTtlForUnusedTenant; + this.clock = clock; } @Override protected void maintain() { - applicationRepository.deleteUnusedTenants(ttlForUnusedTenant, Instant.now()); + applicationRepository.deleteUnusedTenants(ttlForUnusedTenant, clock.instant()); } } 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 2110e6476b6..492c9432646 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 @@ -41,6 +41,8 @@ import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import java.time.Clock; import java.time.Duration; import java.time.Instant; @@ -323,13 +325,15 @@ public class SessionRepository { loadSessionIfActive(remoteSession); addRemoteSession(remoteSession); Optional<LocalSession> localSession = Optional.empty(); - if (distributeApplicationPackage.value()) { + if (distributeApplicationPackage()) localSession = createLocalSessionUsingDistributedApplicationPackage(sessionId); - localSession.ifPresent(this::addSession); - } addWatcher(sessionId, fileCache, remoteSession, localSession); } + private boolean distributeApplicationPackage() { + return distributeApplicationPackage.value(); + } + private void sessionRemoved(long sessionId) { SessionStateWatcher watcher = sessionStateWatchers.remove(sessionId); if (watcher != null) watcher.close(); @@ -462,7 +466,7 @@ public class SessionRepository { LocalSession session = create(existingApp, existingApplicationId, activeSessionId, internalRedeploy, timeoutBudget); // Note: Needs to be kept in sync with calls in SessionPreparer.writeStateToZooKeeper() session.setApplicationId(existingApplicationId); - if (distributeApplicationPackage.value() && existingSession.getApplicationPackageReference() != null) { + if (distributeApplicationPackage() && existingSession.getApplicationPackageReference() != null) { session.setApplicationPackageReference(existingSession.getApplicationPackageReference()); } session.setVespaVersion(existingSession.getVespaVersion()); @@ -504,7 +508,7 @@ public class SessionRepository { long sessionId, Optional<Long> currentlyActiveSessionId, boolean internalRedeploy) throws IOException { File userApplicationDir = getSessionAppDir(sessionId); - IOUtils.copyDirectory(applicationFile, userApplicationDir); + copyApp(applicationFile, userApplicationDir); ApplicationPackage applicationPackage = createApplication(applicationFile, userApplicationDir, applicationId, @@ -515,6 +519,20 @@ public class SessionRepository { return applicationPackage; } + private void copyApp(File sourceDir, File destinationDir) throws IOException { + if (destinationDir.exists()) + throw new RuntimeException("Destination dir " + destinationDir + " already exists"); + if (! sourceDir.isDirectory()) + throw new IllegalArgumentException(sourceDir.getAbsolutePath() + " is not a directory"); + + // Copy app it atomically: Copy to default tmp dir and move to destination + java.nio.file.Path tempDestinationDir = Files.createTempDirectory(destinationDir.getParentFile().toPath(), "app-package"); + log.log(Level.FINE, "Copying dir " + sourceDir.getAbsolutePath() + " to " + tempDestinationDir.toFile().getAbsolutePath()); + IOUtils.copyDirectory(sourceDir, tempDestinationDir.toFile()); + log.log(Level.FINE, "Moving " + tempDestinationDir + " to " + destinationDir.getAbsolutePath()); + Files.move(tempDestinationDir, destinationDir.toPath(), StandardCopyOption.ATOMIC_MOVE); + } + /** * Returns a new session instance for the given session id. */ @@ -526,7 +544,8 @@ public class SessionRepository { } /** - * Returns a new session instance for the given session id. + * Returns a new local session for the given session id if it does not already exist. + * Will also add the session to the local session cache if necessary */ public Optional<LocalSession> createLocalSessionUsingDistributedApplicationPackage(long sessionId) { if (applicationRepo.hasLocalSession(sessionId)) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java index 08b5c59203a..90bcc221476 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenant.java @@ -6,11 +6,8 @@ import com.yahoo.path.Path; import com.yahoo.vespa.config.server.RequestHandler; import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.session.SessionRepository; -import com.yahoo.vespa.curator.Curator; -import org.apache.zookeeper.data.Stat; import java.time.Instant; -import java.util.Optional; /** * Contains all tenant-level components for a single tenant, dealing with editing sessions and @@ -29,19 +26,19 @@ public class Tenant implements TenantHandlerProvider { private final SessionRepository sessionRepository; private final TenantApplications applicationRepo; private final RequestHandler requestHandler; - private final Curator curator; + private final Instant created; Tenant(TenantName name, SessionRepository sessionRepository, RequestHandler requestHandler, TenantApplications applicationRepo, - Curator curator) { + Instant created) { this.name = name; this.path = TenantRepository.getTenantPath(name); this.requestHandler = requestHandler; this.sessionRepository = sessionRepository; this.applicationRepo = applicationRepo; - this.curator = curator; + this.created = created; } /** @@ -72,16 +69,8 @@ public class Tenant implements TenantHandlerProvider { return applicationRepo; } - public Curator getCurator() { - return curator; - } - public Instant getCreatedTime() { - Optional<Stat> stat = curator.getStat(path); - if (stat.isPresent()) - return Instant.ofEpochMilli(stat.get().getCtime()); - else - return Instant.now(); + return created; } @Override @@ -101,16 +90,11 @@ public class Tenant implements TenantHandlerProvider { /** * Closes any watchers, thread pools that may react to changes in tenant state, * and removes any session data in filesystem and zookeeper. - * Called by watchers as a reaction to {@link #delete()}. + * Called by watchers as a reaction to deleting a tenant. */ void close() { applicationRepo.close(); // Closes watchers. sessionRepository.close(); // Closes watchers, clears memory, and deletes local files and ZK session state. } - /** Deletes the tenant tree from ZooKeeper (application and session status for the tenant) and triggers {@link #close()}. */ - void delete() { - curator.delete(path); // Deletes tenant ZK tree: applications and sessions. - } - } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java index 2c9d9bf239c..5afb99e81e3 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java @@ -20,8 +20,10 @@ import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent; import org.apache.curator.framework.state.ConnectionState; import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.data.Stat; import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -82,7 +84,6 @@ public class TenantRepository { private final ExecutorService bootstrapExecutor; private final ScheduledExecutorService checkForRemovedApplicationsService = new ScheduledThreadPoolExecutor(1); private final Optional<Curator.DirectoryCache> directoryCache; - private final boolean throwExceptionIfBootstrappingFails; /** * Creates a new tenant repository @@ -105,7 +106,6 @@ public class TenantRepository { this.componentRegistry = componentRegistry; ConfigserverConfig configserverConfig = componentRegistry.getConfigserverConfig(); this.bootstrapExecutor = Executors.newFixedThreadPool(configserverConfig.numParallelTenantLoaders()); - this.throwExceptionIfBootstrappingFails = configserverConfig.throwIfBootstrappingTenantRepoFails(); this.curator = componentRegistry.getCurator(); metricUpdater = componentRegistry.getMetrics().getOrCreateMetricUpdater(Collections.emptyMap()); this.tenantListeners.add(componentRegistry.getTenantListener()); @@ -148,7 +148,7 @@ public class TenantRepository { public synchronized void addTenant(TenantName tenantName, RequestHandler requestHandler, ReloadHandler reloadHandler) { writeTenantPath(tenantName); - createTenant(tenantName, requestHandler, reloadHandler); + createTenant(tenantName, componentRegistry.getClock().instant(), requestHandler, reloadHandler); } private static Set<TenantName> readTenantsFromZooKeeper(Curator curator) { @@ -164,14 +164,14 @@ public class TenantRepository { zkWatcherExecutor.execute(tenantName, () -> closeTenant(tenantName)); for (TenantName tenantName : allTenants) if ( ! tenants.containsKey(tenantName)) - zkWatcherExecutor.execute(tenantName, () -> createTenant(tenantName)); + zkWatcherExecutor.execute(tenantName, () -> bootstrapTenant(tenantName)); metricUpdater.setTenants(tenants.size()); } private void bootstrapTenants() { // Keep track of tenants created Map<TenantName, Future<?>> futures = new HashMap<>(); - readTenantsFromZooKeeper(curator).forEach(t -> futures.put(t, bootstrapExecutor.submit(() -> createTenant(t)))); + readTenantsFromZooKeeper(curator).forEach(t -> futures.put(t, bootstrapExecutor.submit(() -> bootstrapTenant(t)))); // Wait for all tenants to be created Set<TenantName> failed = new HashSet<>(); @@ -187,7 +187,7 @@ public class TenantRepository { } } - if (failed.size() > 0 && throwExceptionIfBootstrappingFails) + if (failed.size() > 0) throw new RuntimeException("Could not create all tenants when bootstrapping, failed to create: " + failed); metricUpdater.setTenants(tenants.size()); @@ -199,12 +199,21 @@ public class TenantRepository { } } - protected void createTenant(TenantName tenantName) { - createTenant(tenantName, null, null); + // Use when bootstrapping an existing tenant based on ZooKeeper data + protected void bootstrapTenant(TenantName tenantName) { + createTenant(tenantName, readCreatedTimeFromZooKeeper(tenantName), null, null); + } + + public Instant readCreatedTimeFromZooKeeper(TenantName tenantName) { + Optional<Stat> stat = curator.getStat(getTenantPath(tenantName)); + if (stat.isPresent()) + return Instant.ofEpochMilli(stat.get().getCtime()); + else + return componentRegistry.getClock().instant(); } // Creates tenant and all its dependencies. This also includes loading active applications - private void createTenant(TenantName tenantName, RequestHandler requestHandler, ReloadHandler reloadHandler) { + private void createTenant(TenantName tenantName, Instant created, RequestHandler requestHandler, ReloadHandler reloadHandler) { if (tenants.containsKey(tenantName)) return; TenantApplications applicationRepo = @@ -225,9 +234,8 @@ public class TenantRepository { applicationRepo, reloadHandler, componentRegistry.getFlagSource(), componentRegistry.getSessionPreparer()); - log.log(Level.INFO, "Creating tenant '" + tenantName + "'"); - Tenant tenant = new Tenant(tenantName, sessionRepository, requestHandler, applicationRepo, - componentRegistry.getCurator()); + log.log(Level.INFO, "Adding tenant '" + tenantName + "'" + ", created " + created); + Tenant tenant = new Tenant(tenantName, sessionRepository, requestHandler, applicationRepo, created); notifyNewTenant(tenant); tenants.putIfAbsent(tenantName, tenant); } @@ -303,7 +311,9 @@ public class TenantRepository { throw new IllegalArgumentException("Deleting '" + name + "' failed, tenant does not exist"); log.log(Level.INFO, "Deleting tenant '" + name + "'"); - tenants.get(name).delete(); + // Deletes the tenant tree from ZooKeeper (application and session status for the tenant) + // and triggers Tenant.close(). + curator.delete(tenants.get(name).getPath()); } private synchronized void closeTenant(TenantName name) { @@ -316,11 +326,6 @@ public class TenantRepository { tenant.close(); } - // For unit testing - String tenantZkPath(TenantName tenant) { - return getTenantPath(tenant).getAbsolute(); - } - /** * A helper to format a log preamble for messages with a tenant and app id * @param app the app @@ -446,4 +451,6 @@ public class TenantRepository { return locksPath.append(tenantName.value()); } + public Curator getCurator() { return curator; } + } 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 8745a9bf596..c6d2c6b6438 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 @@ -63,7 +63,6 @@ import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.IOException; -import java.time.Clock; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -101,7 +100,7 @@ public class ApplicationRepositoryTest { private final static TenantName tenant1 = TenantName.from("test1"); private final static TenantName tenant2 = TenantName.from("test2"); private final static TenantName tenant3 = TenantName.from("test3"); - private final static Clock clock = Clock.systemUTC(); + private final static ManualClock clock = new ManualClock(Instant.now()); private ApplicationRepository applicationRepository; private TenantRepository tenantRepository; @@ -133,6 +132,7 @@ public class ApplicationRepositoryTest { .fileReferencesDir(temporaryFolder.newFolder().getAbsolutePath()) .build()) .flagSource(flagSource) + .clock(clock) .build(); tenantRepository = new TenantRepository(componentRegistry, false); tenantRepository.addTenant(TenantRepository.HOSTED_VESPA_TENANT); @@ -245,29 +245,6 @@ public class ApplicationRepositoryTest { } @Test - public void deleteUnusedTenants() { - // Set clock to epoch plus hour, as mock curator will always return epoch as creation time - Instant now = ManualClock.at("1970-01-01T01:00:00"); - - // 3 tenants exist, tenant1 and tenant2 has applications deployed: - deployApp(testApp); - deployApp(testApp, new PrepareParams.Builder().applicationId(applicationId(tenant2)).build()); - - // Should not be deleted, not old enough - Duration ttlForUnusedTenant = Duration.ofHours(1); - assertTrue(applicationRepository.deleteUnusedTenants(ttlForUnusedTenant, now).isEmpty()); - // Should be deleted - ttlForUnusedTenant = Duration.ofMillis(1); - assertEquals(tenant3, applicationRepository.deleteUnusedTenants(ttlForUnusedTenant, now).iterator().next()); - - // Delete app used by tenant1, tenant2 still has an application - applicationRepository.delete(applicationId()); - Set<TenantName> tenantsDeleted = applicationRepository.deleteUnusedTenants(Duration.ofMillis(1), now); - assertTrue(tenantsDeleted.contains(tenant1)); - assertFalse(tenantsDeleted.contains(tenant2)); - } - - @Test public void deleteUnusedFileReferences() throws IOException { File fileReferencesDir = temporaryFolder.newFolder(); @@ -372,7 +349,6 @@ public class ApplicationRepositoryTest { @Test public void testDeletingInactiveSessions() throws IOException { - ManualClock clock = new ManualClock(Instant.now()); ConfigserverConfig configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder() .configServerDBDir(temporaryFolder.newFolder("serverdb").getAbsolutePath()) @@ -455,7 +431,7 @@ public class ApplicationRepositoryTest { var prepareParams = new PrepareParams.Builder().applicationId(applicationId) .applicationRoles(ApplicationRoles.fromString("hostRole","containerRole")).build(); deployApp(testApp, prepareParams); - var approlesStore = new ApplicationRolesStore(tenant.getCurator(), tenant.getPath()); + var approlesStore = new ApplicationRolesStore(tenantRepository.getCurator(), tenant.getPath()); var appRoles = approlesStore.readApplicationRoles(applicationId); // App roles present after deploy diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java index c2489a1d3e9..4b37638cb50 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java @@ -10,15 +10,20 @@ import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.curator.Curator; import com.yahoo.vespa.curator.mock.MockCurator; +import java.time.Clock; + class MaintainerTester { private final Curator curator; private final TenantRepository tenantRepository; private final ApplicationRepository applicationRepository; - MaintainerTester() { + MaintainerTester(Clock clock) { curator = new MockCurator(); - GlobalComponentRegistry componentRegistry = new TestComponentRegistry.Builder().curator(curator).build(); + GlobalComponentRegistry componentRegistry = new TestComponentRegistry.Builder() + .curator(curator) + .clock(clock) + .build(); tenantRepository = new TenantRepository(componentRegistry, false); applicationRepository = new ApplicationRepository(tenantRepository, new SessionHandlerTest.MockProvisioner(), diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java index fdc6ffeacf0..53326a89293 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java @@ -5,6 +5,7 @@ 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.test.ManualClock; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.session.PrepareParams; import com.yahoo.vespa.config.server.tenant.TenantRepository; @@ -20,7 +21,8 @@ public class TenantsMaintainerTest { @Test public void deleteTenantWithNoApplications() { - MaintainerTester tester = new MaintainerTester(); + ManualClock clock = new ManualClock("2020-06-01T00:00:00"); + MaintainerTester tester = new MaintainerTester(clock); TenantRepository tenantRepository = tester.tenantRepository(); ApplicationRepository applicationRepository = tester.applicationRepository(); File applicationPackage = new File("src/test/apps/app"); @@ -36,7 +38,8 @@ public class TenantsMaintainerTest { assertNotNull(tenantRepository.getTenant(shouldBeDeleted)); assertNotNull(tenantRepository.getTenant(shouldNotBeDeleted)); - new TenantsMaintainer(applicationRepository, tester.curator(), Duration.ofDays(1)).run(); + clock.advance(TenantsMaintainer.defaultTtlForUnusedTenant.plus(Duration.ofDays(1))); + new TenantsMaintainer(applicationRepository, tester.curator(), Duration.ofDays(1), clock).run(); tenantRepository.updateTenants(); // One tenant should now have been deleted @@ -59,4 +62,5 @@ public class TenantsMaintainerTest { private ApplicationId applicationId(TenantName tenantName) { return ApplicationId.from(tenantName, ApplicationName.from("foo"), InstanceName.defaultName()); } + } 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 104b94b274f..8d0285ac12b 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 @@ -170,15 +170,10 @@ public class TenantRepositoryTest { public void testFailingBootstrap() throws IOException { tenantRepository.close(); // stop using the one setup in Before method - // No exception if config is false - boolean throwIfBootstrappingTenantRepoFails = false; - new FailingDuringBootstrapTenantRepository(createComponentRegistry(throwIfBootstrappingTenantRepoFails)); - // Should get exception if config is true - throwIfBootstrappingTenantRepoFails = true; expectedException.expect(RuntimeException.class); expectedException.expectMessage("Could not create all tenants when bootstrapping, failed to create: [default]"); - new FailingDuringBootstrapTenantRepository(createComponentRegistry(throwIfBootstrappingTenantRepoFails)); + new FailingDuringBootstrapTenantRepository(createComponentRegistry()); } private List<String> readZKChildren(String path) throws Exception { @@ -186,16 +181,16 @@ public class TenantRepositoryTest { } private void assertZooKeeperTenantPathExists(TenantName tenantName) throws Exception { - assertNotNull(globalComponentRegistry.getCurator().framework().checkExists().forPath(tenantRepository.tenantZkPath(tenantName))); + assertNotNull(globalComponentRegistry.getCurator().framework() + .checkExists().forPath(TenantRepository.getTenantPath(tenantName).getAbsolute())); } - private GlobalComponentRegistry createComponentRegistry(boolean throwIfBootstrappingTenantRepoFails) throws IOException { + private GlobalComponentRegistry createComponentRegistry() throws IOException { return new TestComponentRegistry.Builder() .curator(new MockCurator()) .configServerConfig(new ConfigserverConfig(new ConfigserverConfig.Builder() - .throwIfBootstrappingTenantRepoFails(throwIfBootstrappingTenantRepoFails) - .configDefinitionsDir(temporaryFolder.newFolder("configdefs" + throwIfBootstrappingTenantRepoFails).getAbsolutePath()) - .configServerDBDir(temporaryFolder.newFolder("configserverdb" + throwIfBootstrappingTenantRepoFails).getAbsolutePath()))) + .configDefinitionsDir(temporaryFolder.newFolder("configdefs").getAbsolutePath()) + .configServerDBDir(temporaryFolder.newFolder("configserverdb").getAbsolutePath()))) .zone(new Zone(SystemName.cd, Environment.prod, RegionName.from("foo"))) .build(); } @@ -207,7 +202,7 @@ public class TenantRepositoryTest { } @Override - public void createTenant(TenantName tenantName) { + public void bootstrapTenant(TenantName tenantName) { throw new RuntimeException("Failed to create: " + tenantName); } } |