diff options
author | toby <smorgrav@yahoo-inc.com> | 2016-06-30 13:22:13 +0200 |
---|---|---|
committer | toby <smorgrav@yahoo-inc.com> | 2016-06-30 13:22:13 +0200 |
commit | 0c70e06e1ff2b0cc189f7718044baf92e02fd9de (patch) | |
tree | 566416bc9a4158a74e247129ccee83190a1a3ac9 | |
parent | 12e646bd65c1d5eacac607828937f3e23aa913c4 (diff) |
Relax assumption on ApplicationInstanceReference format.
-rw-r--r-- | orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java | 11 | ||||
-rw-r--r-- | orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorUtilTest.java | 13 |
2 files changed, 23 insertions, 1 deletions
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java index adfdb7bde5d..262d89cfd1e 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/OrchestratorUtil.java @@ -134,7 +134,16 @@ public class OrchestratorUtil { String appNameStr = appRef.toString(); String[] appNameParts = appNameStr.split(":"); - // TODO model ApplicationInstanceReference properly and validate this there + + // Env, region and instance seems to be optional due to the hardcoded config server app + // Assume here that first two are tenant and application name. + if (appNameParts.length > 1 && appNameParts.length < 5) { + return ApplicationId.from(TenantName.from(appNameParts[0]), + ApplicationName.from(appNameParts[1]), + InstanceName.defaultName()); + } + + // Other normal application should have 5 parts. if (appNameParts.length != 5) { throw new IllegalArgumentException("Application reference not valid (not 5 parts): " + appRef); } diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorUtilTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorUtilTest.java index 2655f6b2b49..a79e32ab101 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorUtilTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorUtilTest.java @@ -25,6 +25,10 @@ public class OrchestratorUtilTest { new TenantId("test-tenant-id"), new ApplicationInstanceId("application:prod:utopia-1:instance")); + private static final ApplicationInstanceReference APPREF_2 = new ApplicationInstanceReference( + new TenantId("hosted-vespa"), + new ApplicationInstanceId("zone-config-servers")); + /** * Here we don't care how the internal of the different application * id/reference look like as long as we get back to exactly where we @@ -46,4 +50,13 @@ public class OrchestratorUtilTest { Assert.assertEquals(APPREF_1, appRefRoundTrip); } + + @Test + public void applicationid_from_zone_confg_server_appref_is_working() throws Exception { + ApplicationId appId = OrchestratorUtil.toApplicationId(APPREF_2); + Assert.assertEquals(ApplicationId.from( + TenantName.from("hosted-vespa"), + ApplicationName.from("zone-config-servers"), + InstanceName.defaultName()),appId); + } } |