Search in sources :

Example 21 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class TenantRequestHandlerTest method testReloadConfig.

@Test
public void testReloadConfig() throws IOException, SAXException {
    Clock clock = Clock.systemUTC();
    ApplicationId applicationId = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(tenant).build();
    server.reloadConfig(reloadConfig(1, clock));
    assertThat(listener.reloaded.get(), is(1));
    // Using only payload list for this simple test
    SimpletypesConfig config = resolve(SimpletypesConfig.class, server, "");
    assertThat(config.intval(), is(1337));
    assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(1l));
    server.reloadConfig(reloadConfig(1l, clock));
    config = resolve(SimpletypesConfig.class, server, "");
    assertThat(config.intval(), is(1337));
    assertThat(listener.reloaded.get(), is(2));
    assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(1l));
    assertThat(listener.tenantHosts.size(), is(1));
    assertThat(server.resolveApplicationId("mytesthost"), is(applicationId));
    listener.reloaded.set(0);
    feedApp(app2, 2);
    server.reloadConfig(reloadConfig(2l, clock));
    config = resolve(SimpletypesConfig.class, server, "");
    assertThat(config.intval(), is(1330));
    assertThat(listener.reloaded.get(), is(1));
    assertThat(server.getApplicationGeneration(applicationId, Optional.of(vespaVersion)), is(2l));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) Clock(java.time.Clock) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 22 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class TenantRequestHandlerTest method testResolveMultipleVersions.

@Test
public void testResolveMultipleVersions() throws IOException {
    ApplicationId appId = new ApplicationId.Builder().tenant(tenant).applicationName("myapp1").instanceName("myinst1").build();
    feedAndReloadApp(app1, 1, appId);
    SimpletypesConfig config = resolve(SimpletypesConfig.class, server, appId, vespaVersion, "");
    assertThat(config.intval(), is(1337));
    config = resolve(SimpletypesConfig.class, server, appId, Version.fromIntValues(3, 2, 1), "");
    assertThat(config.intval(), is(1337));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) ApplicationId(com.yahoo.config.provision.ApplicationId) Test(org.junit.Test)

Example 23 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class SessionPreparerTest method require_no_warning_for_overlapping_host_for_same_appid.

@Test
public void require_no_warning_for_overlapping_host_for_same_appid() throws IOException {
    SessionContext ctx = getContext(getApplicationPackage(testApp));
    ((HostRegistry<ApplicationId>) ctx.getHostValidator()).update(applicationId("default"), Collections.singletonList("mytesthost"));
    final StringBuilder logged = new StringBuilder();
    DeployLogger logger = (level, message) -> {
        System.out.println(level + ": " + message);
        if (level.equals(LogLevel.WARNING) && message.contains("The host mytesthost is already in use"))
            logged.append("ok");
    };
    preparer.prepare(ctx, logger, new PrepareParams.Builder().build(), Optional.empty(), tenantPath, Instant.now());
    assertEquals(logged.toString(), "");
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) java.util(java.util) InstanceName(com.yahoo.config.provision.InstanceName) ApplicationName(com.yahoo.config.provision.ApplicationName) ApplicationId(com.yahoo.config.provision.ApplicationId) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) Slime(com.yahoo.slime.Slime) ConfigCurator(com.yahoo.vespa.config.server.zookeeper.ConfigCurator) IOUtils(com.yahoo.io.IOUtils) InvalidApplicationException(com.yahoo.vespa.config.server.http.InvalidApplicationException) DeployLogger(com.yahoo.config.application.api.DeployLogger) TenantName(com.yahoo.config.provision.TenantName) TestModelFactory(com.yahoo.vespa.config.server.model.TestModelFactory) Path(com.yahoo.path.Path) Rotations(com.yahoo.vespa.config.server.tenant.Rotations) LogLevel(com.yahoo.log.LogLevel) HostRegistry(com.yahoo.vespa.config.server.host.HostRegistry) Before(org.junit.Before) Rotation(com.yahoo.config.provision.Rotation) ConfigChangeAction(com.yahoo.config.model.api.ConfigChangeAction) ImmutableSet(com.google.common.collect.ImmutableSet) ModelContext(com.yahoo.config.model.api.ModelContext) MemoryTenantApplications(com.yahoo.vespa.config.server.application.MemoryTenantApplications) Test(org.junit.Test) IOException(java.io.IOException) Instant(java.time.Instant) com.yahoo.config.model.application.provider(com.yahoo.config.model.application.provider) File(java.io.File) RestartActions(com.yahoo.vespa.config.server.configchange.RestartActions) Rule(org.junit.Rule) PermanentApplicationPackage(com.yahoo.vespa.config.server.application.PermanentApplicationPackage) ModelFactoryRegistry(com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry) Matchers.contains(org.hamcrest.Matchers.contains) HostProvisionerProvider(com.yahoo.vespa.config.server.provision.HostProvisionerProvider) SAXException(org.xml.sax.SAXException) ModelCreateResult(com.yahoo.config.model.api.ModelCreateResult) Version(com.yahoo.config.provision.Version) com.yahoo.vespa.config.server(com.yahoo.vespa.config.server) DeployHandlerLogger(com.yahoo.vespa.config.server.deploy.DeployHandlerLogger) Assert(org.junit.Assert) TemporaryFolder(org.junit.rules.TemporaryFolder) ServiceInfo(com.yahoo.config.model.api.ServiceInfo) MockRestartAction(com.yahoo.vespa.config.server.configchange.MockRestartAction) HostRegistry(com.yahoo.vespa.config.server.host.HostRegistry) DeployLogger(com.yahoo.config.application.api.DeployLogger) Test(org.junit.Test)

