You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "Pochatkin (via GitHub)" <gi...@apache.org> on 2026/01/07 16:04:19 UTC
[PR] IGNITE-27201 Add CLI command to inspect deployment unit file tree [ignite-3]
Pochatkin opened a new pull request, #7356:
URL: https://github.com/apache/ignite-3/pull/7356
https://issues.apache.org/jira/browse/IGNITE-27201
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27201 Add CLI command to inspect deployment unit file tree [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on code in PR #7356:
URL: https://github.com/apache/ignite-3/pull/7356#discussion_r2669938430
##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItNodeUnitStructureCommandTest.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.unit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertAll;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.internal.cli.CliIntegrationTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+/** Integration test for node unit structure command. */
+public class ItNodeUnitStructureCommandTest extends CliIntegrationTest {
+ private static String testFile;
+
+ private static Path testDirectory;
+
+ @BeforeAll
+ static void beforeAll() throws IOException {
+ testDirectory = Files.createDirectory(WORK_DIR.resolve("test-structure"));
+ testFile = Files.createFile(testDirectory.resolve("test.txt")).toString();
+ Files.createFile(testDirectory.resolve("test2.txt"));
+ Files.createFile(testDirectory.resolve("test3.txt"));
Review Comment:
can u make the test input more diverse? like filenames contains spaces, slashes, dashes, etc?
##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItNodeUnitStructureCommandTest.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.unit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertAll;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.internal.cli.CliIntegrationTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+/** Integration test for node unit structure command. */
+public class ItNodeUnitStructureCommandTest extends CliIntegrationTest {
Review Comment:
Why the test is called `NodeUnit...` but it tests `cluster unit ...`?
##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/unit/NodeUnitStructureCommand.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.node.unit;
+
+import static org.apache.ignite.internal.cli.commands.Options.Constants.PLAIN_OPTION;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.PLAIN_OPTION_DESC;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.UNIT_VERSION_OPTION_DESC;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.VERSION_OPTION;
+
+import jakarta.inject.Inject;
+import java.util.concurrent.Callable;
+import org.apache.ignite.internal.cli.call.node.unit.NodeUnitStructureCall;
+import org.apache.ignite.internal.cli.call.unit.UnitStructureCallInput;
+import org.apache.ignite.internal.cli.commands.BaseCommand;
+import org.apache.ignite.internal.cli.commands.node.NodeUrlProfileMixin;
+import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline;
+import org.apache.ignite.internal.cli.core.exception.handler.ClusterNotInitializedExceptionHandler;
+import org.apache.ignite.internal.cli.decorators.UnitStructureDecorator;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Mixin;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Parameters;
+
+/** Command to show deployment unit structure. */
+@Command(name = "structure", description = "Shows the structure of a deployed unit")
Review Comment:
I have a concern about the command naming. We tend to name the last command with a verb: `cluster config show`, `cluster unit deploy`, etc. Maybe we can follow this pattern? I would propose `inspect` instead of `structure`.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27201 Add CLI command to inspect deployment unit file tree [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #7356:
URL: https://github.com/apache/ignite-3/pull/7356#discussion_r2686284693
##########
modules/cli/src/test/java/org/apache/ignite/internal/cli/decorators/UnitStructureDecoratorTest.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.decorators;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
+
+import java.util.List;
+import org.apache.ignite.rest.client.model.UnitEntry;
+import org.apache.ignite.rest.client.model.UnitFile;
+import org.apache.ignite.rest.client.model.UnitFolder;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+class UnitStructureDecoratorTest {
+
+ @Test
+ @DisplayName("Tree view should display folder with files")
+ void treeViewWithFiles() {
+ // Given
+ UnitFolder folder = createFolderWithFiles("test-unit",
+ createFile("file1.txt", 100),
+ createFile("file2.txt", 200));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("test-unit"));
+ assertThat(output, containsString("file1.txt"));
+ assertThat(output, containsString("file2.txt"));
+ assertThat(output, containsString("100 B"));
+ assertThat(output, containsString("200 B"));
+ assertThat(output, containsString("+--"));
+ assertThat(output, containsString("\\--"));
+ }
+
+ @Test
+ @DisplayName("Tree view should display nested folders")
+ void treeViewWithNestedFolders() {
+ // Given
+ UnitFolder subFolder = createFolderWithFiles("subfolder",
+ createFile("nested.txt", 50));
+
+ UnitEntry subFolderEntry = new UnitEntry();
+ subFolderEntry.setActualInstance(subFolder);
+
+ UnitFolder rootFolder = new UnitFolder()
+ .type(UnitFolder.TypeEnum.FOLDER)
+ .name("root")
+ .children(List.of(subFolderEntry));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(rootFolder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("root"));
+ assertThat(output, containsString("subfolder"));
+ assertThat(output, containsString("nested.txt"));
+ assertThat(output, containsString("\\--"));
+ assertThat(output, containsString(" \\--")); // Nested indent
+ }
+
+ @Test
+ @DisplayName("Plain view should display file paths")
+ void plainViewWithFiles() {
+ // Given
+ UnitFolder folder = createFolderWithFiles("test-unit",
+ createFile("file1.txt", 100),
+ createFile("file2.txt", 200));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(true);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("file1.txt"));
+ assertThat(output, containsString("file2.txt"));
+ assertThat(output, containsString("100"));
+ assertThat(output, containsString("200"));
+ // Should not contain tree characters in plain mode
+ assertThat(output, not(containsString("├──")));
+ assertThat(output, not(containsString("└──")));
+ }
+
+ @Test
+ @DisplayName("Plain view should display nested paths")
+ void plainViewWithNestedFolders() {
+ // Given
+ UnitFolder subFolder = createFolderWithFiles("subfolder",
+ createFile("nested.txt", 50));
+
+ UnitEntry subFolderEntry = new UnitEntry();
+ subFolderEntry.setActualInstance(subFolder);
+
+ UnitFolder rootFolder = new UnitFolder()
+ .type(UnitFolder.TypeEnum.FOLDER)
+ .name("root")
+ .children(List.of(subFolderEntry));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(true);
+
+ // When
+ String output = decorator.decorate(rootFolder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("subfolder/nested.txt"));
+ assertThat(output, containsString("50"));
+ }
+
+ @Test
+ @DisplayName("Should format file sizes correctly")
+ void fileSizeFormatting() {
+ // Given
+ UnitFolder folder = createFolderWithFiles("test-unit",
+ createFile("small.txt", 512),
+ createFile("medium.txt", 2048),
+ createFile("large.txt", 1024 * 1024 * 2));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("512 B"));
+ assertThat(output, containsString("KiB"));
+ assertThat(output, containsString("MiB"));
+ }
+
+ @Test
+ @DisplayName("Should handle empty folder")
+ void emptyFolder() {
+ // Given
+ UnitFolder folder = new UnitFolder()
+ .type(UnitFolder.TypeEnum.FOLDER)
+ .name("empty-folder")
+ .children(List.of());
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("empty-folder"));
+ }
+
+ private UnitFolder createFolderWithFiles(String name, UnitFile... files) {
+ List<UnitEntry> children = new java.util.ArrayList<>();
+ long totalSize = 0;
+
+ for (UnitFile file : files) {
+ UnitEntry entry = new UnitEntry();
+ entry.setActualInstance(file);
+ children.add(entry);
+ totalSize += file.getSize();
+ }
Review Comment:
There's a constructor with the actual instance parameter, so this can be simplified. `totalSize` variable is unused.
```suggestion
List<UnitEntry> children = Arrays.stream(files).map(UnitEntry::new).collect(Collectors.toList());
```
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27201 Add CLI command to inspect deployment unit file tree [ignite-3]
Posted by "Pochatkin (via GitHub)" <gi...@apache.org>.
Pochatkin commented on code in PR #7356:
URL: https://github.com/apache/ignite-3/pull/7356#discussion_r2690164663
##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/unit/NodeUnitStructureCommand.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.node.unit;
+
+import static org.apache.ignite.internal.cli.commands.Options.Constants.PLAIN_OPTION;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.PLAIN_OPTION_DESC;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.UNIT_VERSION_OPTION_DESC;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.VERSION_OPTION;
+
+import jakarta.inject.Inject;
+import java.util.concurrent.Callable;
+import org.apache.ignite.internal.cli.call.node.unit.NodeUnitStructureCall;
+import org.apache.ignite.internal.cli.call.unit.UnitStructureCallInput;
+import org.apache.ignite.internal.cli.commands.BaseCommand;
+import org.apache.ignite.internal.cli.commands.node.NodeUrlProfileMixin;
+import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline;
+import org.apache.ignite.internal.cli.core.exception.handler.ClusterNotInitializedExceptionHandler;
+import org.apache.ignite.internal.cli.decorators.UnitStructureDecorator;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Mixin;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Parameters;
+
+/** Command to show deployment unit structure. */
+@Command(name = "structure", description = "Shows the structure of a deployed unit")
Review Comment:
Fixed: Renamed the command from `structure` to `inspect`. All related classes have been renamed accordingly (NodeUnitStructureCommand → NodeUnitInspectCommand, etc.).
##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItNodeUnitStructureCommandTest.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.unit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertAll;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.internal.cli.CliIntegrationTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+/** Integration test for node unit structure command. */
+public class ItNodeUnitStructureCommandTest extends CliIntegrationTest {
+ private static String testFile;
+
+ private static Path testDirectory;
+
+ @BeforeAll
+ static void beforeAll() throws IOException {
+ testDirectory = Files.createDirectory(WORK_DIR.resolve("test-structure"));
+ testFile = Files.createFile(testDirectory.resolve("test.txt")).toString();
+ Files.createFile(testDirectory.resolve("test2.txt"));
+ Files.createFile(testDirectory.resolve("test3.txt"));
Review Comment:
Fixed: Added diverse test filenames with spaces, dashes, underscores, multiple dots, parentheses, and mixed case. Also added nested directories to cover more edge cases.
##########
modules/cli/src/test/java/org/apache/ignite/internal/cli/decorators/UnitStructureDecoratorTest.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.decorators;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
+
+import java.util.List;
+import org.apache.ignite.rest.client.model.UnitEntry;
+import org.apache.ignite.rest.client.model.UnitFile;
+import org.apache.ignite.rest.client.model.UnitFolder;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+class UnitStructureDecoratorTest {
+
+ @Test
+ @DisplayName("Tree view should display folder with files")
+ void treeViewWithFiles() {
+ // Given
+ UnitFolder folder = createFolderWithFiles("test-unit",
+ createFile("file1.txt", 100),
+ createFile("file2.txt", 200));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("test-unit"));
Review Comment:
Fixed: Added exact output verification for all tests in UnitInspectDecoratorTest using assertThat(output, is(expected)) instead of containsString.
##########
modules/cli/src/test/java/org/apache/ignite/internal/cli/decorators/UnitStructureDecoratorTest.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.decorators;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
+
+import java.util.List;
+import org.apache.ignite.rest.client.model.UnitEntry;
+import org.apache.ignite.rest.client.model.UnitFile;
+import org.apache.ignite.rest.client.model.UnitFolder;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+class UnitStructureDecoratorTest {
+
+ @Test
+ @DisplayName("Tree view should display folder with files")
+ void treeViewWithFiles() {
+ // Given
+ UnitFolder folder = createFolderWithFiles("test-unit",
+ createFile("file1.txt", 100),
+ createFile("file2.txt", 200));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("test-unit"));
+ assertThat(output, containsString("file1.txt"));
+ assertThat(output, containsString("file2.txt"));
+ assertThat(output, containsString("100 B"));
+ assertThat(output, containsString("200 B"));
+ assertThat(output, containsString("+--"));
+ assertThat(output, containsString("\\--"));
+ }
+
+ @Test
+ @DisplayName("Tree view should display nested folders")
+ void treeViewWithNestedFolders() {
+ // Given
+ UnitFolder subFolder = createFolderWithFiles("subfolder",
+ createFile("nested.txt", 50));
+
+ UnitEntry subFolderEntry = new UnitEntry();
+ subFolderEntry.setActualInstance(subFolder);
+
+ UnitFolder rootFolder = new UnitFolder()
+ .type(UnitFolder.TypeEnum.FOLDER)
+ .name("root")
+ .children(List.of(subFolderEntry));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(rootFolder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("root"));
+ assertThat(output, containsString("subfolder"));
+ assertThat(output, containsString("nested.txt"));
+ assertThat(output, containsString("\\--"));
+ assertThat(output, containsString(" \\--")); // Nested indent
+ }
+
+ @Test
+ @DisplayName("Plain view should display file paths")
+ void plainViewWithFiles() {
+ // Given
+ UnitFolder folder = createFolderWithFiles("test-unit",
+ createFile("file1.txt", 100),
+ createFile("file2.txt", 200));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(true);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("file1.txt"));
+ assertThat(output, containsString("file2.txt"));
+ assertThat(output, containsString("100"));
+ assertThat(output, containsString("200"));
+ // Should not contain tree characters in plain mode
+ assertThat(output, not(containsString("├──")));
+ assertThat(output, not(containsString("└──")));
+ }
+
+ @Test
+ @DisplayName("Plain view should display nested paths")
+ void plainViewWithNestedFolders() {
+ // Given
+ UnitFolder subFolder = createFolderWithFiles("subfolder",
+ createFile("nested.txt", 50));
+
+ UnitEntry subFolderEntry = new UnitEntry();
+ subFolderEntry.setActualInstance(subFolder);
+
+ UnitFolder rootFolder = new UnitFolder()
+ .type(UnitFolder.TypeEnum.FOLDER)
+ .name("root")
+ .children(List.of(subFolderEntry));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(true);
+
+ // When
+ String output = decorator.decorate(rootFolder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("subfolder/nested.txt"));
+ assertThat(output, containsString("50"));
+ }
+
+ @Test
+ @DisplayName("Should format file sizes correctly")
+ void fileSizeFormatting() {
+ // Given
+ UnitFolder folder = createFolderWithFiles("test-unit",
+ createFile("small.txt", 512),
+ createFile("medium.txt", 2048),
+ createFile("large.txt", 1024 * 1024 * 2));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("512 B"));
+ assertThat(output, containsString("KiB"));
+ assertThat(output, containsString("MiB"));
+ }
+
+ @Test
+ @DisplayName("Should handle empty folder")
+ void emptyFolder() {
+ // Given
+ UnitFolder folder = new UnitFolder()
+ .type(UnitFolder.TypeEnum.FOLDER)
+ .name("empty-folder")
+ .children(List.of());
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("empty-folder"));
+ }
+
+ private UnitFolder createFolderWithFiles(String name, UnitFile... files) {
+ List<UnitEntry> children = new java.util.ArrayList<>();
+ long totalSize = 0;
+
+ for (UnitFile file : files) {
+ UnitEntry entry = new UnitEntry();
+ entry.setActualInstance(file);
+ children.add(entry);
+ totalSize += file.getSize();
+ }
Review Comment:
Fixed: Simplified the code using `Arrays.stream(files).map(UnitEntry::new).collect(Collectors.toList())` as suggested.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27201 Add CLI command to inspect deployment unit file tree [ignite-3]
Posted by "Pochatkin (via GitHub)" <gi...@apache.org>.
Pochatkin merged PR #7356:
URL: https://github.com/apache/ignite-3/pull/7356
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27201 Add CLI command to inspect deployment unit file tree [ignite-3]
Posted by "Pochatkin (via GitHub)" <gi...@apache.org>.
Pochatkin commented on code in PR #7356:
URL: https://github.com/apache/ignite-3/pull/7356#discussion_r2671998948
##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItNodeUnitStructureCommandTest.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.unit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertAll;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.internal.cli.CliIntegrationTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+/** Integration test for node unit structure command. */
+public class ItNodeUnitStructureCommandTest extends CliIntegrationTest {
Review Comment:
It tests new `node unit structure` command, but for state initialization we need to use `cluster unit deploy` command. Test name just shows what we test actually.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27201 Add CLI command to inspect deployment unit file tree [ignite-3]
Posted by "Pochatkin (via GitHub)" <gi...@apache.org>.
Pochatkin commented on code in PR #7356:
URL: https://github.com/apache/ignite-3/pull/7356#discussion_r2690325475
##########
modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/node/unit/NodeUnitStructureCommand.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.node.unit;
+
+import static org.apache.ignite.internal.cli.commands.Options.Constants.PLAIN_OPTION;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.PLAIN_OPTION_DESC;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.UNIT_VERSION_OPTION_DESC;
+import static org.apache.ignite.internal.cli.commands.Options.Constants.VERSION_OPTION;
+
+import jakarta.inject.Inject;
+import java.util.concurrent.Callable;
+import org.apache.ignite.internal.cli.call.node.unit.NodeUnitStructureCall;
+import org.apache.ignite.internal.cli.call.unit.UnitStructureCallInput;
+import org.apache.ignite.internal.cli.commands.BaseCommand;
+import org.apache.ignite.internal.cli.commands.node.NodeUrlProfileMixin;
+import org.apache.ignite.internal.cli.core.call.CallExecutionPipeline;
+import org.apache.ignite.internal.cli.core.exception.handler.ClusterNotInitializedExceptionHandler;
+import org.apache.ignite.internal.cli.decorators.UnitStructureDecorator;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Mixin;
+import picocli.CommandLine.Option;
+import picocli.CommandLine.Parameters;
+
+/** Command to show deployment unit structure. */
+@Command(name = "structure", description = "Shows the structure of a deployed unit")
Review Comment:
Done
##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItNodeUnitStructureCommandTest.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.unit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertAll;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.internal.cli.CliIntegrationTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+/** Integration test for node unit structure command. */
+public class ItNodeUnitStructureCommandTest extends CliIntegrationTest {
+ private static String testFile;
+
+ private static Path testDirectory;
+
+ @BeforeAll
+ static void beforeAll() throws IOException {
+ testDirectory = Files.createDirectory(WORK_DIR.resolve("test-structure"));
+ testFile = Files.createFile(testDirectory.resolve("test.txt")).toString();
+ Files.createFile(testDirectory.resolve("test2.txt"));
+ Files.createFile(testDirectory.resolve("test3.txt"));
Review Comment:
Done
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-27201 Add CLI command to inspect deployment unit file tree [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #7356:
URL: https://github.com/apache/ignite-3/pull/7356#discussion_r2685715085
##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItNodeUnitStructureCommandTest.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.unit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertAll;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.internal.cli.CliIntegrationTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+/** Integration test for node unit structure command. */
+public class ItNodeUnitStructureCommandTest extends CliIntegrationTest {
+ private static String testFile;
+
+ private static Path testDirectory;
+
+ @BeforeAll
+ static void beforeAll() throws IOException {
+ testDirectory = Files.createDirectory(WORK_DIR.resolve("test-structure"));
+ testFile = Files.createFile(testDirectory.resolve("test.txt")).toString();
+ Files.createFile(testDirectory.resolve("test2.txt"));
+ Files.createFile(testDirectory.resolve("test3.txt"));
+ }
+
+ @Test
+ @DisplayName("Should display unit structure with tree view")
+ void structureTreeView() {
+ // Given deployed unit
+ String id = "test.structure.unit.1";
+ execute("cluster", "unit", "deploy", id, "--version", "1.0.0", "--path", testDirectory.toString());
+
+ await().untilAsserted(() -> {
+ execute("cluster", "unit", "list", "--plain", id);
+ assertExitCodeIsZero();
+ });
+
+ // When get structure
+ execute("node", "unit", "structure", id, "--version", "1.0.0");
+
+ // Then
+ assertAll(
+ this::assertExitCodeIsZero,
+ this::assertErrOutputIsEmpty,
+ () -> assertOutputContains(id),
+ () -> assertOutputContains("test.txt"),
+ () -> assertOutputContains("test2.txt"),
+ () -> assertOutputContains("test3.txt"),
+ () -> assertOutputContains(" B)") // File size display
+ );
+ }
+
+ @Test
+ @DisplayName("Should display unit structure with plain view")
+ void structurePlainView() {
+ // Given deployed unit
+ String id = "test.structure.unit.2";
+ execute("cluster", "unit", "deploy", id, "--version", "1.0.0", "--path", testDirectory.toString());
+
+ await().untilAsserted(() -> {
+ execute("cluster", "unit", "list", "--plain", id);
+ assertExitCodeIsZero();
+ });
+
+ // When get structure with plain option
+ execute("node", "unit", "structure", id, "--version", "1.0.0", "--plain");
+
+ // Then
+ assertAll(
+ this::assertExitCodeIsZero,
+ this::assertErrOutputIsEmpty,
+ () -> assertOutputContains("test.txt"),
Review Comment:
Can we test the exact output at least in the plain case?
##########
modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItNodeUnitStructureCommandTest.java:
##########
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.commands.unit;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertAll;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.apache.ignite.internal.cli.CliIntegrationTest;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+/** Integration test for node unit structure command. */
+public class ItNodeUnitStructureCommandTest extends CliIntegrationTest {
+ private static String testFile;
+
+ private static Path testDirectory;
+
+ @BeforeAll
+ static void beforeAll() throws IOException {
+ testDirectory = Files.createDirectory(WORK_DIR.resolve("test-structure"));
+ testFile = Files.createFile(testDirectory.resolve("test.txt")).toString();
+ Files.createFile(testDirectory.resolve("test2.txt"));
+ Files.createFile(testDirectory.resolve("test3.txt"));
+ }
+
+ @Test
+ @DisplayName("Should display unit structure with tree view")
+ void structureTreeView() {
+ // Given deployed unit
+ String id = "test.structure.unit.1";
+ execute("cluster", "unit", "deploy", id, "--version", "1.0.0", "--path", testDirectory.toString());
+
+ await().untilAsserted(() -> {
+ execute("cluster", "unit", "list", "--plain", id);
+ assertExitCodeIsZero();
+ });
+
+ // When get structure
+ execute("node", "unit", "structure", id, "--version", "1.0.0");
+
+ // Then
+ assertAll(
+ this::assertExitCodeIsZero,
+ this::assertErrOutputIsEmpty,
+ () -> assertOutputContains(id),
+ () -> assertOutputContains("test.txt"),
+ () -> assertOutputContains("test2.txt"),
+ () -> assertOutputContains("test3.txt"),
+ () -> assertOutputContains(" B)") // File size display
+ );
+ }
+
+ @Test
+ @DisplayName("Should display unit structure with plain view")
+ void structurePlainView() {
+ // Given deployed unit
+ String id = "test.structure.unit.2";
+ execute("cluster", "unit", "deploy", id, "--version", "1.0.0", "--path", testDirectory.toString());
+
+ await().untilAsserted(() -> {
+ execute("cluster", "unit", "list", "--plain", id);
+ assertExitCodeIsZero();
+ });
+
+ // When get structure with plain option
+ execute("node", "unit", "structure", id, "--version", "1.0.0", "--plain");
+
+ // Then
+ assertAll(
+ this::assertExitCodeIsZero,
+ this::assertErrOutputIsEmpty,
+ () -> assertOutputContains("test.txt"),
+ () -> assertOutputContains("test2.txt"),
+ () -> assertOutputContains("test3.txt")
+ );
+ }
+
+ @Test
+ @DisplayName("Should display error when version is missing")
+ void structureVersionIsMandatory() {
+ // When get structure without version
+ execute("node", "unit", "structure", "test.unit.id");
+
+ // Then
+ assertAll(
+ () -> assertExitCodeIs(2),
+ () -> assertErrOutputContains("Missing required option: '--version=<version>'"),
+ this::assertOutputIsEmpty
+ );
+ }
+
+ @Test
+ @DisplayName("Should display error when unit does not exist")
+ void structureUnitNotFound() {
+ // When get structure of non-existing unit
+ execute("node", "unit", "structure", "non.existing.unit", "--version", "1.0.0");
+
+ // Then
+ assertAll(
+ this::assertExitCodeIsError,
+ () -> assertErrOutputContains("not found")
Review Comment:
Again, can we verify the exact error output?
##########
modules/cli/src/test/java/org/apache/ignite/internal/cli/decorators/UnitStructureDecoratorTest.java:
##########
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.cli.decorators;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.not;
+
+import java.util.List;
+import org.apache.ignite.rest.client.model.UnitEntry;
+import org.apache.ignite.rest.client.model.UnitFile;
+import org.apache.ignite.rest.client.model.UnitFolder;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+class UnitStructureDecoratorTest {
+
+ @Test
+ @DisplayName("Tree view should display folder with files")
+ void treeViewWithFiles() {
+ // Given
+ UnitFolder folder = createFolderWithFiles("test-unit",
+ createFile("file1.txt", 100),
+ createFile("file2.txt", 200));
+
+ UnitStructureDecorator decorator = new UnitStructureDecorator(false);
+
+ // When
+ String output = decorator.decorate(folder).toTerminalString();
+
+ // Then
+ assertThat(output, containsString("test-unit"));
Review Comment:
Let's verify exact output here as well
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org