use of com.yahoo.config.model.api.SuperModel in project vespa by vespa-engine.
the class InstanceValidatorTest method mockSuperModelProvider.
private SuperModelProvider mockSuperModelProvider(ApplicationInfo... appInfos) {
SuperModel superModel = new SuperModel(Stream.of(appInfos).collect(Collectors.groupingBy(appInfo -> appInfo.getApplicationId().tenant(), Collectors.toMap(ApplicationInfo::getApplicationId, Function.identity()))));
SuperModelProvider superModelProvider = mock(SuperModelProvider.class);
when(superModelProvider.getSuperModel()).thenReturn(superModel);
return superModelProvider;
}
use of com.yahoo.config.model.api.SuperModel in project vespa by vespa-engine.
the class SuperModelControllerTest method test_lb_config_multiple_apps.
@Test
public void test_lb_config_multiple_apps() throws IOException, SAXException {
Map<TenantName, Map<ApplicationId, ApplicationInfo>> models = new LinkedHashMap<>();
models.put(TenantName.from("t1"), new LinkedHashMap<>());
models.put(TenantName.from("t2"), new LinkedHashMap<>());
File testApp1 = new File("src/test/resources/deploy/app");
File testApp2 = new File("src/test/resources/deploy/advancedapp");
File testApp3 = new File("src/test/resources/deploy/advancedapp");
// TODO must fix equals, hashCode on Tenant
Version vespaVersion = Version.fromIntValues(1, 2, 3);
models.get(TenantName.from("t1")).put(applicationId("mysimpleapp"), new ApplicationInfo(applicationId("mysimpleapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp1))));
models.get(TenantName.from("t1")).put(applicationId("myadvancedapp"), new ApplicationInfo(applicationId("myadvancedapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp2))));
models.get(TenantName.from("t2")).put(applicationId("minetooadvancedapp"), new ApplicationInfo(applicationId("minetooadvancedapp"), 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp3))));
SuperModel superModel = new SuperModel(models);
SuperModelController han = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
LbServicesConfig.Builder lb = new LbServicesConfig.Builder();
han.getSuperModel().getConfig(lb);
LbServicesConfig lbc = new LbServicesConfig(lb);
assertThat(lbc.tenants().size(), is(2));
assertThat(lbc.tenants("t1").applications().size(), is(2));
assertThat(lbc.tenants("t2").applications().size(), is(1));
assertThat(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default").hosts().size(), is(1));
assertQrServer(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default"));
}
use of com.yahoo.config.model.api.SuperModel in project vespa by vespa-engine.
the class SuperModelControllerTest method setupHandler.
@Before
public void setupHandler() throws IOException, SAXException {
Map<TenantName, Map<ApplicationId, ApplicationInfo>> models = new LinkedHashMap<>();
models.put(TenantName.from("a"), new LinkedHashMap<>());
File testApp = new File("src/test/resources/deploy/app");
ApplicationId app = ApplicationId.from(TenantName.from("a"), ApplicationName.from("foo"), InstanceName.defaultName());
models.get(app.tenant()).put(app, new ApplicationInfo(app, 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp))));
SuperModel superModel = new SuperModel(models);
handler = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
}
use of com.yahoo.config.model.api.SuperModel in project vespa by vespa-engine.
the class ExampleModel method createExampleSuperModelWithOneRpcPort.
static SuperModel createExampleSuperModelWithOneRpcPort(String hostname, int rpcPort) {
List<String> hosts = Stream.of(hostname).collect(Collectors.toList());
ApplicationInfo applicationInfo = ExampleModel.createApplication(TENANT, APPLICATION_NAME).addServiceCluster(CLUSTER_ID, SERVICE_NAME, SERVICE_TYPE, hosts).addPort(rpcPort, "footag", SlobrokMonitor.SLOBROK_RPC_PORT_TAG).addPort(rpcPort + 1, "bartag").then().build();
Map<TenantName, Map<ApplicationId, ApplicationInfo>> applicationInfos = new HashMap<>();
applicationInfos.put(applicationInfo.getApplicationId().tenant(), new HashMap<>());
applicationInfos.get(applicationInfo.getApplicationId().tenant()).put(applicationInfo.getApplicationId(), applicationInfo);
return new SuperModel(applicationInfos);
}
Aggregations