|
8 | 8 | import java.io.IOException;
|
9 | 9 | import java.net.URI;
|
10 | 10 | import java.net.URISyntaxException;
|
| 11 | +import java.time.Duration; |
11 | 12 | import java.util.Arrays;
|
12 | 13 | import java.util.Collections;
|
13 | 14 | import java.util.concurrent.TimeUnit;
|
|
47 | 48 |
|
48 | 49 | import static io.netty.util.CharsetUtil.UTF_8;
|
49 | 50 | import static org.assertj.core.api.Assertions.assertThat;
|
| 51 | +import static org.awaitility.Awaitility.await; |
50 | 52 | import static org.junit.Assert.*;
|
51 | 53 | import static org.junit.Assume.assumeTrue;
|
52 | 54 |
|
@@ -781,28 +783,29 @@ public void testMoveNode() throws IOException, URISyntaxException
|
781 | 783 |
|
782 | 784 | NettyHttpClient client = new NettyHttpClient(BASE_URL);
|
783 | 785 |
|
784 |
| - URI uri = new URIBuilder(BASE_PATH + "/ops/node/move") |
785 |
| - .addParameter("newToken", "1234") |
786 |
| - .build(); |
787 |
| - Pair<Integer, String> response = client.post(uri.toURL(), null) |
788 |
| - .thenApply(this::responseAsCodeAndBody).join(); |
789 |
| - assertThat(response.getLeft()).isEqualTo(HttpStatus.SC_ACCEPTED); |
790 |
| - String jobId = response.getRight(); |
| 786 | + URI nodeMoveUri = new URIBuilder(BASE_PATH + "/ops/node/move") |
| 787 | + .addParameter("newToken", "1234") |
| 788 | + .build(); |
| 789 | + Pair<Integer, String> nodeMoveResponse = client.post(nodeMoveUri.toURL(), null) |
| 790 | + .thenApply(this::responseAsCodeAndBody).join(); |
| 791 | + assertThat(nodeMoveResponse.getLeft()).isEqualTo(HttpStatus.SC_ACCEPTED); |
| 792 | + String jobId = nodeMoveResponse.getRight(); |
791 | 793 | assertThat(jobId).isNotEmpty();
|
792 | 794 |
|
793 |
| - uri = new URIBuilder(BASE_PATH + "/ops/executor/job") |
794 |
| - .addParameter("job_id", jobId) |
795 |
| - .build(); |
796 |
| - response = client.get(uri.toURL()).thenApply(this::responseAsCodeAndBody).join(); |
797 |
| - assertThat(response.getLeft()).isEqualTo(HttpStatus.SC_OK); |
798 |
| - |
799 |
| - Map<String, String> jobDetails = new JsonMapper().readValue(response.getRight(), new TypeReference<Map<String, String>>(){}); |
800 |
| - assertThat(jobDetails) |
801 |
| - .hasEntrySatisfying("id", value -> assertThat(value).isEqualTo(jobId)) |
802 |
| - .hasEntrySatisfying("type", value -> assertThat(value).isEqualTo("move")) |
803 |
| - .hasEntrySatisfying("status", value -> assertThat(value).isEqualTo("ERROR")) |
804 |
| - .hasEntrySatisfying("error", value -> assertThat(value).contains("This node has more than one token and cannot be moved")) |
805 |
| - ; |
| 795 | + URI getJobDetailsUri = new URIBuilder(BASE_PATH + "/ops/executor/job") |
| 796 | + .addParameter("job_id", jobId) |
| 797 | + .build(); |
| 798 | + |
| 799 | + await().atMost(Duration.ofMinutes(1)).untilAsserted(() -> { |
| 800 | + Pair<Integer, String> getJobDetailsResponse = client.get(getJobDetailsUri.toURL()).thenApply(this::responseAsCodeAndBody).join(); |
| 801 | + assertThat(getJobDetailsResponse.getLeft()).isEqualTo(HttpStatus.SC_OK); |
| 802 | + Map<String, String> jobDetails = new JsonMapper().readValue(getJobDetailsResponse.getRight(), new TypeReference<Map<String, String>>(){}); |
| 803 | + assertThat(jobDetails) |
| 804 | + .hasEntrySatisfying("id", value -> assertThat(value).isEqualTo(jobId)) |
| 805 | + .hasEntrySatisfying("type", value -> assertThat(value).isEqualTo("move")) |
| 806 | + .hasEntrySatisfying("status", value -> assertThat(value).isEqualTo("ERROR")) |
| 807 | + .hasEntrySatisfying("error", value -> assertThat(value).contains("This node has more than one token and cannot be moved")); |
| 808 | + }); |
806 | 809 | }
|
807 | 810 |
|
808 | 811 | private void createKeyspace(NettyHttpClient client, String localDc, String keyspaceName) throws IOException, URISyntaxException
|
|
0 commit comments