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;
}
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));
}
}
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"));
}
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;
}
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));
}
Aggregations