|
5 | 5 | */
|
6 | 6 | package com.datastax.mgmtapi;
|
7 | 7 |
|
| 8 | +import static java.util.concurrent.TimeUnit.SECONDS; |
8 | 9 | import static org.assertj.core.api.Assertions.assertThat;
|
9 | 10 | import static org.assertj.core.api.Assertions.assertThatCode;
|
10 | 11 | import static org.awaitility.Awaitility.await;
|
|
17 | 18 | import static org.junit.Assume.assumeFalse;
|
18 | 19 | import static org.junit.Assume.assumeTrue;
|
19 | 20 |
|
| 21 | +import com.datastax.mgmtapi.client.api.DefaultApi; |
| 22 | +import com.datastax.mgmtapi.client.invoker.ApiClient; |
20 | 23 | import com.datastax.mgmtapi.helpers.IntegrationTestUtils;
|
21 | 24 | import com.datastax.mgmtapi.helpers.NettyHttpClient;
|
22 | 25 | import com.datastax.mgmtapi.resources.models.CompactRequest;
|
|
49 | 52 | import java.util.Collections;
|
50 | 53 | import java.util.List;
|
51 | 54 | import java.util.Map;
|
52 |
| -import java.util.concurrent.TimeUnit; |
53 | 55 | import org.apache.commons.lang3.tuple.Pair;
|
54 | 56 | import org.apache.http.HttpStatus;
|
55 | 57 | import org.apache.http.client.utils.URIBuilder;
|
@@ -112,7 +114,7 @@ public static void ensureStarted() throws IOException {
|
112 | 114 |
|
113 | 115 | if (ready) break;
|
114 | 116 |
|
115 |
| - Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS); |
| 117 | + Uninterruptibles.sleepUninterruptibly(10, SECONDS); |
116 | 118 | }
|
117 | 119 |
|
118 | 120 | logger.info("CASSANDRA ALIVE: {}", ready);
|
@@ -1033,4 +1035,39 @@ public void testMoveNode() throws IOException, URISyntaxException {
|
1033 | 1035 | "status", value -> assertThat(value).isIn("COMPLETED", "ERROR"));
|
1034 | 1036 | });
|
1035 | 1037 | }
|
| 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 | + } |
1036 | 1073 | }
|
0 commit comments