sklaha commented on code in PR #275:
URL: https://github.com/apache/cassandra-sidecar/pull/275#discussion_r2675336519


##########
integration-tests/src/integrationTest/org/apache/cassandra/sidecar/routes/CassandraNodeOperationsIntegrationTest.java:
##########
@@ -88,17 +100,160 @@ void testNodeDrainOperationSuccess()
 
         // Validate the operational job status using the OperationalJobHandler
         String jobId = responseBody.getString("jobId");
-        validateOperationalJobStatus(jobId, "drain");
+        validateOperationalJobStatus(jobId, "drain", 
OperationalJobStatus.SUCCEEDED);
+    }
+
+
+    @Test
+    void testNodeMoveOperationSuccess()
+    {
+        // Use a test token - this is a valid token for Murmur3Partitioner
+        String testToken = "123456789";
+        String requestBody = "{\"newToken\":\"" + testToken + "\"}";
+
+        // Validate that the node owns a different token than testToken
+        String currentToken = getCurrentTokenForNode("localhost");
+        assertThat(currentToken).isNotEqualTo(testToken);
+
+        // Initiate move operation
+        HttpResponse<Buffer> moveResponse = getBlocking(
+        trustedClient().put(serverWrapper.serverPort, "localhost", 
ApiEndpointsV1.NODE_MOVE_ROUTE)
+                       .putHeader("content-type", "application/json")
+                       .sendBuffer(Buffer.buffer(requestBody)));
+
+        assertThat(moveResponse.statusCode()).isIn(OK.code(), ACCEPTED.code());
+
+        JsonObject responseBody = moveResponse.bodyAsJsonObject();
+        assertThat(responseBody).isNotNull();
+        assertThat(responseBody.getString("jobId")).isNotNull();
+        assertThat(responseBody.getString("operation")).isEqualTo("move");
+        assertThat(responseBody.getString("jobStatus")).isIn(
+        OperationalJobStatus.CREATED.name(),
+        OperationalJobStatus.RUNNING.name(),
+        OperationalJobStatus.SUCCEEDED.name()
+        );
+
+        // Verify the job eventually completes (or at least gets processed)
+        loopAssert(30, 500, () -> {
+            HttpResponse<Buffer> streamStatsResponse = getBlocking(
+            trustedClient().get(serverWrapper.serverPort, "localhost", 
ApiEndpointsV1.STREAM_STATS_ROUTE)
+                           .send());
+
+            assertThat(streamStatsResponse.statusCode()).isEqualTo(OK.code());
+
+            JsonObject streamStats = streamStatsResponse.bodyAsJsonObject();
+            assertThat(streamStats).isNotNull();
+            // The operationMode should be either NORMAL (completed) or MOVING 
(in progress)
+            assertThat(streamStats.getString("operationMode")).isIn("NORMAL", 
"MOVING");
+        });
+
+        // Validate the operational job status using the OperationalJobHandler
+        String jobId = responseBody.getString("jobId");
+        validateOperationalJobStatus(jobId, "move", 
OperationalJobStatus.SUCCEEDED);

Review Comment:
   Yes. The job submits a node move request to the node. It succeeds when the 
move request is submitted successfully.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to