Search in sources :

Example 1 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator in project vespa by vespa-engine.

the class ApplicationRepositoryTest method setup.

@Before
public void setup() {
    Curator curator = new MockCurator();
    Tenants tenants = new Tenants(new TestComponentRegistry.Builder().curator(curator).build());
    tenants.addTenant(tenantName);
    tenant = tenants.getTenant(tenantName);
    Provisioner provisioner = new SessionHandlerTest.MockProvisioner();
    applicationRepository = new ApplicationRepository(tenants, provisioner, clock);
    timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(60));
}
Also used : Provisioner(com.yahoo.config.provision.Provisioner) Tenants(com.yahoo.vespa.config.server.tenant.Tenants) Curator(com.yahoo.vespa.curator.Curator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 2 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator in project vespa by vespa-engine.

the class ApplicationHandlerTest method addApplication.

private static Tenants addApplication(ApplicationId applicationId, long sessionId) throws Exception {
    // This method is a good illustration of the spaghetti wiring resulting from no design
    // TODO: When this setup looks sane we have refactored sufficiently that there is a design
    TenantName tenantName = applicationId.tenant();
    Path tenantPath = Tenants.getTenantPath(tenantName);
    Path sessionPath = tenantPath.append(Tenant.SESSIONS).append(String.valueOf(sessionId));
    MockCurator curator = new MockCurator();
    GlobalComponentRegistry componentRegistry = new TestComponentRegistry.Builder().curator(curator).modelFactoryRegistry(new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())))).build();
    // Creates the application path element in zk
    Tenants tenants = new Tenants(componentRegistry);
    tenants.addTenant(tenantName);
    Tenant tenant = tenants.getTenant(tenantName);
    tenant.getApplicationRepo().createPutApplicationTransaction(applicationId, sessionId).commit();
    ApplicationPackage app = FilesApplicationPackage.fromFile(testApp);
    SessionZooKeeperClient sessionClient = new SessionZooKeeperClient(curator, sessionPath);
    SessionContext context = new SessionContext(app, sessionClient, new File("/serverDb"), tenant.getApplicationRepo(), null, new SuperModelGenerationCounter(curator));
    tenant.getLocalSessionRepo().addSession(new LocalSession(tenantName, sessionId, null, context));
    // TODO: Instead, use ApplicationRepository to deploy the application
    sessionClient.writeApplicationId(applicationId);
    tenant.getRemoteSessionRepo().addSession(new RemoteSession(tenantName, sessionId, componentRegistry, sessionClient, Clock.systemUTC()));
    return tenants;
}
Also used : Path(com.yahoo.path.Path) TenantName(com.yahoo.config.provision.TenantName) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) Tenants(com.yahoo.vespa.config.server.tenant.Tenants) GlobalComponentRegistry(com.yahoo.vespa.config.server.GlobalComponentRegistry) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TestComponentRegistry(com.yahoo.vespa.config.server.TestComponentRegistry) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) SessionContext(com.yahoo.vespa.config.server.session.SessionContext) SuperModelGenerationCounter(com.yahoo.vespa.config.server.SuperModelGenerationCounter) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) SessionZooKeeperClient(com.yahoo.vespa.config.server.session.SessionZooKeeperClient)

Example 3 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator in project vespa by vespa-engine.

the class SessionPrepareHandlerTest method setupRepo.

@Before
public void setupRepo() throws Exception {
    applicationRepo = new MemoryTenantApplications();
    curator = new MockCurator();
    localRepo = new LocalSessionRepo(Clock.systemUTC());
    pathPrefix = "/application/v2/tenant/" + tenant + "/session/";
    preparedMessage = " for tenant '" + tenant + "' prepared.\"";
    tenantMessage = ",\"tenant\":\"" + tenant + "\"";
    builder = new TestTenantBuilder();
}
Also used : MemoryTenantApplications(com.yahoo.vespa.config.server.application.MemoryTenantApplications) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Example 4 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator in project vespa by vespa-engine.

the class ZooKeeperDeployerTest method require_that_deployer_is_initialized.

