aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-11-05 14:54:52 +0100
committerHarald Musum <musum@oath.com>2018-11-05 17:43:05 +0100
commit6630d84ae7856c26c00f5f1d10e1c0a3e304170f (patch)
tree1f55749a8d903398069a2ea6e95f5a45c783406d /configserver/src
parente5d0e505d22f728ff97da039c6eceb5860147511 (diff)
Use simpler map for models
Need to keep old constructor and make a temporary one with an ignored argument to make this work (since arguments will be equal due to type erasure)
Diffstat (limited to 'configserver/src')
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java80
1 files changed, 63 insertions, 17 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
index 323b52ee4ac..b7ca52390ed 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
@@ -6,6 +6,8 @@ import com.yahoo.cloud.config.LbServicesConfig.Tenants.Applications;
import com.yahoo.config.model.api.ApplicationInfo;
import com.yahoo.config.model.api.SuperModel;
import com.yahoo.config.model.application.provider.FilesApplicationPackage;
+import com.yahoo.config.model.deploy.DeployProperties;
+import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationName;
import com.yahoo.config.provision.InstanceName;
@@ -39,7 +41,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
- * @since 5.9
*/
public class SuperModelControllerTest {
@@ -47,13 +48,13 @@ public class SuperModelControllerTest {
@Before
public void setupHandler() throws IOException, SAXException {
- Map<TenantName, Map<ApplicationId, ApplicationInfo>> models = new LinkedHashMap<>();
- models.put(TenantName.from("a"), new LinkedHashMap<>());
+ Map<ApplicationId, ApplicationInfo> models = 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);
+ models.put(app, new ApplicationInfo(app, 4l, new VespaModel(FilesApplicationPackage.fromFile(testApp))));
+ SuperModel superModel = new SuperModel(models, false);
handler = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
}
@@ -81,21 +82,25 @@ public class SuperModelControllerTest {
}
@Test
- public void test_lb_config_multiple_apps() throws IOException, SAXException {
+ public void test_lb_config_multiple_apps_legacy_super_model() 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<>());
+ TenantName t1 = TenantName.from("t1");
+ TenantName t2 = TenantName.from("t2");
+ models.put(t1, new LinkedHashMap<>());
+ models.put(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))));
+
+ ApplicationId simple = applicationId("mysimpleapp", t1);
+ ApplicationId advanced = applicationId("myadvancedapp", t1);
+ ApplicationId tooAdvanced = applicationId("minetooadvancedapp", t2);
+ models.get(t1).put(simple, createApplicationInfo(testApp1, simple, 4l));
+ models.get(t1).put(advanced, createApplicationInfo(testApp2, simple, 4l));
+ models.get(t2).put(tooAdvanced, createApplicationInfo(testApp3, simple, 4l));
+
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();
@@ -108,9 +113,38 @@ public class SuperModelControllerTest {
assertQrServer(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default"));
}
- private ApplicationId applicationId(String applicationName) {
- return ApplicationId.from(TenantName.defaultName(),
- ApplicationName.from(applicationName), InstanceName.defaultName());
+ @Test
+ public void test_lb_config_multiple_apps() throws IOException, SAXException {
+ Map<ApplicationId, ApplicationInfo> models = new LinkedHashMap<>();
+ TenantName t1 = TenantName.from("t1");
+ TenantName t2 = TenantName.from("t2");
+ 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);
+
+ ApplicationId simple = applicationId("mysimpleapp", t1);
+ ApplicationId advanced = applicationId("myadvancedapp", t1);
+ ApplicationId tooAdvanced = applicationId("minetooadvancedapp", t2);
+ models.put(simple, createApplicationInfo(testApp1, simple, 4l));
+ models.put(advanced, createApplicationInfo(testApp2, simple, 4l));
+ models.put(tooAdvanced, createApplicationInfo(testApp3, simple, 4l));
+
+ SuperModel superModel = new SuperModel(models, false);
+ 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"));
+ }
+
+ private ApplicationId applicationId(String applicationName, TenantName tenantName) {
+ return ApplicationId.from(tenantName, ApplicationName.from(applicationName), InstanceName.defaultName());
}
private void assertQrServer(Applications app) {
@@ -130,6 +164,18 @@ public class SuperModelControllerTest {
org.junit.Assert.fail("No qrserver service in config");
}
+ private DeployState createDeployState(File applicationPackage, ApplicationId applicationId) {
+ return new DeployState.Builder()
+ .applicationPackage(FilesApplicationPackage.fromFile(applicationPackage))
+ .properties(new DeployProperties.Builder().applicationId(applicationId).build())
+ .build();
+ }
+
+ private ApplicationInfo createApplicationInfo(File applicationPackage, ApplicationId applicationId, long generation) throws IOException, SAXException {
+ DeployState deployState = createDeployState(applicationPackage, applicationId);
+ return new ApplicationInfo(applicationId, generation, new VespaModel(deployState));
+ }
+
}