diff options
author | Håkon Hallingstad <hakon@yahoo-inc.com> | 2017-05-04 09:42:25 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@yahoo-inc.com> | 2017-05-04 09:42:25 +0200 |
commit | df86b08b98f24e2300e83f8ee521162280084dd7 (patch) | |
tree | e89bbeca776bf6ef8662e4166300071514dd1120 /orchestrator | |
parent | fad9bdcd621da92d83085bc44aa27be10e419871 (diff) |
Correctly extract cluster controller index from standalone cluster controller
Diffstat (limited to 'orchestrator')
-rw-r--r-- | orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/VespaModelUtil.java | 6 | ||||
-rw-r--r-- | orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/VespaModelUtilTest.java | 12 |
2 files changed, 14 insertions, 4 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/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 |