|
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,61 @@ 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 | + String jobID = |
| 1065 | + new ObjectMapper().readValue(repairResp.getRight(), RepairRequestResponse.class).repairID; |
| 1066 | + Integer repairID = |
| 1067 | + Integer.parseInt( |
| 1068 | + jobID.substring(7) // Trimming off "repair-" prefix. |
| 1069 | + ); |
1059 | 1070 | logger.info("Repair ID: {}", repairID); |
1060 | 1071 | assertThat(repairID).isNotNull(); |
1061 | 1072 | assertThat(repairID).isGreaterThan(0); |
1062 | 1073 |
|
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); |
| 1074 | + URI statusUri = |
| 1075 | + new URIBuilder(BASE_PATH_V2 + "/ops/executor/job").addParameter("job_id", jobID).build(); |
| 1076 | + Pair<Integer, String> statusResp = |
| 1077 | + client.get(statusUri.toURL()).thenApply(this::responseAsCodeAndBody).join(); |
| 1078 | + logger.info("Repair job status: {}", statusResp); |
| 1079 | + Job jobStatus = new ObjectMapper().readValue(statusResp.getRight(), Job.class); |
| 1080 | + |
| 1081 | + assertThat(jobStatus.getStatus()).isNotNull(); |
| 1082 | + assertThat(jobStatus.getStatusChanges()).isNotNull(); |
1068 | 1083 | await() |
1069 | 1084 | .atMost(5, SECONDS) |
1070 | 1085 | .until( |
1071 | | - () -> status.getStatus() == com.datastax.mgmtapi.client.model.Job.StatusEnum.COMPLETED); |
| 1086 | + () -> { |
| 1087 | + Pair<Integer, String> statusResp2 = |
| 1088 | + client.get(statusUri.toURL()).thenApply(this::responseAsCodeAndBody).join(); |
| 1089 | + logger.info("Repair job status: {}", statusResp); |
| 1090 | + Job jobStatus2 = new ObjectMapper().readValue(statusResp.getRight(), Job.class); |
| 1091 | + return jobStatus2.getStatusChanges().size() > 0 |
| 1092 | + && jobStatus2.getStatus() |
| 1093 | + == com.datastax.mgmtapi.resources.models.Job.JobStatus.COMPLETED; |
| 1094 | + }); |
1072 | 1095 | } |
1073 | 1096 | } |
0 commit comments