|
10 | 10 | import org.opensearch.action.ActionRequest;
|
11 | 11 | import org.opensearch.action.ActionRequestValidationException;
|
12 | 12 | import org.opensearch.common.io.stream.BytesStreamOutput;
|
| 13 | +import org.opensearch.common.unit.TimeValue; |
13 | 14 | import org.opensearch.core.common.io.stream.StreamOutput;
|
14 | 15 |
|
15 | 16 | import java.io.IOException;
|
|
19 | 20 | import static org.junit.Assert.assertNotSame;
|
20 | 21 | import static org.junit.Assert.assertNull;
|
21 | 22 | import static org.junit.Assert.assertSame;
|
| 23 | +import static org.junit.Assert.assertTrue; |
22 | 24 |
|
23 | 25 | public class MLModelDeleteRequestTest {
|
24 | 26 | private String modelId;
|
@@ -54,6 +56,62 @@ public void validate_Exception_NullModelId() {
|
54 | 56 | assertEquals("Validation Failed: 1: ML model id can't be null;", exception.getMessage());
|
55 | 57 | }
|
56 | 58 |
|
| 59 | + @Test |
| 60 | + public void validate_Exception_NegativeMaxRetry() { |
| 61 | + MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.builder() |
| 62 | + .modelId(modelId).maxRetry(-1).build(); |
| 63 | + |
| 64 | + ActionRequestValidationException exception = mlModelDeleteRequest.validate(); |
| 65 | + assertEquals("Validation Failed: 1: Retry count should be greater than or equal to 0 and less than 5;", exception.getMessage()); |
| 66 | + } |
| 67 | + |
| 68 | + @Test |
| 69 | + public void validate_Exception_ExceedMaxRetry() { |
| 70 | + MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.builder() |
| 71 | + .modelId(modelId).maxRetry(6).build(); |
| 72 | + |
| 73 | + ActionRequestValidationException exception = mlModelDeleteRequest.validate(); |
| 74 | + assertEquals("Validation Failed: 1: Retry count should be greater than or equal to 0 and less than 5;", exception.getMessage()); |
| 75 | + } |
| 76 | + |
| 77 | + @Test |
| 78 | + public void validate_Exception_NegativeRetryDelay() { |
| 79 | + MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.builder() |
| 80 | + .modelId(modelId).retryDelay(TimeValue.timeValueMillis(-1)).build(); |
| 81 | + |
| 82 | + ActionRequestValidationException exception = mlModelDeleteRequest.validate(); |
| 83 | + assertEquals("Validation Failed: 1: Retry delay should be greater than or equal to 0 or less than 30000 milliseconds;", exception.getMessage()); |
| 84 | + } |
| 85 | + |
| 86 | + |
| 87 | + @Test |
| 88 | + public void validate_Exception_ExceedRetryDelay() { |
| 89 | + MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.builder() |
| 90 | + .modelId(modelId).retryDelay(TimeValue.timeValueMillis(50000)).build(); |
| 91 | + |
| 92 | + ActionRequestValidationException exception = mlModelDeleteRequest.validate(); |
| 93 | + assertEquals("Validation Failed: 1: Retry delay should be greater than or equal to 0 or less than 30000 milliseconds;", exception.getMessage()); |
| 94 | + } |
| 95 | + |
| 96 | + @Test |
| 97 | + public void validate_Exception_NegativeRetryTimeout() { |
| 98 | + MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.builder() |
| 99 | + .modelId(modelId).retryTimeout(TimeValue.timeValueMillis(-1)).build(); |
| 100 | + |
| 101 | + ActionRequestValidationException exception = mlModelDeleteRequest.validate(); |
| 102 | + assertEquals("Validation Failed: 1: Retry delay should be greater than or equal to 0 or less than 30000 milliseconds;", exception.getMessage()); |
| 103 | + } |
| 104 | + |
| 105 | + |
| 106 | + @Test |
| 107 | + public void validate_Exception_ExceedRetryTimeout() { |
| 108 | + MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.builder() |
| 109 | + .modelId(modelId).retryTimeout(TimeValue.timeValueSeconds(60)).build(); |
| 110 | + |
| 111 | + ActionRequestValidationException exception = mlModelDeleteRequest.validate(); |
| 112 | + assertEquals("Validation Failed: 1: Retry delay should be greater than or equal to 0 or less than 30000 milliseconds;", exception.getMessage()); |
| 113 | + } |
| 114 | + |
57 | 115 | @Test
|
58 | 116 | public void fromActionRequest_Success() {
|
59 | 117 | MLModelDeleteRequest mlModelDeleteRequest = MLModelDeleteRequest.builder()
|
|
0 commit comments