@Test
public void require_that_deployer_is_initialized() throws IOException, ParseException {
    ConfigCurator zkfacade = ConfigCurator.create(new MockCurator());
    File serverdbDir = folder.newFolder("serverdb");
    File defsDir = new File(serverdbDir, "serverdefs");
    try {
        IOUtils.createWriter(new File(defsDir, defFile), true);
    } catch (IOException e) {
        e.printStackTrace();
        fail();
    }
    deploy(FilesApplicationPackage.fromFile(new File("src/test/apps/content")), zkfacade, Path.fromString("/1"));
    deploy(FilesApplicationPackage.fromFile(new File("src/test/apps/content")), zkfacade, Path.fromString("/2"));
}
Also used : ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) IOException(java.io.IOException) File(java.io.File) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Test(org.junit.Test)

Example 5 with MockCurator

use of com.yahoo.vespa.curator.mock.MockCurator in project vespa by vespa-engine.

the class InjectedGlobalComponentRegistryTest method setupRegistry.

@Before
public void setupRegistry() {
    curator = new MockCurator();
    ConfigCurator configCurator = ConfigCurator.create(curator);
    metrics = Metrics.createTestMetrics();
    modelFactoryRegistry = new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())));
    configserverConfig = new ConfigserverConfig(new ConfigserverConfig.Builder().configServerDBDir(Files.createTempDir().getAbsolutePath()).configDefinitionsDir(Files.createTempDir().getAbsolutePath()));
    serverDB = new ConfigServerDB(configserverConfig);
    sessionPreparer = new SessionTest.MockSessionPreparer();
    rpcServer = new RpcServer(configserverConfig, null, Metrics.createTestMetrics(), new HostRegistries(), new ConfigRequestHostLivenessTracker(), new FileServer(FileDistribution.getDefaultFileDBPath()));
    generationCounter = new SuperModelGenerationCounter(curator);
    defRepo = new StaticConfigDefinitionRepo();
    permanentApplicationPackage = new PermanentApplicationPackage(configserverConfig);
    hostRegistries = new HostRegistries();
    HostProvisionerProvider hostProvisionerProvider = HostProvisionerProvider.withProvisioner(new SessionHandlerTest.MockProvisioner());
    zone = Zone.defaultZone();
    globalComponentRegistry = new InjectedGlobalComponentRegistry(curator, configCurator, metrics, modelFactoryRegistry, serverDB, sessionPreparer, rpcServer, configserverConfig, generationCounter, defRepo, permanentApplicationPackage, hostRegistries, hostProvisionerProvider, zone);
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) HostRegistries(com.yahoo.vespa.config.server.host.HostRegistries) HostProvisionerProvider(com.yahoo.vespa.config.server.provision.HostProvisionerProvider) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) ConfigRequestHostLivenessTracker(com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker) VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) RpcServer(com.yahoo.vespa.config.server.rpc.RpcServer) PermanentApplicationPackage(com.yahoo.vespa.config.server.application.PermanentApplicationPackage) FileServer(com.yahoo.vespa.config.server.filedistribution.FileServer) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) Before(org.junit.Before)

Aggregations

MockCurator (com.yahoo.vespa.curator.mock.MockCurator)29 Test (org.junit.Test)16 Before (org.junit.Before)11 Curator (com.yahoo.vespa.curator.Curator)6 ConfigCurator (com.yahoo.vespa.config.server.zookeeper.ConfigCurator)5 MockNameResolver (com.yahoo.vespa.hosted.provision.testutils.MockNameResolver)5 DockerImage (com.yahoo.config.provision.DockerImage)4 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)4 File (java.io.File)4 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)3 NodeFlavors (com.yahoo.config.provision.NodeFlavors)3 Zone (com.yahoo.config.provision.Zone)3 Path (com.yahoo.path.Path)3 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)3 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)3 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)2 ManualClock (com.yahoo.test.ManualClock)2 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)2 MemoryTenantApplications (com.yahoo.vespa.config.server.application.MemoryTenantApplications)2 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)2