This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push: new b04fd3c47a upgrade nacos client from 1.4.2 to 2.3.2 (#12362) b04fd3c47a is described below commit b04fd3c47a5847925efab199dcb7c91f8cae190c Author: shalk(xiao kun) <xsh...@163.com> AuthorDate: Wed Jun 26 11:41:34 2024 +0800 upgrade nacos client from 1.4.2 to 2.3.2 (#12362) --- apm-dist/pom.xml | 11 +++++ dist-material/release-docs/LICENSE | 53 ++++++++++----------- docs/en/changes/changes.md | 1 + docs/en/setup/backend/backend-cluster.md | 2 + docs/en/setup/backend/dynamic-config-nacos.md | 4 +- oap-server-bom/pom.xml | 9 +++- .../cluster-nacos-plugin/pom.xml | 26 ---------- .../ClusterModuleNacosProviderFunctionalIT.java | 28 ++++++----- .../configuration/nacos/NacosConfigurationIT.java | 55 ++++++++++++++-------- .../src/main/resources/application.yml | 2 +- 10 files changed, 104 insertions(+), 87 deletions(-) diff --git a/apm-dist/pom.xml b/apm-dist/pom.xml index e7d4c611b5..8d0cd96d79 100644 --- a/apm-dist/pom.xml +++ b/apm-dist/pom.xml @@ -34,6 +34,17 @@ <activation> <activeByDefault>true</activeByDefault> </activation> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.skywalking</groupId> + <artifactId>oap-server-bom</artifactId> + <version>${project.version}</version> + <scope>import</scope> + <type>pom</type> + </dependency> + </dependencies> + </dependencyManagement> <dependencies> <dependency> <groupId>org.apache.skywalking</groupId> diff --git a/dist-material/release-docs/LICENSE b/dist-material/release-docs/LICENSE index 8d11ad1104..efce54ed31 100644 --- a/dist-material/release-docs/LICENSE +++ b/dist-material/release-docs/LICENSE @@ -212,14 +212,14 @@ The text of each license is the standard Apache 2.0 license. https://mvnrepository.com/artifact/build.buf.protoc-gen-validate/protoc-gen-validate/0.6.13 Apache-2.0 https://mvnrepository.com/artifact/com.aayushatharva.brotli4j/brotli4j/1.15.0 Apache-2.0 https://mvnrepository.com/artifact/com.aayushatharva.brotli4j/service/1.15.0 Apache-2.0 - https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-api/1.4.2 Apache-2.0 - https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-client/1.4.2 Apache-2.0 - https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-common/1.4.2 Apache-2.0 + https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-auth-plugin/2.3.2 Apache-2.0 + https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-client/2.3.2 Apache-2.0 + https://mvnrepository.com/artifact/com.alibaba.nacos/nacos-encryption-plugin/2.3.2 Apache-2.0 https://mvnrepository.com/artifact/com.ctrip.framework.apollo/apollo-client/1.8.0 Apache-2.0 https://mvnrepository.com/artifact/com.ctrip.framework.apollo/apollo-core/1.8.0 Apache-2.0 - https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations/2.16.1 Apache-2.0 - https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core/2.16.1 Apache-2.0 - https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.16.1 Apache-2.0 + https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations/2.16.0 Apache-2.0 + https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core/2.16.0 Apache-2.0 + https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.16.0 Apache-2.0 https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.15.2 Apache-2.0 https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-guava/2.12.0 Apache-2.0 https://mvnrepository.com/artifact/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.16.1 Apache-2.0 @@ -243,15 +243,14 @@ The text of each license is the standard Apache 2.0 license. https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-graphql-protocol/1.27.3 Apache-2.0 https://mvnrepository.com/artifact/com.linecorp.armeria/armeria-protobuf/1.27.3 Apache-2.0 https://mvnrepository.com/artifact/com.orbitz.consul/consul-client/1.5.3 Apache-2.0 - https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/4.9.0 Apache-2.0 - https://mvnrepository.com/artifact/com.squareup.okio/okio/2.8.0 Apache-2.0 + https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp/3.14.9 Apache-2.0 + https://mvnrepository.com/artifact/com.squareup.okio/okio/1.17.2 Apache-2.0 https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-jackson/2.9.0 Apache-2.0 https://mvnrepository.com/artifact/com.squareup.retrofit2/retrofit/2.9.0 Apache-2.0 https://mvnrepository.com/artifact/com.zaxxer/HikariCP/3.1.0 Apache-2.0 https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils/1.9.4 Apache-2.0 https://mvnrepository.com/artifact/commons-codec/commons-codec/1.11 Apache-2.0 https://mvnrepository.com/artifact/commons-io/commons-io/2.7 Apache-2.0 - https://mvnrepository.com/artifact/commons-logging/commons-logging/1.2 Apache-2.0 https://mvnrepository.com/artifact/commons-net/commons-net/3.9.0 Apache-2.0 https://mvnrepository.com/artifact/commons-validator/commons-validator/1.7 Apache-2.0 https://npmjs.com/package/d3-flame-graph/v/4.1.3 4.1.3 Apache-2.0 @@ -303,29 +302,27 @@ The text of each license is the standard Apache 2.0 license. https://mvnrepository.com/artifact/io.micrometer/micrometer-observation/1.12.2 Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-buffer/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-codec/4.1.108.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-codec-dns/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-codec-haproxy/4.1.106.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-codec-dns/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-codec-haproxy/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-codec-http/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-codec-http2/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-codec-socks/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-common/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-handler/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-handler-proxy/4.1.108.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-resolver/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-resolver-dns/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-resolver-dns-classes-macos/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-resolver-dns-native-macos/4.1.106.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-resolver/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-resolver-dns/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-resolver-dns-classes-macos/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-resolver-dns-native-macos/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.netty/netty-tcnative-boringssl-static/2.0.52.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-tcnative-boringssl-static/2.0.61.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-tcnative-classes/2.0.61.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-transport/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-transport-classes-epoll/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-transport-classes-kqueue/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-transport-native-epoll/4.1.45.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-transport-native-epoll/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-transport-native-kqueue/4.1.106.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-transport-native-unix-common/4.1.100.Final Apache-2.0 - https://mvnrepository.com/artifact/io.netty/netty-transport-native-unix-common/4.1.106.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-tcnative-boringssl-static/2.0.65.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-tcnative-classes/2.0.65.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-transport/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-transport-classes-epoll/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-transport-classes-kqueue/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-transport-native-epoll/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-transport-native-kqueue/4.1.108.Final Apache-2.0 + https://mvnrepository.com/artifact/io.netty/netty-transport-native-unix-common/4.1.108.Final Apache-2.0 https://mvnrepository.com/artifact/io.perfmark/perfmark-api/0.26.0 Apache-2.0 https://mvnrepository.com/artifact/io.prometheus/simpleclient/0.6.0 Apache-2.0 https://mvnrepository.com/artifact/io.prometheus/simpleclient_common/0.6.0 Apache-2.0 @@ -337,15 +334,15 @@ The text of each license is the standard Apache 2.0 license. https://mvnrepository.com/artifact/javax.inject/javax.inject/1 Apache-2.0 https://mvnrepository.com/artifact/joda-time/joda-time/2.10.5 Apache-2.0 https://mvnrepository.com/artifact/net.jodah/failsafe/2.4.4 Apache-2.0 - https://mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.11 Apache-2.0 + https://mvnrepository.com/artifact/org.apache.commons/commons-lang3/3.12.0 Apache-2.0 https://mvnrepository.com/artifact/org.apache.commons/commons-text/1.4 Apache-2.0 https://mvnrepository.com/artifact/org.apache.curator/curator-client/4.3.0 Apache-2.0 https://mvnrepository.com/artifact/org.apache.curator/curator-framework/4.3.0 Apache-2.0 https://mvnrepository.com/artifact/org.apache.curator/curator-recipes/4.3.0 Apache-2.0 https://mvnrepository.com/artifact/org.apache.curator/curator-x-discovery/4.3.0 Apache-2.0 https://mvnrepository.com/artifact/org.apache.groovy/groovy/4.0.15 Apache-2.0 - https://mvnrepository.com/artifact/org.apache.httpcomponents/httpasyncclient/4.1.3 Apache-2.0 - https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.3 Apache-2.0 + https://mvnrepository.com/artifact/org.apache.httpcomponents/httpasyncclient/4.1.5 Apache-2.0 + https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient/4.5.13 Apache-2.0 https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore/4.4.13 Apache-2.0 https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore-nio/4.4.13 Apache-2.0 https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients/3.4.0 Apache-2.0 diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md index a899293562..db9ac07b0c 100644 --- a/docs/en/changes/changes.md +++ b/docs/en/changes/changes.md @@ -19,6 +19,7 @@ * Add Python as a supported language for Pulsar. * Make more proper histogram buckets for the `persistence_timer_bulk_prepare_latency`, `persistence_timer_bulk_execute_latency` and `persistence_timer_bulk_all_latency` metrics in PersistenceTimer. +* [Break Change] Update Nacos version to 2.3.2. Nacos 1.x server can't serve as cluster coordinator and configuration server. #### UI diff --git a/docs/en/setup/backend/backend-cluster.md b/docs/en/setup/backend/backend-cluster.md index b26416ae10..190cf1122b 100644 --- a/docs/en/setup/backend/backend-cluster.md +++ b/docs/en/setup/backend/backend-cluster.md @@ -181,6 +181,8 @@ The following settings are provided to set the host and port manually, based on Set the **cluster/selector** to **nacos** in the yml to enable it. +Nacos 2.x is required. + ```yaml cluster: selector: ${SW_CLUSTER:nacos} diff --git a/docs/en/setup/backend/dynamic-config-nacos.md b/docs/en/setup/backend/dynamic-config-nacos.md index 90a8461809..4d33c7ab70 100755 --- a/docs/en/setup/backend/dynamic-config-nacos.md +++ b/docs/en/setup/backend/dynamic-config-nacos.md @@ -1,6 +1,8 @@ # Dynamic Configuration Nacos Implementation -[Nacos](https://github.com/alibaba/nacos) is also supported as a Dynamic Configuration Center (DCC). To use it, please configure it as follows: +[Nacos](https://github.com/alibaba/nacos) 2.x is also supported as a Dynamic Configuration Center (DCC). + +To use it, please configure it as follows: ```yaml configuration: diff --git a/oap-server-bom/pom.xml b/oap-server-bom/pom.xml index f68c18a0dd..4076469305 100644 --- a/oap-server-bom/pom.xml +++ b/oap-server-bom/pom.xml @@ -54,7 +54,7 @@ <jackson-databind.version>2.16.0</jackson-databind.version> <simpleclient.version>0.6.0</simpleclient.version> <apollo.version>1.8.0</apollo.version> - <nacos.version>1.4.2</nacos.version> + <nacos.version>2.3.2</nacos.version> <curator.version>4.3.0</curator.version> <curator-test.version>2.12.0</curator-test.version> <etcd4j.version>2.18.0</etcd4j.version> @@ -71,6 +71,7 @@ <armeria.version>1.27.3</armeria.version> <awaitility.version>3.0.0</awaitility.version> <httpcore.version>4.4.13</httpcore.version> + <httpasyncclient.version>4.1.5</httpasyncclient.version> <commons-compress.version>1.21</commons-compress.version> <banyandb-java-client.version>0.6.0</banyandb-java-client.version> <kafka-clients.version>3.4.0</kafka-clients.version> @@ -518,6 +519,12 @@ <version>${httpclient.version}</version> </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpasyncclient</artifactId> + <version>${httpasyncclient.version}</version> + </dependency> + <dependency> <groupId>com.google.flatbuffers</groupId> <artifactId>flatbuffers-java</artifactId> diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/pom.xml b/oap-server/server-cluster-plugin/cluster-nacos-plugin/pom.xml index 1f56610049..6d6294fe23 100644 --- a/oap-server/server-cluster-plugin/cluster-nacos-plugin/pom.xml +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/pom.xml @@ -35,32 +35,6 @@ <dependency> <groupId>com.alibaba.nacos</groupId> <artifactId>nacos-client</artifactId> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-core</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.logging.log4j</groupId> - <artifactId>log4j-slf4j-impl</artifactId> - </exclusion> - <exclusion> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - </exclusion> - <exclusion> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-core</artifactId> - </exclusion> - <exclusion> - <groupId>net.jcip</groupId> - <artifactId>jcip-annotations</artifactId> - </exclusion> - </exclusions> </dependency> <!-- Override the dependency to use the same version of httpcore-nio --> <dependency> diff --git a/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProviderFunctionalIT.java b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProviderFunctionalIT.java index 0c82fae730..322d87de3e 100644 --- a/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProviderFunctionalIT.java +++ b/oap-server/server-cluster-plugin/cluster-nacos-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/nacos/ClusterModuleNacosProviderFunctionalIT.java @@ -19,6 +19,9 @@ package org.apache.skywalking.oap.server.cluster.plugin.nacos; import com.alibaba.nacos.api.naming.NamingService; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import lombok.Getter; import org.apache.skywalking.oap.server.core.cluster.ClusterCoordinator; import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery; @@ -33,6 +36,7 @@ import org.apache.skywalking.oap.server.telemetry.TelemetryModule; import org.apache.skywalking.oap.server.telemetry.api.MetricsCreator; import org.apache.skywalking.oap.server.telemetry.none.MetricsCreatorNoop; import org.apache.skywalking.oap.server.telemetry.none.NoneTelemetryProvider; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -46,10 +50,6 @@ import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -58,17 +58,16 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @ExtendWith(MockitoExtension.class) public class ClusterModuleNacosProviderFunctionalIT { - private String nacosAddress; - private final String username = "nacos"; - private final String password = "nacos"; - @Container public final GenericContainer<?> container = - new GenericContainer<>(DockerImageName.parse("nacos/nacos-server:1.4.2")) + new GenericContainer<>(DockerImageName.parse("nacos/nacos-server:v2.3.2-slim")) .waitingFor(Wait.forLogMessage(".*Nacos started successfully.*", 1)) .withEnv(Collections.singletonMap("MODE", "standalone")) - .withExposedPorts(8848); - + .withLogConsumer(outputFrame -> System.out.print(outputFrame.getUtf8String())) + .withExposedPorts(8848, 9848); + private final String username = "nacos"; + private final String password = "nacos"; + private String nacosAddress; @Mock private ModuleManager moduleManager; @Mock @@ -82,6 +81,13 @@ public class ClusterModuleNacosProviderFunctionalIT { Whitebox.setInternalState(telemetryModule, "loadedProvider", telemetryProvider); Mockito.when(moduleManager.find(TelemetryModule.NAME)).thenReturn(telemetryModule); nacosAddress = container.getHost() + ":" + container.getMappedPort(8848); + Integer nacosPortOffset = container.getMappedPort(9848) - container.getMappedPort(8848); + System.setProperty("nacos.server.grpc.port.offset", nacosPortOffset.toString()); + } + + @AfterEach + public void after() { + System.clearProperty("nacos.server.grpc.port.offset"); } @Test diff --git a/oap-server/server-configuration/configuration-nacos/src/test/java/org/apache/skywalking/oap/server/configuration/nacos/NacosConfigurationIT.java b/oap-server/server-configuration/configuration-nacos/src/test/java/org/apache/skywalking/oap/server/configuration/nacos/NacosConfigurationIT.java index 9f65b03a5e..718a70475e 100644 --- a/oap-server/server-configuration/configuration-nacos/src/test/java/org/apache/skywalking/oap/server/configuration/nacos/NacosConfigurationIT.java +++ b/oap-server/server-configuration/configuration-nacos/src/test/java/org/apache/skywalking/oap/server/configuration/nacos/NacosConfigurationIT.java @@ -21,12 +21,18 @@ package org.apache.skywalking.oap.server.configuration.nacos; import com.alibaba.nacos.api.NacosFactory; import com.alibaba.nacos.api.config.ConfigService; import com.alibaba.nacos.api.exception.NacosException; +import java.io.FileNotFoundException; +import java.io.Reader; +import java.util.Collections; +import java.util.Map; +import java.util.Properties; import lombok.extern.slf4j.Slf4j; import org.apache.skywalking.oap.server.library.module.ApplicationConfiguration; import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.library.util.CollectionUtils; import org.apache.skywalking.oap.server.library.util.PropertyPlaceholderHelper; import org.apache.skywalking.oap.server.library.util.ResourceUtils; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -37,12 +43,6 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; import org.yaml.snakeyaml.Yaml; -import java.io.FileNotFoundException; -import java.io.Reader; -import java.util.Collections; -import java.util.Map; -import java.util.Properties; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -51,16 +51,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @Slf4j @Testcontainers public class NacosConfigurationIT { - private final Yaml yaml = new Yaml(); - - private NacosConfigurationTestProvider provider; - @Container public final GenericContainer<?> container = - new GenericContainer<>(DockerImageName.parse("nacos/nacos-server:1.4.2")) + new GenericContainer<>(DockerImageName.parse("nacos/nacos-server:v2.3.2-slim")) .waitingFor(Wait.forLogMessage(".*Nacos started successfully.*", 1)) .withEnv(Collections.singletonMap("MODE", "standalone")) - .withExposedPorts(8848); + .withExposedPorts(8848, 9848); + private final Yaml yaml = new Yaml(); + private NacosConfigurationTestProvider provider; @BeforeEach public void setUp() throws Exception { @@ -76,6 +74,13 @@ public class NacosConfigurationIT { provider = (NacosConfigurationTestProvider) moduleManager.find(NacosConfigurationTestModule.NAME).provider(); assertNotNull(provider); + Integer nacosPortOffset = container.getMappedPort(9848) - container.getMappedPort(8848); + System.setProperty("nacos.server.grpc.port.offset", nacosPortOffset.toString()); + } + + @AfterEach + public void after() { + System.clearProperty("nacos.server.grpc.port.offset"); } @SuppressWarnings("StatementWithEmptyBody") @@ -122,28 +127,38 @@ public class NacosConfigurationIT { assertTrue(configService.publishConfig("test-module.default.testKeyGroup", "skywalking", "item1\n item2")); assertTrue(configService.publishConfig("item1", "skywalking", "100")); assertTrue(configService.publishConfig("item2", "skywalking", "200")); - for (String v = provider.groupWatcher.groupItems().get("item1"); v == null; v = provider.groupWatcher.groupItems().get("item1")) { + for (String v = provider.groupWatcher.groupItems() + .get("item1"); v == null; v = provider.groupWatcher.groupItems() + .get("item1")) { } - for (String v = provider.groupWatcher.groupItems().get("item2"); v == null; v = provider.groupWatcher.groupItems().get("item2")) { + for (String v = provider.groupWatcher.groupItems() + .get("item2"); v == null; v = provider.groupWatcher.groupItems() + .get("item2")) { } assertEquals("100", provider.groupWatcher.groupItems().get("item1")); assertEquals("200", provider.groupWatcher.groupItems().get("item2")); //test remove item1 assertTrue(configService.removeConfig("item1", "skywalking")); - for (String v = provider.groupWatcher.groupItems().get("item1"); v != null; v = provider.groupWatcher.groupItems().get("item1")) { + for (String v = provider.groupWatcher.groupItems() + .get("item1"); v != null; v = provider.groupWatcher.groupItems() + .get("item1")) { } assertNull(provider.groupWatcher.groupItems().get("item1")); //test modify item1 assertTrue(configService.publishConfig("item1", "skywalking", "300")); - for (String v = provider.groupWatcher.groupItems().get("item1"); v == null; v = provider.groupWatcher.groupItems().get("item1")) { + for (String v = provider.groupWatcher.groupItems() + .get("item1"); v == null; v = provider.groupWatcher.groupItems() + .get("item1")) { } assertEquals("300", provider.groupWatcher.groupItems().get("item1")); //test remove group key assertTrue(configService.removeConfig("test-module.default.testKeyGroup", "skywalking")); - for (String v = provider.groupWatcher.groupItems().get("item2"); v != null; v = provider.groupWatcher.groupItems().get("item2")) { + for (String v = provider.groupWatcher.groupItems() + .get("item2"); v != null; v = provider.groupWatcher.groupItems() + .get("item2")) { } assertNull(provider.groupWatcher.groupItems().get("item2")); //chean @@ -158,13 +173,15 @@ public class NacosConfigurationIT { if (CollectionUtils.isNotEmpty(moduleConfig)) { moduleConfig.forEach((moduleName, providerConfig) -> { if (providerConfig.size() > 0) { - ApplicationConfiguration.ModuleConfiguration moduleConfiguration = configuration.addModule(moduleName); + ApplicationConfiguration.ModuleConfiguration moduleConfiguration = configuration.addModule( + moduleName); providerConfig.forEach((name, propertiesConfig) -> { Properties properties = new Properties(); if (propertiesConfig != null) { propertiesConfig.forEach((key, value) -> { properties.put(key, value); - final Object replaceValue = yaml.load(PropertyPlaceholderHelper.INSTANCE.replacePlaceholders(value + "", properties)); + final Object replaceValue = yaml.load( + PropertyPlaceholderHelper.INSTANCE.replacePlaceholders(value + "", properties)); if (replaceValue != null) { properties.replace(key, replaceValue); } diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml index 9e391d4921..c647418c46 100644 --- a/oap-server/server-starter/src/main/resources/application.yml +++ b/oap-server/server-starter/src/main/resources/application.yml @@ -54,7 +54,7 @@ cluster: nacos: serviceName: ${SW_SERVICE_NAME:"SkyWalking_OAP_Cluster"} hostPort: ${SW_CLUSTER_NACOS_HOST_PORT:localhost:8848} - # Nacos Configuration namespace + # Nacos Naming namespace namespace: ${SW_CLUSTER_NACOS_NAMESPACE:"public"} # Nacos auth username username: ${SW_CLUSTER_NACOS_USERNAME:""}