diff options
author | Harald Musum <musum@yahoo-inc.com> | 2016-12-06 13:20:59 +0100 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2016-12-06 13:20:59 +0100 |
commit | b8720b9052fd5bb66efc6dd5b98adaf013720959 (patch) | |
tree | 3644992d18ae8cdb56a6a6c8c272f0af8d48bf76 /configserver | |
parent | 5ad834e539b0a330aaa1137138926779e23fcdde (diff) |
Use builder pattern for constructing TestComponentRegistry
Diffstat (limited to 'configserver')
17 files changed, 138 insertions, 71 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java index 8ed80ac2339..1f2386d0342 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/PrepareParams.java @@ -40,7 +40,7 @@ public final class PrepareParams { private final Set<Rotation> rotations; private final Optional<Version> dockerVespaImageVersion; - public PrepareParams(ApplicationId applicationId, TimeoutBudget timeoutBudget, boolean ignoreValidationErrors, + private PrepareParams(ApplicationId applicationId, TimeoutBudget timeoutBudget, boolean ignoreValidationErrors, boolean dryRun, Optional<Version> vespaVersion, Set<Rotation> rotations, Optional<Version> dockerVespaImageVersion) { this.timeoutBudget = timeoutBudget; 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 d3092b94de4..4dc0729577c 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 @@ -30,7 +30,6 @@ import java.util.Optional; * @author lulf * @since 5.1 */ -// TODO Use a Builder to avoid so many constructors public class TestComponentRegistry implements GlobalComponentRegistry { private final Curator curator; @@ -41,60 +40,102 @@ public class TestComponentRegistry implements GlobalComponentRegistry { private final ConfigserverConfig configserverConfig; private final SuperModelGenerationCounter superModelGenerationCounter; private final ConfigDefinitionRepo defRepo; - final TenantRequestHandlerTest.MockReloadListener reloadListener; - final MockTenantListener tenantListener; + private final ReloadListener reloadListener; + private final TenantListener tenantListener; private final PermanentApplicationPackage permanentApplicationPackage; private final HostRegistries hostRegistries; private final FileDistributionFactory fileDistributionFactory; private final ModelFactoryRegistry modelFactoryRegistry; private final Optional<Provisioner> hostProvisioner; - public TestComponentRegistry() { this(new MockCurator()); } - - public TestComponentRegistry(Curator curator) { - this(curator, ConfigCurator.create(curator), new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))); - } - - public TestComponentRegistry(Curator curator, ConfigCurator configCurator, FileDistributionFactory fileDistributionFactory) { - this(curator, configCurator, new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry()))), fileDistributionFactory); - } - - public TestComponentRegistry(Curator curator, ModelFactoryRegistry modelFactoryRegistry) { - this(curator, ConfigCurator.create(curator), modelFactoryRegistry, Optional.empty()); - } - - public TestComponentRegistry(Curator curator, ConfigCurator configCurator, ModelFactoryRegistry modelFactoryRegistry) { - this(curator, configCurator, modelFactoryRegistry, Optional.empty()); - } - - public TestComponentRegistry(Curator curator, ConfigCurator configCurator, ModelFactoryRegistry modelFactoryRegistry, FileDistributionFactory fileDistributionFactory) { - this(curator, configCurator, modelFactoryRegistry, Optional.empty(), fileDistributionFactory); - } - - public TestComponentRegistry(Curator curator, ModelFactoryRegistry modelFactoryRegistry, Optional<PermanentApplicationPackage> permanentApplicationPackage) { - this(curator, ConfigCurator.create(curator), modelFactoryRegistry, permanentApplicationPackage, new MockFileDistributionFactory()); - } - - public TestComponentRegistry(Curator curator, ConfigCurator configCurator, ModelFactoryRegistry modelFactoryRegistry, Optional<PermanentApplicationPackage> permanentApplicationPackage) { - this(curator, configCurator, modelFactoryRegistry, permanentApplicationPackage, new MockFileDistributionFactory()); - } - - public TestComponentRegistry(Curator curator, ConfigCurator configCurator, ModelFactoryRegistry modelFactoryRegistry, Optional<PermanentApplicationPackage> permanentApplicationPackage, FileDistributionFactory fileDistributionFactory) { + private TestComponentRegistry(Curator curator, ConfigCurator configCurator, Metrics metrics, + ModelFactoryRegistry modelFactoryRegistry, + PermanentApplicationPackage permanentApplicationPackage, + FileDistributionFactory fileDistributionFactory, + SuperModelGenerationCounter superModelGenerationCounter, + ConfigServerDB configServerDB, + HostRegistries hostRegistries, + ConfigserverConfig configserverConfig, + SessionPreparer sessionPreparer, + Optional<Provisioner> hostProvisioner, + ConfigDefinitionRepo defRepo, + ReloadListener reloadListener, + TenantListener tenantListener) { this.curator = curator; this.configCurator = configCurator; - metrics = Metrics.createTestMetrics(); - configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder().configServerDBDir(Files.createTempDir().getAbsolutePath())); - serverDB = new ConfigServerDB(configserverConfig); - reloadListener = new TenantRequestHandlerTest.MockReloadListener(); - tenantListener = new MockTenantListener(); - this.superModelGenerationCounter = new SuperModelGenerationCounter(curator); - this.defRepo = new StaticConfigDefinitionRepo(); - this.permanentApplicationPackage = permanentApplicationPackage.orElse(new PermanentApplicationPackage(configserverConfig)); - this.hostRegistries = new HostRegistries(); + this.metrics = metrics; + this.configserverConfig = configserverConfig; + this.serverDB = configServerDB; + this.reloadListener = reloadListener; + this.tenantListener = tenantListener; + this.superModelGenerationCounter = superModelGenerationCounter; + this.defRepo = defRepo; + this.permanentApplicationPackage = permanentApplicationPackage; + this.hostRegistries = hostRegistries; this.fileDistributionFactory = fileDistributionFactory; this.modelFactoryRegistry = modelFactoryRegistry; - this.hostProvisioner = Optional.empty(); - sessionPreparer = new SessionPreparer(modelFactoryRegistry, fileDistributionFactory, HostProvisionerProvider.empty(), this.permanentApplicationPackage, configserverConfig, defRepo, curator, new Zone(configserverConfig)); + this.hostProvisioner = hostProvisioner; + this.sessionPreparer = sessionPreparer; + } + + public static class Builder { + + private Curator curator = new MockCurator(); + private Optional<ConfigCurator> configCurator = Optional.empty(); + private Metrics metrics = Metrics.createTestMetrics();; + private ConfigserverConfig configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder() + .configServerDBDir(Files.createTempDir() + .getAbsolutePath()));; + private ConfigDefinitionRepo defRepo = new StaticConfigDefinitionRepo(); + private TenantRequestHandlerTest.MockReloadListener reloadListener = new TenantRequestHandlerTest.MockReloadListener(); + private MockTenantListener tenantListener = new MockTenantListener(); + private Optional<PermanentApplicationPackage> permanentApplicationPackage = Optional.empty(); + private HostRegistries hostRegistries = new HostRegistries(); + private FileDistributionFactory fileDistributionFactory = new MockFileDistributionFactory(); + private ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry()))); + private Optional<Provisioner> hostProvisioner = Optional.empty(); + + + public Builder curator(Curator curator) { + this.curator = curator; + return this; + } + + public Builder configCurator(ConfigCurator configCurator) { + this.configCurator = Optional.ofNullable(configCurator); + return this; + } + + public Builder metrics(Metrics metrics) { + this.metrics = metrics; + return this; + } + + public Builder modelFactoryRegistry(ModelFactoryRegistry modelFactoryRegistry) { + this.modelFactoryRegistry = modelFactoryRegistry; + return this; + } + + public Builder permanentApplicationPackage(Optional<PermanentApplicationPackage> permanentApplicationPackage) { + this.permanentApplicationPackage = permanentApplicationPackage; + return this; + } + + public TestComponentRegistry build() { + final PermanentApplicationPackage permApp = this.permanentApplicationPackage + .orElse(new PermanentApplicationPackage(configserverConfig)); + SessionPreparer sessionPreparer = new SessionPreparer(modelFactoryRegistry, fileDistributionFactory, + HostProvisionerProvider.empty(), permApp, + configserverConfig, defRepo, curator, new Zone(configserverConfig)); + return new TestComponentRegistry(curator, configCurator.orElse(ConfigCurator.create(curator)), + metrics, modelFactoryRegistry, + permApp, + new MockFileDistributionFactory(), + new SuperModelGenerationCounter(curator), + new ConfigServerDB(configserverConfig), + hostRegistries, configserverConfig, sessionPreparer, + hostProvisioner, defRepo, reloadListener, tenantListener); + } } @Override diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java index caaf90a0f04..783ce4a5eda 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java @@ -73,7 +73,13 @@ public class DeployTester { this.curator = new MockCurator(); this.testApp = new File(appPath); ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(modelFactories); - this.tenants = new Tenants(new TestComponentRegistry(curator, modelFactoryRegistry), Metrics.createTestMetrics()); + final Metrics metrics = Metrics.createTestMetrics(); + this.tenants = new Tenants(new TestComponentRegistry.Builder() + .curator(curator) + .modelFactoryRegistry(modelFactoryRegistry) + .metrics(metrics) + .build(), + metrics); } catch (Exception e) { throw new IllegalArgumentException(e); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionActiveHandlerTestBase.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionActiveHandlerTestBase.java index 3d1f9b5766a..4f551339983 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionActiveHandlerTestBase.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionActiveHandlerTestBase.java @@ -151,7 +151,12 @@ public abstract class SessionActiveHandlerTestBase extends SessionHandlerTest { VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry()); zkC.feedZKFileRegistries(Collections.singletonMap(modelFactory.getVersion(), new MockFileRegistry())); zkC.feedProvisionInfos(Collections.singletonMap(modelFactory.getVersion(), ProvisionInfo.withHosts(Collections.emptySet()))); - RemoteSession session = new RemoteSession(TenantName.from("default"), sessionId, new TestComponentRegistry(curator, configCurator, new ModelFactoryRegistry(Collections.singletonList(modelFactory))), zkClient); + TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder() + .curator(curator) + .configCurator(configCurator) + .modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(modelFactory))) + .build(); + RemoteSession session = new RemoteSession(TenantName.from("default"), sessionId, componentRegistry, zkClient); remoteSessionRepo.addSession(session); return session; } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionPrepareHandlerTestBase.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionPrepareHandlerTestBase.java index 85eae0c91cc..c5c0e53871d 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionPrepareHandlerTestBase.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionPrepareHandlerTestBase.java @@ -104,7 +104,7 @@ public abstract class SessionPrepareHandlerTestBase extends SessionHandlerTest { zooKeeperClient = new MockSessionZKClient(curator, pathProvider.getSessionDirs().append(String.valueOf(ls.getSessionId()))); if (ls.getStatus()!=null) zooKeeperClient.writeStatus(ls.getStatus()); RemoteSession remSess = new RemoteSession(TenantName.from("default"), ls.getSessionId(), - new TestComponentRegistry(), + new TestComponentRegistry.Builder().curator(curator).build(), zooKeeperClient); remoteRepo.addSession(remSess); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java index f8071721989..19674834719 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java @@ -239,9 +239,10 @@ public class ApplicationHandlerTest { tenant.getApplicationRepo().createPutApplicationTransaction(applicationId, sessionId).commit(); ApplicationPackage app = FilesApplicationPackage.fromFile(testApp); tenant.getLocalSessionRepo().addSession(new SessionHandlerTest.MockSession(sessionId, app, applicationId)); - tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenant.getName(), sessionId, - new TestComponentRegistry(new MockCurator(), - new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))), new MockSessionZKClient(app))); + TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder() + .modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))) + .build(); + tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenant.getName(), sessionId, componentRegistry, new MockSessionZKClient(app))); } static Tenants addApplication(ApplicationId applicationId, long sessionId) throws Exception { @@ -254,7 +255,7 @@ public class ApplicationHandlerTest { Path sessionPath = tenantPath.append(Tenant.SESSIONS).append(String.valueOf(sessionId)); MockCurator curator = new MockCurator(); - GlobalComponentRegistry globalComponents = new TestComponentRegistry(curator); + GlobalComponentRegistry globalComponents = new TestComponentRegistry.Builder().curator(curator).build(); Tenants tenants = new Tenants(globalComponents, Metrics.createTestMetrics()); // Creates the application path element in zk tenants.writeTenantPath(tenantName); @@ -280,10 +281,14 @@ public class ApplicationHandlerTest { tenant.getLocalSessionRepo().addSession(new LocalSession(tenantName, sessionId, null, context)); sessionClient.writeApplicationId(applicationId); // TODO: Instead, use ApplicationRepository to deploy the application - tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenantName, sessionId, - new TestComponentRegistry(curator, - new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))), - sessionClient)); + tenant.getRemoteSessionRepo().addSession( + new RemoteSession(tenantName, sessionId, + new TestComponentRegistry.Builder() + .curator(curator) + .modelFactoryRegistry(new ModelFactoryRegistry( + Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))) + .build(), + sessionClient)); return tenants; } 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 5ec09f1478f..4ed87dd5d81 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 @@ -47,7 +47,7 @@ public class HostHandlerTest { private HostHandler createHostHandler() { final HostRegistry<TenantName> hostRegistry = new HostRegistry<>(); hostRegistry.update(mytenant, Collections.singletonList(hostname)); - TestComponentRegistry testComponentRegistry = new TestComponentRegistry(); + TestComponentRegistry testComponentRegistry = new TestComponentRegistry.Builder().build(); hostRegistries = testComponentRegistry.getHostRegistries(); hostRegistries.createApplicationHostRegistry(mytenant).update(ApplicationId.from(mytenant, ApplicationName.defaultName(), InstanceName.defaultName()), Collections.singletonList(hostname)); hostRegistries.getTenantHostRegistry().update(mytenant, Collections.singletonList(hostname)); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java index e6b3a86ebb0..754969bda68 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantTest.java @@ -35,7 +35,7 @@ public class TenantTest extends TestWithCurator { } protected Tenants createTenants() throws Exception { - return new Tenants(new TestComponentRegistry(curator), Metrics.createTestMetrics()); + return new Tenants(new TestComponentRegistry.Builder().curator(curator).build(), Metrics.createTestMetrics()); } protected Executor testExecutor() { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java index a2b69f96406..92ac2ccc480 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java @@ -14,7 +14,6 @@ import com.yahoo.vespa.config.server.session.RemoteSessionRepo; import com.yahoo.vespa.config.server.tenant.Tenant; import com.yahoo.vespa.config.server.tenant.TenantBuilder; import com.yahoo.vespa.config.server.tenant.Tenants; -import com.yahoo.vespa.curator.mock.MockCurator; import java.util.*; @@ -30,7 +29,7 @@ public class TestTenantBuilder { private Map<TenantName, TenantBuilder> tenantMap = new HashMap<>(); public TestTenantBuilder() throws Exception { - componentRegistry = new TestComponentRegistry(new MockCurator()); + componentRegistry = new TestComponentRegistry.Builder().build(); } public TenantBuilder createTenant(TenantName tenantName) { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/restapi/impl/StatusResourceTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/restapi/impl/StatusResourceTest.java index 333cac4fd48..a6e5b35125e 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/restapi/impl/StatusResourceTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/restapi/impl/StatusResourceTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertThat; public class StatusResourceTest { @Test public void require_that_status_handler_responds_to_ping() throws IOException { - StatusResource handler = new StatusResource(null, null, null, null, null, null, null, new TestComponentRegistry()); + StatusResource handler = new StatusResource(null, null, null, null, null, null, null, new TestComponentRegistry.Builder().build()); assertNotNull(handler.getStatus().configserverConfig); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java index 0971d37c5d6..67a06707ffa 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java @@ -41,7 +41,7 @@ public class LocalSessionRepoTest extends TestWithCurator { } private void setupSessions(TenantName tenantName, boolean createInitialSessions) throws Exception { - GlobalComponentRegistry globalComponentRegistry = new TestComponentRegistry(curator); + GlobalComponentRegistry globalComponentRegistry = new TestComponentRegistry.Builder().curator(curator).build(); TenantFileSystemDirs tenantFileSystemDirs = TenantFileSystemDirs.createTestDirs(tenantName); if (createInitialSessions) { IOUtils.copyDirectory(testApp, new File(tenantFileSystemDirs.path(), "1")); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java index 68c8bffa823..1f65d92d305 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java @@ -40,7 +40,9 @@ public class RemoteSessionRepoTest extends TestWithCurator { createSession(3l, false); curator.create(Path.fromString("/applications")); curator.create(Path.fromString("/sessions")); - Tenant tenant = TenantBuilder.create(new TestComponentRegistry(curator), TenantName.defaultName(), Path.createRoot()).build(); + Tenant tenant = TenantBuilder.create(new TestComponentRegistry.Builder().curator(curator).build(), + TenantName.defaultName(), + Path.createRoot()).build(); this.remoteSessionRepo = tenant.getRemoteSessionRepo(); } @@ -89,7 +91,9 @@ public class RemoteSessionRepoTest extends TestWithCurator { public void testBadApplicationRepoOnActivate() throws Exception { TenantApplications applicationRepo = new FailingTenantApplications(); curator.framework().create().forPath("/mytenant"); - Tenant tenant = TenantBuilder.create(new TestComponentRegistry(curator), TenantName.from("mytenant"), Path.fromString("mytenant")) + Tenant tenant = TenantBuilder.create(new TestComponentRegistry.Builder().curator(curator).build(), + TenantName.from("mytenant"), + Path.fromString("mytenant")) .withApplicationRepo(applicationRepo) .build(); remoteSessionRepo = tenant.getRemoteSessionRepo(); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java index ad192a895b9..87cd23f4362 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionTest.java @@ -229,7 +229,13 @@ public class RemoteSessionTest { private RemoteSession createSession(long sessionId, SessionZooKeeperClient zkc, List<ModelFactory> modelFactories, Optional<PermanentApplicationPackage> permanentApplicationPackage) { zkc.writeStatus(Session.Status.NEW); zkc.writeApplicationId(new ApplicationId.Builder().applicationName("foo").instanceName("bim").build()); - return new RemoteSession(TenantName.from("default"), sessionId, new TestComponentRegistry(curator, new ModelFactoryRegistry(modelFactories), permanentApplicationPackage), zkc); + return new RemoteSession(TenantName.from("default"), sessionId, + new TestComponentRegistry.Builder() + .curator(curator) + .modelFactoryRegistry(new ModelFactoryRegistry(modelFactories)) + .permanentApplicationPackage(permanentApplicationPackage) + .build(), + zkc); } private class MockModelFactory implements ModelFactory { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java index 12cb5749daa..ac25cba3b47 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java @@ -67,7 +67,7 @@ public class SessionPreparerTest extends TestWithCurator { @Before public void setUp() throws Exception { - componentRegistry = new TestComponentRegistry(curator); + componentRegistry = new TestComponentRegistry.Builder().curator(curator).build(); fileDistributionFactory = (MockFileDistributionFactory)componentRegistry.getFileDistributionFactory(); preparer = createPreparer(); } 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 f5d67279bbf..fc0dc52dc01 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 @@ -77,7 +77,7 @@ public class TenantRequestHandlerTest extends TestWithCurator { List<ReloadListener> listeners = new ArrayList<>(); listeners.add(listener); server = new TenantRequestHandler(sh, tenant, listeners, new UncompressedConfigResponseFactory(), new HostRegistries()); - componentRegistry = new TestComponentRegistry(curator, configCurator, createRegistry()); + componentRegistry = new TestComponentRegistry.Builder().curator(curator).modelFactoryRegistry(createRegistry()).build(); } private void feedApp(File appDir, long sessionId) throws IOException { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantsTestCase.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantsTestCase.java index 603b5798da6..767956d7dd3 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantsTestCase.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantsTestCase.java @@ -48,7 +48,7 @@ public class TenantsTestCase extends TestWithCurator { @Before public void setupSessions() throws Exception { - globalComponentRegistry = new TestComponentRegistry(curator); + globalComponentRegistry = new TestComponentRegistry.Builder().curator(curator).build(); listener = (TenantRequestHandlerTest.MockReloadListener)globalComponentRegistry.getReloadListener(); tenantListener = (MockTenantListener)globalComponentRegistry.getTenantListener(); tenantListener.tenantsLoaded = false; @@ -150,7 +150,7 @@ public class TenantsTestCase extends TestWithCurator { @Test public void testTenantWatching() throws Exception { - TestComponentRegistry reg = new TestComponentRegistry(curator); + TestComponentRegistry reg = new TestComponentRegistry.Builder().curator(curator).build(); Tenants t = new Tenants(reg, Metrics.createTestMetrics()); try { assertEquals(t.tenantsCopy().get(TenantName.defaultName()).getName(), TenantName.defaultName()); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestWithTenant.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestWithTenant.java index bb13aee5b97..7cede0d94bc 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestWithTenant.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TestWithTenant.java @@ -19,7 +19,8 @@ public class TestWithTenant extends TestWithCurator { @Before public void setupTenant() throws Exception { - tenants = new Tenants(new TestComponentRegistry(curator), Metrics.createTestMetrics()); + final Metrics metrics = Metrics.createTestMetrics(); + tenants = new Tenants(new TestComponentRegistry.Builder().curator(curator).metrics(metrics).build(), metrics); tenant = tenants.defaultTenant(); } |