SammyVimes commented on code in PR #948: URL: https://github.com/apache/ignite-3/pull/948#discussion_r929211038
########## modules/cli/src/integrationTest/java/org/apache/ignite/cli/commands/cluster/status/ItClusterStatusReplCommandInitializedTest.java: ########## @@ -0,0 +1,55 @@ +/* + * 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.cli.commands.cluster.status; + +import static org.junit.jupiter.api.Assertions.assertAll; + +import org.apache.ignite.cli.commands.CliCommandTestInitializedIntegrationBase; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; + +/** + * Tests for {@link ClusterStatusReplSubCommand} for the cluster that is initialized. + */ +class ItClusterStatusReplCommandInitializedTest extends CliCommandTestInitializedIntegrationBase { + + String metaStorageNodeName; + + @BeforeAll + void setUpMsNodeName(TestInfo testInfo) { + metaStorageNodeName = metaStorageNodeName(testInfo); Review Comment: It seems like metastorage node name is always `testNodeName(testInfo, 0)`, so probably we may rewrite initializeCluster method to use that by default ########## modules/cli/src/integrationTest/java/org/apache/ignite/rest/ItGeneratedRestClientTest.java: ########## @@ -291,6 +296,20 @@ void nodeState() { }); } + @Test + void logicalTopology() { + assertDoesNotThrow(() -> { + assertThat(topologyApi.logical(), hasSize(3)); + }); + } + + @Test + void physicalTopology() { + assertDoesNotThrow(() -> { Review Comment: same thing about assertDoesNotThrow ########## modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/cluster/TopologyApi.java: ########## @@ -0,0 +1,65 @@ +/* + * 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.rest.api.cluster; + +import io.micronaut.http.annotation.Controller; +import io.micronaut.http.annotation.Get; +import io.micronaut.http.annotation.Produces; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.Collection; +import org.apache.ignite.internal.rest.api.Problem; +import org.apache.ignite.internal.rest.constants.MediaType; + +/** + * Cluster topology endpoint. + */ +@Controller("/management/v1/cluster/topology") +@Tag(name = "topology") +public interface TopologyApi { + + /** + * Cluster physical topology. + */ + @Get("physical") + @Operation(operationId = "physical") + @ApiResponses({ Review Comment: ApiResponses annotation should not be used directly because ApiResponse is a `@Repeatable` annotation. So it should be just ``` @ApiResponse(responseCode = "200", ...), @ApiResponse(responseCode = "500", ...) @Produces(MediaType.APPLICATION_JSON) Collection<ClusterNodeDto> physicalTopology(); ``` ########## modules/cli/src/integrationTest/java/org/apache/ignite/cli/call/CallInitializedIntegrationTestBase.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.cli.call; + +import static org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName; + +import java.util.concurrent.ExecutionException; +import org.apache.ignite.cli.IntegrationTestBase; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInfo; + +/** + * Base class for call integration tests that needs initialized ignite cluster. Contains common methods and useful assertions. + */ +public class CallInitializedIntegrationTestBase extends IntegrationTestBase { + @BeforeAll + void beforeAll(TestInfo testInfo) throws ExecutionException, InterruptedException { + startNodes(testInfo); + String metaStorageNodeName = testNodeName(testInfo, 0); + super.initializeCluster(metaStorageNodeName); Review Comment: I'm curious, why `super.` is needed here? ########## modules/rest/openapi/openapi.yaml: ########## @@ -61,6 +61,48 @@ paths: application/problem+json: schema: $ref: '#/components/schemas/Problem' + /management/v1/cluster/topology/logical: Review Comment: just out of curiosity: why do we need this file if we use Swagger that generates schema? ########## modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/cluster/NetworkAddressDto.java: ########## @@ -0,0 +1,90 @@ +/* + * 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.rest.api.cluster; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import java.io.Serializable; +import org.apache.ignite.network.NetworkAddress; +import org.jetbrains.annotations.Nullable; + +/** + * REST representation of {@link NetworkAddress}. + */ +@Schema(name = "NetworkAddress") +public class NetworkAddressDto implements Serializable { Review Comment: Should it be `Serializable`? ########## modules/cli/src/integrationTest/java/org/apache/ignite/rest/ItGeneratedRestClientTest.java: ########## @@ -291,6 +296,20 @@ void nodeState() { }); } + @Test + void logicalTopology() { + assertDoesNotThrow(() -> { Review Comment: `assertDoesNotThrow` seems redundant here as there is `assertThat` inside it, so if it throws, the test fails anyway -- 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]
