Search in sources :

Example 1 with ModelFactoryRegistry

use of com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry in project vespa by vespa-engine.

the class ModelFactoryRegistryTest method testThatLatestVersionIsSelected.

@Test
public void testThatLatestVersionIsSelected() {
    Version versionA = Version.fromIntValues(5, 38, 4);
    Version versionB = Version.fromIntValues(5, 58, 1);
    Version versionC = Version.fromIntValues(5, 48, 44);
    Version versionD = Version.fromIntValues(5, 18, 44);
    TestFactory a = new TestFactory(versionA);
    TestFactory b = new TestFactory(versionB);
    TestFactory c = new TestFactory(versionC);
    TestFactory d = new TestFactory(versionD);
    for (int i = 0; i < 100; i++) {
        List<ModelFactory> randomOrder = Arrays.asList(a, b, c, d);
        Collections.shuffle(randomOrder);
        ModelFactoryRegistry registry = new ModelFactoryRegistry(randomOrder);
        assertThat(registry.getFactory(versionA), is(a));
        assertThat(registry.getFactory(versionB), is(b));
        assertThat(registry.getFactory(versionC), is(c));
        assertThat(registry.getFactory(versionD), is(d));
    }
}
Also used : Version(com.yahoo.config.provision.Version) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) ModelFactory(com.yahoo.config.model.api.ModelFactory) Test(org.junit.Test)

Example 2 with ModelFactoryRegistry

use of com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry 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 ModelFactoryRegistry

use of com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry in project vespa by vespa-engine.

the class ApplicationHandlerTest method addMockApplication.

static void addMockApplication(Tenant tenant, ApplicationId applicationId, long sessionId, Clock clock) {
    tenant.getApplicationRepo().createPutApplicationTransaction(applicationId, sessionId).commit();
    ApplicationPackage app = FilesApplicationPackage.fromFile(testApp);
    tenant.getLocalSessionRepo().addSession(new SessionHandlerTest.MockSession(sessionId, app, applicationId));
    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), clock));
}
Also used : VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) MockSessionZKClient(com.yahoo.vespa.config.server.session.MockSessionZKClient) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) TestComponentRegistry(com.yahoo.vespa.config.server.TestComponentRegistry) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage)

Example 4 with ModelFactoryRegistry

use of com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry in project vespa by vespa-engine.

the class SessionPreparerTest method require_that_prepare_fails_if_older_version_fails.

@Test(expected = InvalidApplicationException.class)
public void require_that_prepare_fails_if_older_version_fails() throws IOException {
    ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(Arrays.asList(new TestModelFactory(Version.fromIntValues(3, 2, 3)), new FailingModelFactory(Version.fromIntValues(1, 2, 1), new IllegalArgumentException("BOOHOO"))));
    preparer = createPreparer(modelFactoryRegistry, HostProvisionerProvider.empty());
    preparer.prepare(getContext(getApplicationPackage(testApp)), getLogger(), new PrepareParams.Builder().build(), Optional.empty(), tenantPath, Instant.now());
}
Also used : ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) TestModelFactory(com.yahoo.vespa.config.server.model.TestModelFactory) Test(org.junit.Test)

Example 5 with ModelFactoryRegistry

use of com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry 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

ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)13 Test (org.junit.Test)7 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)5 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)4 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)4 TestModelFactory (com.yahoo.vespa.config.server.model.TestModelFactory)3 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)3 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 Version (com.yahoo.config.provision.Version)2 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)2 RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)2 File (java.io.File)2 Before (org.junit.Before)2 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)1 ModelContext (com.yahoo.config.model.api.ModelContext)1 ModelFactory (com.yahoo.config.model.api.ModelFactory)1 ServiceInfo (com.yahoo.config.model.api.ServiceInfo)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Rotation (com.yahoo.config.provision.Rotation)1