Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't force the use of underscore to separate slave prefix from number. #92

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -134,4 +134,4 @@ static BigInteger toBigInteger(final long msb, final long lsb) {
final BigInteger bigNumber = new BigInteger(bytes);
return bigNumber;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -296,7 +296,7 @@ public void findUnusedNameGivenUncappedInstancesThenReturnsUniqueNames() {
// Then
final List<String> uniques = new ArrayList<String>(new LinkedHashSet<String>(actuals));
assertThat(actuals, equalTo(uniques));
assertThat(actuals, everyItem(startsWith(prefix + "_")));
assertThat(actuals, everyItem(startsWith(prefix)));
}

private CloudProvisioningRecord createInstance(int capacity, int provisioned, int planned) {
Expand Down