Skip to content

Commit b9f5f7f

Browse files
committed
Add new test for null statusChanges in the job response.
1 parent 6b965aa commit b9f5f7f

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

management-api-server/src/test/java/com/datastax/mgmtapi/BaseDockerIntegrationTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public abstract class BaseDockerIntegrationTest {
4444
protected static final String BASE_PATH = "http://localhost:8080/api/v0";
4545
protected static final String BASE_PATH_V1 = "http://localhost:8080/api/v1";
4646
protected static final String BASE_PATH_V2 = "http://localhost:8080/api/v2";
47+
protected static final String BASE_HOST = "http://localhost:8080";
4748
protected static final URL BASE_URL;
4849
protected static final ObjectMapper JSON_MAPPER = new ObjectMapper();
4950

management-api-server/src/test/java/com/datastax/mgmtapi/NonDestructiveOpsIT.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
package com.datastax.mgmtapi;
77

8+
import static java.util.concurrent.TimeUnit.SECONDS;
89
import static org.assertj.core.api.Assertions.assertThat;
910
import static org.assertj.core.api.Assertions.assertThatCode;
1011
import static org.awaitility.Awaitility.await;
@@ -17,6 +18,8 @@
1718
import static org.junit.Assume.assumeFalse;
1819
import static org.junit.Assume.assumeTrue;
1920

21+
import com.datastax.mgmtapi.client.api.DefaultApi;
22+
import com.datastax.mgmtapi.client.invoker.ApiClient;
2023
import com.datastax.mgmtapi.helpers.IntegrationTestUtils;
2124
import com.datastax.mgmtapi.helpers.NettyHttpClient;
2225
import com.datastax.mgmtapi.resources.models.CompactRequest;
@@ -49,7 +52,6 @@
4952
import java.util.Collections;
5053
import java.util.List;
5154
import java.util.Map;
52-
import java.util.concurrent.TimeUnit;
5355
import org.apache.commons.lang3.tuple.Pair;
5456
import org.apache.http.HttpStatus;
5557
import org.apache.http.client.utils.URIBuilder;
@@ -112,7 +114,7 @@ public static void ensureStarted() throws IOException {
112114

113115
if (ready) break;
114116

115-
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
117+
Uninterruptibles.sleepUninterruptibly(10, SECONDS);
116118
}
117119

118120
logger.info("CASSANDRA ALIVE: {}", ready);
@@ -1033,4 +1035,39 @@ public void testMoveNode() throws IOException, URISyntaxException {
10331035
"status", value -> assertThat(value).isIn("COMPLETED", "ERROR"));
10341036
});
10351037
}
1038+
1039+
public void ensureStatusChanges() throws Exception {
1040+
assumeTrue(IntegrationTestUtils.shouldRun());
1041+
ensureStarted();
1042+
NettyHttpClient client = new NettyHttpClient(BASE_URL);
1043+
DefaultApi apiClient = new DefaultApi(new ApiClient().setBasePath(BASE_HOST));
1044+
com.datastax.mgmtapi.client.model.RepairRequest req =
1045+
new com.datastax.mgmtapi.client.model.RepairRequest()
1046+
.keyspace("system_distributed")
1047+
.fullRepair(true)
1048+
.notifications(true)
1049+
.repairParallelism(
1050+
com.datastax.mgmtapi.client.model.RepairRequest.RepairParallelismEnum.SEQUENTIAL)
1051+
.associatedTokens(
1052+
Collections.singletonList(
1053+
new com.datastax.mgmtapi.client.model.RingRange()
1054+
.start(Long.valueOf(-1))
1055+
.end(Long.valueOf(100))));
1056+
logger.info("Sending repair request: {}", req);
1057+
String jobID = apiClient.putRepairV2(req).getRepairId();
1058+
Integer repairID = Integer.parseInt(jobID.substring(7)); // Trimming off "repair-" prefix.
1059+
logger.info("Repair ID: {}", repairID);
1060+
assertThat(repairID).isNotNull();
1061+
assertThat(repairID).isGreaterThan(0);
1062+
1063+
com.datastax.mgmtapi.client.model.Job status = apiClient.getJobStatus(jobID);
1064+
logger.info("Repair job status: {}", status);
1065+
assertThat(status.getStatus()).isNotNull();
1066+
assertThat(status.getStatusChanges()).isNotNull();
1067+
await().atMost(5, SECONDS).until(() -> status.getStatusChanges().size() > 0);
1068+
await()
1069+
.atMost(5, SECONDS)
1070+
.until(
1071+
() -> status.getStatus() == com.datastax.mgmtapi.client.model.Job.StatusEnum.COMPLETED);
1072+
}
10361073
}

0 commit comments

Comments
 (0)