diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-05-04 09:51:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-04 09:51:09 +0200 |
commit | ed7deee81fc50c7f61d7e5bdb7ad8a689a13189b (patch) | |
tree | 4cbbf061d40a4ca85e648a08a4a8d47bb259ce63 | |
parent | f51e8c0178d38b862708585c11977e801c640639 (diff) | |
parent | c8d89329184af4f21b784b715617da486dbf64dd (diff) |
Merge pull request #2384 from yahoo/hakon/correctly-extract-cluster-controller-index-from-standalone-cluster-controller
Correctly extract cluster controller index from standalone cluster controller
3 files changed, 15 insertions, 5 deletions
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java index b9b1f334784..c94ce8cacdb 100644 --- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java +++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java @@ -197,10 +197,12 @@ public class VespaModelUtil { } // See getClusterControllerIndex() - private static final Pattern CONTROLLER_INDEX_PATTERN = Pattern.compile(".*/cluster-controllers/(\\d+)"); + private static final Pattern CONTROLLER_INDEX_PATTERN = Pattern.compile(".*-controllers/(\\d+)"); /** - * @param configId Must be of the form admin/cluster-controllers/2 + * @param configId Must be of the form admin/cluster-controllers/2 or NAME/standalone/NAME-controllers/2, + * where NAME is the name of the content cluster. NAME-controllers is also the cluster ID of + * the cluster controller cluster. * @return the Cluster Controller index given its config ID. * @throws java.lang.IllegalArgumentException if the config ID is not of the proper format. */ diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/TestUtil.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/TestUtil.java index 3dfd9a5cb8e..0f074be9667 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/TestUtil.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/TestUtil.java @@ -32,6 +32,6 @@ public class TestUtil { } public static ConfigId clusterControllerConfigId(String contentClusterName, int index) { - return new ConfigId(contentClusterName + "/cluster-controllers/" + index); + return new ConfigId(contentClusterName + "/standalone/" + contentClusterName + "-controllers/" + index); } } diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/VespaModelUtilTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/VespaModelUtilTest.java index 53f5e830bfc..ea4b095a748 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/VespaModelUtilTest.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/VespaModelUtilTest.java @@ -24,6 +24,7 @@ import static com.yahoo.vespa.orchestrator.TestUtil.makeServiceInstanceSet; import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertTrue; import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assert.fail; /** * @author hakonhall @@ -217,8 +218,15 @@ public class VespaModelUtilTest { @Test public void testGetClusterControllerIndexWithStandaloneClusterController() { - ConfigId configId = new ConfigId("foo/standalone/cluster-controllers/2"); - assertThat(VespaModelUtil.getClusterControllerIndex(configId)).isEqualTo(2); + ConfigId configId = new ConfigId("fantasy_sports/standalone/fantasy_sports-controllers/1"); + assertThat(VespaModelUtil.getClusterControllerIndex(configId)).isEqualTo(1); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadClusterControllerConfigId() { + ConfigId configId = new ConfigId("fantasy_sports/storage/9"); + VespaModelUtil.getClusterControllerIndex(configId); + fail(); } @Test |