rpuch commented on a change in pull request #647:
URL: https://github.com/apache/ignite-3/pull/647#discussion_r803370870
##########
File path:
modules/cli/src/test/java/org/apache/ignite/cli/IgniteCliInterfaceTest.java
##########
@@ -581,17 +619,200 @@ void setJson() throws IOException, InterruptedException {
+ "local.baseline.autoAdjust.enabled=true --type
node"
).split(" "));
- Assertions.assertEquals(0, exitCode);
- verify(httpClient).send(
- argThat(r ->
"http://localhost:8081/management/v1/configuration/node/".equals(r.uri().toString())
- && "PATCH".equals(r.method())
- && r.bodyPublisher().get().contentLength() ==
expSentContent.getBytes(UTF_8).length
- &&
"application/json".equals(r.headers().firstValue("Content-Type").get())),
- any());
- assertEquals("Configuration was updated successfully.\n\n"
+ assertThatExitCodeMeansSuccess(exitCode);
+
+ verify(httpClient).send(requestCaptor.capture(), any());
+ HttpRequest capturedRequest = requestCaptor.getValue();
+
+ assertThat(capturedRequest.uri().toString(),
is("http://localhost:8081/management/v1/configuration/node/"));
+ assertThat(capturedRequest.method(), is("PATCH"));
+ assertThat(requestBodyBytes(capturedRequest),
is(expSentContent.getBytes(UTF_8)));
+ assertThat(capturedRequest.headers().firstValue("Content-Type"),
isPresentAnd(is("application/json")));
+
+ assertOutputEqual("Configuration was updated successfully.\n\n"
+ "Use the " + cmd.getColorScheme().commandText("ignite
config get")
- + " command to view the updated configuration.\n",
out.toString());
+ + " command to view the updated configuration.\n",
out.toString(UTF_8));
+ assertThatStderrIsEmpty();
+ }
+ }
+
+ /**
+ * Tests "cluster" command.
+ */
+ @Nested
+ @DisplayName("cluster")
+ class Cluster {
+ @Mock
+ private HttpClient httpClient;
+
+ @Mock
+ private HttpResponse<String> response;
+
+ @BeforeEach
+ void setUp() {
+ ctx.registerSingleton(httpClient);
+ }
+
+ @Test
+ @DisplayName("init --node-endpoint=127.0.0.1:17300 --meta-storage-node
node1ConsistentId --meta-storage-node node2ConsistentId "
+ + "--cmg-node node2ConsistentId --cmg-node node3ConsistentId")
+ void initSuccess() throws Exception {
+ when(response.statusCode()).thenReturn(HttpURLConnection.HTTP_OK);
+ when(httpClient.<String>send(any(), any())).thenReturn(response);
+
+ var expSentContent =
"{\"metastorageNodes\":[\"node1ConsistentId\",\"node2ConsistentId\"],"
+ +
"\"cmgNodes\":[\"node2ConsistentId\",\"node3ConsistentId\"]}";
+
+ var cmd = cmd(ctx);
Review comment:
Fixed
--
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]