Search in sources :

Example 11 with ModelFactoryRegistry

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

the class SessionPreparerTest method require_that_prepare_succeeds_if_newer_version_fails.

@Test
public void require_that_prepare_succeeds_if_newer_version_fails() throws IOException {
    ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(Arrays.asList(new TestModelFactory(Version.fromIntValues(1, 2, 3)), new FailingModelFactory(Version.fromIntValues(3, 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 12 with ModelFactoryRegistry

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

the class SessionPreparerTest method require_that_config_change_actions_are_collected_from_all_models.

@Test
public void require_that_config_change_actions_are_collected_from_all_models() throws IOException {
    ServiceInfo service = new ServiceInfo("serviceName", "serviceType", null, new HashMap<>(), "configId", "hostName");
    ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(Arrays.asList(new ConfigChangeActionsModelFactory(Version.fromIntValues(1, 2, 3), new MockRestartAction("change", Arrays.asList(service))), new ConfigChangeActionsModelFactory(Version.fromIntValues(1, 2, 4), new MockRestartAction("other change", Arrays.asList(service)))));
    preparer = createPreparer(modelFactoryRegistry, HostProvisionerProvider.empty());
    List<RestartActions.Entry> actions = preparer.prepare(getContext(getApplicationPackage(testApp)), getLogger(), new PrepareParams.Builder().build(), Optional.empty(), tenantPath, Instant.now()).getRestartActions().getEntries();
    assertThat(actions.size(), is(1));
    assertThat(actions.get(0).getMessages(), equalTo(ImmutableSet.of("change", "other change")));
}
Also used : ServiceInfo(com.yahoo.config.model.api.ServiceInfo) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) MockRestartAction(com.yahoo.vespa.config.server.configchange.MockRestartAction) Test(org.junit.Test)

Example 13 with ModelFactoryRegistry

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

the class SessionPreparerTest method require_that_rotations_are_read_from_zookeeper_and_used.

@Test
public void require_that_rotations_are_read_from_zookeeper_and_used() throws IOException {
    final Version vespaVersion = Version.fromIntValues(1, 2, 3);
    final TestModelFactory modelFactory = new TestModelFactory(vespaVersion);
    preparer = createPreparer(new ModelFactoryRegistry(Arrays.asList(modelFactory)), HostProvisionerProvider.empty());
    final String rotations = "foo.msbe.global.vespa.yahooapis.com";
    final ApplicationId applicationId = applicationId("test");
    new Rotations(curator, tenantPath).writeRotationsToZooKeeper(applicationId, Collections.singleton(new Rotation(rotations)));
    final PrepareParams params = new PrepareParams.Builder().applicationId(applicationId).build();
    final File app = new File("src/test/resources/deploy/app");
    preparer.prepare(getContext(getApplicationPackage(app)), getLogger(), params, Optional.empty(), tenantPath, Instant.now());
    // check that the rotation from zookeeper were used
    final ModelContext modelContext = modelFactory.getModelContext();
    final Set<Rotation> rotationSet = modelContext.properties().rotations();
    assertThat(rotationSet, contains(new Rotation(rotations)));
    // Check that the persisted value is still the same
    assertThat(readRotationsFromZK(applicationId), contains(new Rotation(rotations)));
}
Also used : ModelContext(com.yahoo.config.model.api.ModelContext) Version(com.yahoo.config.provision.Version) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) TestModelFactory(com.yahoo.vespa.config.server.model.TestModelFactory) ApplicationId(com.yahoo.config.provision.ApplicationId) Rotation(com.yahoo.config.provision.Rotation) File(java.io.File) Rotations(com.yahoo.vespa.config.server.tenant.Rotations) Test(org.junit.Test)

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