Example 24 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class LbServicesProducerTest method randomizeApplications.

private Map<ApplicationId, ApplicationInfo> randomizeApplications(Map<ApplicationId, ApplicationInfo> applicationIdApplicationMap, int seed) {
    Map<ApplicationId, ApplicationInfo> randomizedApplications = new LinkedHashMap<>();
    List<ApplicationId> keys = new ArrayList<>(applicationIdApplicationMap.keySet());
    Collections.shuffle(keys, new Random(seed));
    for (ApplicationId key : keys) {
        randomizedApplications.put(key, applicationIdApplicationMap.get(key));
    }
    return randomizedApplications;
}
Also used : Random(java.util.Random) ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ArrayList(java.util.ArrayList) ApplicationId(com.yahoo.config.provision.ApplicationId) LinkedHashMap(java.util.LinkedHashMap)

Example 25 with ApplicationId

use of com.yahoo.config.provision.ApplicationId in project vespa by vespa-engine.

the class LbServicesProducerTest method createTestApplications.

private Map<ApplicationId, ApplicationInfo> createTestApplications(TenantName tenant, DeployState.Builder deploystateBuilder) throws IOException, SAXException {
    Map<ApplicationId, ApplicationInfo> aMap = new LinkedHashMap<>();
    ApplicationId fooApp = new ApplicationId.Builder().tenant(tenant).applicationName("foo").build();
    ApplicationId barApp = new ApplicationId.Builder().tenant(tenant).applicationName("bar").build();
    ApplicationId bazApp = new ApplicationId.Builder().tenant(tenant).applicationName("baz").build();
    aMap.put(fooApp, createApplication(fooApp, deploystateBuilder));
    aMap.put(barApp, createApplication(barApp, deploystateBuilder));
    aMap.put(bazApp, createApplication(bazApp, deploystateBuilder));
    return aMap;
}
Also used : ApplicationInfo(com.yahoo.config.model.api.ApplicationInfo) ApplicationId(com.yahoo.config.provision.ApplicationId) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ApplicationId (com.yahoo.config.provision.ApplicationId)173 Test (org.junit.Test)102 Zone (com.yahoo.config.provision.Zone)52 Node (com.yahoo.vespa.hosted.provision.Node)30 ClusterSpec (com.yahoo.config.provision.ClusterSpec)22 TenantName (com.yahoo.config.provision.TenantName)20 Flavor (com.yahoo.config.provision.Flavor)19 List (java.util.List)16 HashSet (java.util.HashSet)15 HostSpec (com.yahoo.config.provision.HostSpec)12 Duration (java.time.Duration)12 HashMap (java.util.HashMap)12 Map (java.util.Map)12 Set (java.util.Set)12 Collectors (java.util.stream.Collectors)12 Version (com.yahoo.component.Version)11 OutOfCapacityException (com.yahoo.config.provision.OutOfCapacityException)11 Slime (com.yahoo.slime.Slime)11 ArrayList (java.util.ArrayList)11 Optional (java.util.Optional)11