|
18 | 18 | import static org.junit.Assume.assumeFalse;
|
19 | 19 | import static org.junit.Assume.assumeTrue;
|
20 | 20 |
|
21 |
| -import com.datastax.mgmtapi.client.api.DefaultApi; |
22 |
| -import com.datastax.mgmtapi.client.invoker.ApiClient; |
23 | 21 | import com.datastax.mgmtapi.helpers.IntegrationTestUtils;
|
24 | 22 | import com.datastax.mgmtapi.helpers.NettyHttpClient;
|
25 | 23 | import com.datastax.mgmtapi.resources.models.CompactRequest;
|
|
34 | 32 | import com.datastax.mgmtapi.resources.models.ScrubRequest;
|
35 | 33 | import com.datastax.mgmtapi.resources.models.Table;
|
36 | 34 | import com.datastax.mgmtapi.resources.models.TakeSnapshotRequest;
|
| 35 | +import com.datastax.mgmtapi.resources.v2.models.RepairParallelism; |
| 36 | +import com.datastax.mgmtapi.resources.v2.models.RepairRequestResponse; |
37 | 37 | import com.datastax.oss.driver.api.core.metadata.schema.ClusteringOrder;
|
38 | 38 | import com.fasterxml.jackson.core.JsonProcessingException;
|
39 | 39 | import com.fasterxml.jackson.core.type.TypeReference;
|
@@ -1036,38 +1036,62 @@ public void testMoveNode() throws IOException, URISyntaxException {
|
1036 | 1036 | });
|
1037 | 1037 | }
|
1038 | 1038 |
|
1039 |
| - public void ensureStatusChanges() throws Exception { |
| 1039 | + @Test |
| 1040 | + public void testEnsureStatusChanges() throws Exception { |
1040 | 1041 | assumeTrue(IntegrationTestUtils.shouldRun());
|
1041 | 1042 | ensureStarted();
|
1042 | 1043 | 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)))); |
| 1044 | + |
| 1045 | + com.datastax.mgmtapi.resources.v2.models.RepairRequest req = |
| 1046 | + new com.datastax.mgmtapi.resources.v2.models.RepairRequest( |
| 1047 | + "system_distributed", |
| 1048 | + null, |
| 1049 | + true, |
| 1050 | + true, |
| 1051 | + Collections.singletonList( |
| 1052 | + new com.datastax.mgmtapi.resources.v2.models.RingRange(-1L, 100L)), |
| 1053 | + RepairParallelism.SEQUENTIAL, |
| 1054 | + null, |
| 1055 | + null); |
| 1056 | + |
1056 | 1057 | 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. |
| 1058 | + URI repairUri = new URIBuilder(BASE_PATH_V2 + "/repairs").build(); |
| 1059 | + Pair<Integer, String> repairResp = |
| 1060 | + client |
| 1061 | + .put(repairUri.toURL(), new ObjectMapper().writeValueAsString(req)) |
| 1062 | + .thenApply(this::responseAsCodeAndBody) |
| 1063 | + .join(); |
| 1064 | + logger.info("Repair response: {}", repairResp); |
| 1065 | + String jobID = |
| 1066 | + new ObjectMapper().readValue(repairResp.getRight(), RepairRequestResponse.class).repairID; |
| 1067 | + Integer repairID = |
| 1068 | + Integer.parseInt( |
| 1069 | + jobID.substring(7) // Trimming off "repair-" prefix. |
| 1070 | + ); |
1059 | 1071 | logger.info("Repair ID: {}", repairID);
|
1060 | 1072 | assertThat(repairID).isNotNull();
|
1061 | 1073 | assertThat(repairID).isGreaterThan(0);
|
1062 | 1074 |
|
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); |
| 1075 | + URI statusUri = |
| 1076 | + new URIBuilder(BASE_PATH_V2 + "/ops/executor/job").addParameter("job_id", jobID).build(); |
| 1077 | + Pair<Integer, String> statusResp = |
| 1078 | + client.get(statusUri.toURL()).thenApply(this::responseAsCodeAndBody).join(); |
| 1079 | + logger.info("Repair job status: {}", statusResp); |
| 1080 | + Job jobStatus = new ObjectMapper().readValue(statusResp.getRight(), Job.class); |
| 1081 | + |
| 1082 | + assertThat(jobStatus.getStatus()).isNotNull(); |
| 1083 | + assertThat(jobStatus.getStatusChanges()).isNotNull(); |
1068 | 1084 | await()
|
1069 | 1085 | .atMost(5, SECONDS)
|
1070 | 1086 | .until(
|
1071 |
| - () -> status.getStatus() == com.datastax.mgmtapi.client.model.Job.StatusEnum.COMPLETED); |
| 1087 | + () -> { |
| 1088 | + Pair<Integer, String> statusResp2 = |
| 1089 | + client.get(statusUri.toURL()).thenApply(this::responseAsCodeAndBody).join(); |
| 1090 | + logger.info("Repair job status: {}", statusResp); |
| 1091 | + Job jobStatus2 = new ObjectMapper().readValue(statusResp.getRight(), Job.class); |
| 1092 | + return jobStatus2.getStatusChanges().size() > 0 |
| 1093 | + && jobStatus2.getStatus() |
| 1094 | + == com.datastax.mgmtapi.resources.models.Job.JobStatus.COMPLETED; |
| 1095 | + }); |
1072 | 1096 | }
|
1073 | 1097 | }
|
0 commit comments