diff --git a/src/main/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithm.java b/src/main/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithm.java index 20f37720..e9075000 100644 --- a/src/main/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithm.java +++ b/src/main/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithm.java @@ -70,7 +70,7 @@ public static String findUnusedName(CloudProvisioningRecord record) { final int maxAttempts = hasCap ? (templateInstanceCap) : 100; for (int attempt = 0; attempt < maxAttempts; attempt++) { final String suffix = hasCap ? calcSequentialSuffix(attempt) : calcRandomSuffix(attempt); - final String nodeName = cloneNamePrefix + "_" + suffix; + final String nodeName = cloneNamePrefix + suffix; if (!existingNames.contains(nodeName)) { return nodeName; } @@ -134,4 +134,4 @@ static BigInteger toBigInteger(final long msb, final long lsb) { final BigInteger bigNumber = new BigInteger(bytes); return bigNumber; } -} \ No newline at end of file +} diff --git a/src/test/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithmTest.java b/src/test/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithmTest.java index 785e36fb..02f2af5b 100644 --- a/src/test/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithmTest.java +++ b/src/test/java/org/jenkinsci/plugins/vsphere/tools/CloudProvisioningAlgorithmTest.java @@ -200,8 +200,8 @@ public void findUnusedNameGivenZeroOfTwoExistsThenReturnsOneThenTwo() { // Given final CloudProvisioningRecord record = createInstance(2, 0, 0); final String prefix = record.getTemplate().getCloneNamePrefix(); - final String expected1 = prefix + "_1"; - final String expected2 = prefix + "_2"; + final String expected1 = prefix + "1"; + final String expected2 = prefix + "2"; // When final String actual1 = CloudProvisioningAlgorithm.findUnusedName(record); @@ -219,10 +219,10 @@ public void findUnusedNameGivenMiddleOfThreeStillExistsThenReturnsOneThenThree() // Given final CloudProvisioningRecord record = createInstance(3, 0, 0); final String prefix = record.getTemplate().getCloneNamePrefix(); - final String expected1 = prefix + "_1"; - final String unwanted = prefix + "_2"; + final String expected1 = prefix + "1"; + final String unwanted = prefix + "2"; record.setCurrentlyUnwanted(unwanted, false); - final String expected2 = prefix + "_3"; + final String expected2 = prefix + "3"; // When final String actual1 = CloudProvisioningAlgorithm.findUnusedName(record); @@ -240,9 +240,9 @@ public void findUnusedNameGivenNoSpaceThenThrowsIllegalStateException() { // Given final CloudProvisioningRecord record = createInstance(3, 0, 0); final String prefix = record.getTemplate().getCloneNamePrefix(); - final String unwanted = prefix + "_1"; - final String active = prefix + "_2"; - final String planned = prefix + "_3"; + final String unwanted = prefix + "1"; + final String active = prefix + "2"; + final String planned = prefix + "3"; record.setCurrentlyUnwanted(unwanted, false); record.addCurrentlyActive(active); record.addCurrentlyPlanned(planned); @@ -264,7 +264,7 @@ public void findUnusedNameGivenOneOfTwoHasEndedThenReturnsOne() { // Given final CloudProvisioningRecord record = createInstance(2, 0, 0); final String prefix = record.getTemplate().getCloneNamePrefix(); - final String expected = prefix + "_1"; + final String expected = prefix + "1"; // When final String actual1 = CloudProvisioningAlgorithm.findUnusedName(record); @@ -296,7 +296,7 @@ public void findUnusedNameGivenUncappedInstancesThenReturnsUniqueNames() { // Then final List uniques = new ArrayList(new LinkedHashSet(actuals)); assertThat(actuals, equalTo(uniques)); - assertThat(actuals, everyItem(startsWith(prefix + "_"))); + assertThat(actuals, everyItem(startsWith(prefix))); } private CloudProvisioningRecord createInstance(int capacity, int provisioned, int planned) {