Search in sources :

Example 11 with NullConfigModelRegistry

use of com.yahoo.config.model.NullConfigModelRegistry 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 12 with NullConfigModelRegistry

use of com.yahoo.config.model.NullConfigModelRegistry 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 13 with NullConfigModelRegistry

use of com.yahoo.config.model.NullConfigModelRegistry 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)

Example 14 with NullConfigModelRegistry

use of com.yahoo.config.model.NullConfigModelRegistry in project vespa by vespa-engine.

the class ContainerModelBuilderTest method fail_if_http_port_is_not_4080_in_hosted_vespa.

@Test
public void fail_if_http_port_is_not_4080_in_hosted_vespa() throws Exception {
    String servicesXml = "<services>" + "<admin version='3.0'>" + "    <nodes count='1'/>" + "</admin>" + "<jdisc version='1.0'>" + "  <http>" + "    <server port='9000' id='foo' />" + "  </http>" + nodesXml + "</jdisc>" + "</services>";
    ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
    // Need to create VespaModel to make deploy properties have effect
    final MyLogger logger = new MyLogger();
    new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().applicationPackage(applicationPackage).deployLogger(logger).properties(new DeployProperties.Builder().hostedVespa(true).build()).build(true));
    assertFalse(logger.msgs.isEmpty());
    assertThat(logger.msgs.get(0).getSecond(), containsString(String.format("You cannot set port to anything else than %d", Container.BASEPORT)));
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) VespaModel(com.yahoo.vespa.model.VespaModel) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 15 with NullConfigModelRegistry

use of com.yahoo.config.model.NullConfigModelRegistry in project vespa by vespa-engine.

the class ContainerModelBuilderTest method vip_status_handler_uses_file_for_hosted_vespa.

@Test
public void vip_status_handler_uses_file_for_hosted_vespa() throws Exception {
    String servicesXml = "<services>" + "<jdisc version='1.0'>" + nodesXml + "</jdisc>" + "</services>";
    ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
    VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().applicationPackage(applicationPackage).properties(new DeployProperties.Builder().hostedVespa(true).build()).build(true));
    AbstractConfigProducerRoot modelRoot = model.getRoot();
    VipStatusConfig vipStatusConfig = modelRoot.getConfig(VipStatusConfig.class, "jdisc/component/status.html-status-handler");
    assertTrue(vipStatusConfig.accessdisk());
    assertEquals(ContainerModelBuilder.HOSTED_VESPA_STATUS_FILE, vipStatusConfig.statusfile());
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) AbstractConfigProducerRoot(com.yahoo.config.model.producer.AbstractConfigProducerRoot) VespaModel(com.yahoo.vespa.model.VespaModel) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) Matchers.containsString(org.hamcrest.Matchers.containsString) VipStatusConfig(com.yahoo.container.core.VipStatusConfig) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Aggregations

NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)25 Test (org.junit.Test)21 VespaModel (com.yahoo.vespa.model.VespaModel)15 DeployState (com.yahoo.config.model.deploy.DeployState)13 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)11 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)9 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)5 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)5 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 MockModelContext (com.yahoo.config.model.MockModelContext)3 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)3 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)3 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)3 Model (com.yahoo.config.model.api.Model)2 ModelCreateResult (com.yahoo.config.model.api.ModelCreateResult)2 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)2 TenantName (com.yahoo.config.provision.TenantName)2 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)2 RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)2