Skip to content
Open
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 @@ -1599,6 +1599,9 @@ private void validateIops(Long minIops, Long maxIops, Storage.StoragePoolType po
}

if (minIops != null && maxIops != null) {
if (minIops < 0 || maxIops < 0) {
throw new InvalidParameterValueException("The 'miniops' and 'maxiops' parameters must not be negative.");
}
if (minIops > maxIops) {
throw new InvalidParameterValueException("The 'miniops' parameter must be less than or equal to the 'maxiops' parameter.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2966,4 +2966,89 @@ public void testResizeVolumeInternal_VMware_VMRunning_ShouldThrowStateGuardError
e.getMessage() != null && e.getMessage().contains("VM should be in"));
}
}

private void invokeValidateIops(Long minIops, Long maxIops) {
invokeValidateIops(minIops, maxIops, Storage.StoragePoolType.NetworkFilesystem);
}

private void invokeValidateIops(Long minIops, Long maxIops, Storage.StoragePoolType poolType) {
ReflectionTestUtils.invokeMethod(volumeApiServiceImpl, "validateIops", minIops, maxIops, poolType);
}

private void assertValidateIopsRejects(Long minIops, Long maxIops, String expectedMessagePart) {
assertValidateIopsRejects(minIops, maxIops, Storage.StoragePoolType.NetworkFilesystem, expectedMessagePart);
}

private void assertValidateIopsRejects(Long minIops, Long maxIops, Storage.StoragePoolType poolType, String expectedMessagePart) {
try {
invokeValidateIops(minIops, maxIops, poolType);
Assert.fail("Expected an InvalidParameterValueException for miniops=" + minIops + ", maxiops=" + maxIops + ", poolType=" + poolType);
} catch (InvalidParameterValueException e) {
Assert.assertTrue("Unexpected message: " + e.getMessage(), e.getMessage().contains(expectedMessagePart));
}
}

@Test
public void validateIopsPowerFlexAcceptsNegativeMinIops() {
invokeValidateIops(-1L, 200L, Storage.StoragePoolType.PowerFlex);
}

@Test
public void validateIopsPowerFlexRejectsNegativeMaxIops() {
assertValidateIopsRejects(100L, -1L, Storage.StoragePoolType.PowerFlex, "must not be negative");
}

@Test
public void validateIopsPowerFlexRejectsNegativeMinAndMaxIops() {
assertValidateIopsRejects(-1L, -1L, Storage.StoragePoolType.PowerFlex, "must not be negative");
}

@Test
public void validateIopsPowerFlexSkipsMinIopsValidation() {
invokeValidateIops(null, 200L, Storage.StoragePoolType.PowerFlex);
invokeValidateIops(500L, 200L, Storage.StoragePoolType.PowerFlex);
invokeValidateIops(0L, 0L, Storage.StoragePoolType.PowerFlex);
}

@Test
public void validateIopsRejectsNegativeMinIops() {
assertValidateIopsRejects(-1L, 200L, "must not be negative");
}

@Test
public void validateIopsRejectsNegativeMaxIops() {
assertValidateIopsRejects(100L, -1L, "must not be negative");
}

@Test
public void validateIopsRejectsNegativeMinAndMaxIops() {
assertValidateIopsRejects(-1L, -1L, "must not be negative");
}

@Test
public void validateIopsRejectsMinAboveMax() {
assertValidateIopsRejects(300L, 200L, "less than or equal");
}

@Test
public void validateIopsRejectsOnlyOneValueProvided() {
assertValidateIopsRejects(100L, null, "both be provided");
assertValidateIopsRejects(null, 200L, "both be provided");
}

@Test
public void validateIopsAcceptsZeroMinIops() {
invokeValidateIops(0L, 200L);
}

@Test
public void validateIopsAcceptsZeroMinAndMaxIops() {
invokeValidateIops(0L, 0L);
}

@Test
public void validateIopsAcceptsPositiveAndNullValues() {
invokeValidateIops(100L, 200L);
invokeValidateIops(null, null);
}
}
Loading