Search in sources :

Example 1 with ModelFactory

use of com.yahoo.config.model.api.ModelFactory 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 ModelFactory

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

the class HostedDeployTest method testRedeployAfterExpiredValidationOverride.

@Test
public void testRedeployAfterExpiredValidationOverride() {
    // Old version of model fails, but application disables loading old models until 2016-10-10, so deployment works
    ManualClock clock = new ManualClock("2016-10-09T00:00:00");
    List<ModelFactory> modelFactories = new ArrayList<>();
    modelFactories.add(DeployTester.createModelFactory(clock));
    // older than default
    modelFactories.add(DeployTester.createFailingModelFactory(Version.fromIntValues(1, 0, 0)));
    DeployTester tester = new DeployTester("src/test/apps/validationOverride/", modelFactories, createConfigserverConfig());
    tester.deployApp("myApp", clock.instant());
    // Redeployment from local active works
    {
        Optional<com.yahoo.config.provision.Deployment> deployment = tester.redeployFromLocalActive();
        assertTrue(deployment.isPresent());
        deployment.get().prepare();
        deployment.get().activate();
    }
    // validation override expires
    clock.advance(Duration.ofDays(2));
    // Redeployment from local active also works after the validation override expires
    {
        Optional<com.yahoo.config.provision.Deployment> deployment = tester.redeployFromLocalActive();
        assertTrue(deployment.isPresent());
        deployment.get().prepare();
        deployment.get().activate();
    }
    // However, redeployment from the outside fails after this date
    {
        try {
            tester.deployApp("myApp", Instant.now());
            fail("Expected redeployment to fail");
        } catch (Exception expected) {
        // success
        }
    }
}
Also used : ManualClock(com.yahoo.test.ManualClock) Optional(java.util.Optional) ArrayList(java.util.ArrayList) ModelFactory(com.yahoo.config.model.api.ModelFactory) Test(org.junit.Test)

Example 3 with ModelFactory

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

the class RedeployTest method testNoRedeploy.

/**
 * No deployment is done because there is no local active session.
 */
@Test
public void testNoRedeploy() {
    List<ModelFactory> modelFactories = new ArrayList<>();
    modelFactories.add(DeployTester.createModelFactory(Clock.systemUTC()));
    modelFactories.add(DeployTester.createFailingModelFactory(Version.fromIntValues(1, 0, 0)));
    DeployTester tester = new DeployTester("ignored/app/path", modelFactories);
    ApplicationId id = ApplicationId.from(tester.tenant().getName(), ApplicationName.from("default"), InstanceName.from("default"));
    assertFalse(tester.redeployFromLocalActive(id).isPresent());
}
Also used : ArrayList(java.util.ArrayList) ModelFactory(com.yahoo.config.model.api.ModelFactory) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 4 with ModelFactory

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

the class HostedDeployTest method testDeployMultipleVersions.

@Test
public void testDeployMultipleVersions() {
    ManualClock clock = new ManualClock("2016-10-09T00:00:00");
    List<ModelFactory> modelFactories = new ArrayList<>();
    modelFactories.add(DeployTester.createModelFactory(Version.fromString("6.1.0"), clock));
    modelFactories.add(DeployTester.createModelFactory(Version.fromString("6.2.0"), clock));
    modelFactories.add(DeployTester.createModelFactory(Version.fromString("7.0.0"), clock));
    DeployTester tester = new DeployTester("src/test/apps/hosted/", modelFactories, createConfigserverConfig());
    ApplicationId app = tester.deployApp("myApp", Instant.now());
    assertEquals(3, tester.getAllocatedHostsOf(app).getHosts().size());
}
Also used : ManualClock(com.yahoo.test.ManualClock) ArrayList(java.util.ArrayList) ModelFactory(com.yahoo.config.model.api.ModelFactory) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Aggregations

ModelFactory (com.yahoo.config.model.api.ModelFactory)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 ManualClock (com.yahoo.test.ManualClock)2 Version (com.yahoo.config.provision.Version)1 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)1 Optional (java.util.Optional)1