Search in sources :

Example 16 with TenantName

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

the class LbServicesProducerTest method createTestModel.

private Map<TenantName, Map<ApplicationId, ApplicationInfo>> createTestModel(DeployState.Builder deployStateBuilder) throws IOException, SAXException {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> tMap = new LinkedHashMap<>();
    TenantName foo = TenantName.from("foo");
    TenantName bar = TenantName.from("bar");
    TenantName baz = TenantName.from("baz");
    tMap.put(foo, createTestApplications(foo, deployStateBuilder));
    tMap.put(bar, createTestApplications(bar, deployStateBuilder));
    tMap.put(baz, createTestApplications(baz, deployStateBuilder));
    return tMap;
}
Also used : TenantName(com.yahoo.config.provision.TenantName) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 17 with TenantName

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

the class GetConfigProcessorTest method testSentinelConfig.

@Test
public void testSentinelConfig() {
    MockRpc rpc = new MockRpc(13337, false);
    // should be a sentinel config, but it does not matter for this test
    rpc.response = new MockConfigResponse("foo");
    // one tenant, which has host1 assigned
    boolean pretentToHaveLoadedApplications = true;
    TenantName testTenant = TenantName.from("test");
    rpc.onTenantCreate(testTenant, new MockTenantProvider(pretentToHaveLoadedApplications));
    rpc.hostsUpdated(testTenant, Collections.singleton("host1"));
    {
        // a config is returned normally
        JRTServerConfigRequest req = createV3SentinelRequest("host1");
        GetConfigProcessor proc = new GetConfigProcessor(rpc, req, false);
        proc.run();
        assertTrue(rpc.tryResolveConfig);
        assertTrue(rpc.tryRespond);
        assertThat(rpc.errorCode, is(0));
    }
    rpc.resetChecks();
    // host1 is replaced by host2 for this tenant
    rpc.hostsUpdated(testTenant, Collections.singleton("host2"));
    {
        // this causes us to get an empty config instead of normal config resolution
        JRTServerConfigRequest req = createV3SentinelRequest("host1");
        GetConfigProcessor proc = new GetConfigProcessor(rpc, req, false);
        proc.run();
        // <-- no normal config resolution happening
        assertFalse(rpc.tryResolveConfig);
        assertTrue(rpc.tryRespond);
        assertThat(rpc.errorCode, is(0));
    }
}
Also used : JRTServerConfigRequest(com.yahoo.vespa.config.protocol.JRTServerConfigRequest) GetConfigProcessor(com.yahoo.vespa.config.server.rpc.GetConfigProcessor) MockRpc(com.yahoo.vespa.config.server.rpc.MockRpc) TenantName(com.yahoo.config.provision.TenantName) MockTenantProvider(com.yahoo.vespa.config.server.tenant.MockTenantProvider) Test(org.junit.Test)

Example 18 with TenantName

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

the class RoutingProducerTest method testNodesFromRoutingAppOnly.

@Test
public void testNodesFromRoutingAppOnly() throws Exception {
    Map<TenantName, Map<ApplicationId, ApplicationInfo>> testModel = createTestModel(new DeployState.Builder());
    RoutingProducer producer = new RoutingProducer(testModel);
    RoutingConfig.Builder builder = new RoutingConfig.Builder();
    producer.getConfig(builder);
    RoutingConfig config = new RoutingConfig(builder);
    assertThat(config.hosts().size(), is(2));
    assertThat(config.hosts(0), is("hosted-vespa.routing.yahoo.com"));
    assertThat(config.hosts(1), is("hosted-vespa.routing2.yahoo.com"));
}
Also used : DeployState(com.yahoo.config.model.deploy.DeployState) TenantName(com.yahoo.config.provision.TenantName) RoutingConfig(com.yahoo.cloud.config.RoutingConfig) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Test(org.junit.Test)

Example 19 with TenantName

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

the class ApplicationRepository method verifyTenantAndApplication.

public Tenant verifyTenantAndApplication(ApplicationId applicationId) {
    TenantName tenantName = applicationId.tenant();
    if (!tenants.checkThatTenantExists(tenantName)) {
        throw new IllegalArgumentException("Tenant " + tenantName + " was not found.");
    }
    Tenant tenant = tenants.getTenant(tenantName);
    List<ApplicationId> applicationIds = listApplicationIds(tenant);
    if (!applicationIds.contains(applicationId)) {
        throw new IllegalArgumentException("No such application id: " + applicationId);
    }
    return tenant;
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) TenantName(com.yahoo.config.provision.TenantName) ApplicationId(com.yahoo.config.provision.ApplicationId)

Example 20 with TenantName

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

the class HttpConfigRequest method createFromRequestV2SimpleAppId.

// The URL pattern with only tenant and application given
private static HttpConfigRequest createFromRequestV2SimpleAppId(HttpRequest req, BindingMatch<?> bm) {
    String cId;
    String cName;
    String cNamespace;
    TenantName tenant = TenantName.from(bm.group(2));
    ApplicationName application = ApplicationName.from(bm.group(3));
    String conf = bm.group(4);
    if (bm.groupCount() >= 6) {
        cId = bm.group(5);
    } else {
        cId = "";
    }
    Tuple2<String, String> nns = nameAndNamespace(conf);
    cName = nns.first;
    cNamespace = nns.second;
    return new HttpConfigRequest(new ConfigKey<>(cName, cId, cNamespace), new ApplicationId.Builder().applicationName(application).tenant(tenant).build(), req.getBooleanProperty(HTTP_PROPERTY_NOCACHE));
}
Also used : ApplicationName(com.yahoo.config.provision.ApplicationName) TenantName(com.yahoo.config.provision.TenantName)

Aggregations

TenantName (com.yahoo.config.provision.TenantName)48 Test (org.junit.Test)15 ApplicationId (com.yahoo.config.provision.ApplicationId)12 Map (java.util.Map)12 LinkedHashMap (java.util.LinkedHashMap)11 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)9 LbServicesConfig (com.yahoo.cloud.config.LbServicesConfig)4 ApplicationInfo (com.yahoo.config.model.api.ApplicationInfo)4 ApplicationName (com.yahoo.config.provision.ApplicationName)4 SuperModel (com.yahoo.config.model.api.SuperModel)3 Slime (com.yahoo.slime.Slime)3 TimeoutBudget (com.yahoo.vespa.config.server.TimeoutBudget)3 PrepareParams (com.yahoo.vespa.config.server.session.PrepareParams)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 DeployState (com.yahoo.config.model.deploy.DeployState)2 Version (com.yahoo.config.provision.Version)2 Zone (com.yahoo.config.provision.Zone)2 ConfigKey (com.yahoo.vespa.config.ConfigKey)2