Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8abfdff
添加etcd注册发现代码,添加测试模块
SweetWuXiaoMei Oct 12, 2024
ee26b4c
feat(registry-etcd,demo-etcd): implement the basic discovery function…
Oct 14, 2024
93e4cc8
fix(registry-etcd,demo-etcd): complete etcd registry function
SweetWuXiaoMei Oct 18, 2024
af6a984
Merge branch 'apache:master' into dev_czd_etcd
SweetWuXiaoMei Oct 21, 2024
c31c000
fix(registry-etcd,demo-etcd): fix pr probleam
SweetWuXiaoMei Oct 22, 2024
1cf63d2
Merge remote-tracking branch 'origin' into dev_czd_etcd
SweetWuXiaoMei Oct 22, 2024
2c64e42
Merge remote-tracking branch 'origin/dev_czd_etcd' into dev_czd_etcd
SweetWuXiaoMei Oct 22, 2024
cf55f27
refactor(registry-etcd): Refactor the EtcdDiscovery class and update …
SweetWuXiaoMei Oct 23, 2024
fae1f3b
fix(registry-etcd): Support Etcd authentication and optimize the inst…
SweetWuXiaoMei Oct 25, 2024
3686491
fix(provider): fix the content returned by sayHello interface
SweetWuXiaoMei Oct 25, 2024
4915a8c
refactor(registry-etcd): Refactor the EtcdDiscovery class
SweetWuXiaoMei Oct 28, 2024
cc6c800
refactor(registry-etcd): Refactor the EtcdDiscovery class and update …
SweetWuXiaoMei Oct 28, 2024
0cdcbca
restore runnable version
SweetWuXiaoMei Oct 29, 2024
2c06dc9
feat(config): Add etcd configuration support
SweetWuXiaoMei Nov 8, 2024
323495a
Merge branch 'master' into dev_czd_etcd
SweetWuXiaoMei Nov 11, 2024
19d612f
Removed redundant annotations in MuteExceptionUtil Removed redundant …
SweetWuXiaoMei Nov 11, 2024
ce033dc
refactor:delete unused {}
SweetWuXiaoMei Nov 11, 2024
e7c3970
refactor:restore protobuf version
SweetWuXiaoMei Nov 11, 2024
6ce7fc3
refactor:support arm architecter
SweetWuXiaoMei Nov 12, 2024
ff0fe3c
build(docker): restore openjdk:17-alpine
SweetWuXiaoMei Nov 12, 2024
b4f8c56
test(etcd): add log and remove test
SweetWuXiaoMei Nov 12, 2024
39e9873
test(etcd): test whether location is etcd
SweetWuXiaoMei Nov 12, 2024
af2cda2
test(etcd): test
SweetWuXiaoMei Nov 12, 2024
003bf61
test(etcd): test
SweetWuXiaoMei Nov 12, 2024
cb3912b
test(etcd): test
SweetWuXiaoMei Nov 12, 2024
cd55528
test(demo-etcd): Update the test case to verify the source of the con…
SweetWuXiaoMei Nov 13, 2024
e099d8d
fix(config-etcd): Fix configuration update exception information
SweetWuXiaoMei Nov 13, 2024
3120ae0
refactor(registry-etcd): Refactor the EtcdDiscovery class and add asy…
SweetWuXiaoMei Nov 13, 2024
d09eb57
feat(config-etcd): Add configuration parameters and optimize the Etcd…
SweetWuXiaoMei Nov 13, 2024
9ab3442
refactor(config-etcd): Remove the unused Charset import package. The …
SweetWuXiaoMei Nov 13, 2024
13c8de0
fix(service-registry): Fix etcd service version acquisition problem
SweetWuXiaoMei Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/demo-etcd/gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.25.3</version>
<version>3.25.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down
6 changes: 5 additions & 1 deletion demo/demo-etcd/provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.25.3</version>
<version>3.25.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-etcd</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>config-etcd</artifactId>
</dependency>

<dependency>
<groupId>io.reactivex.rxjava3</groupId>
Expand Down
11 changes: 11 additions & 0 deletions demo/demo-etcd/provider/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ servicecomb:
registry:
etcd:
connectString: http://127.0.0.1:2379
config:
etcd:
connectString: http://127.0.0.1:2379
instance-tag: tag1

rest:
address: 0.0.0.0:9094?websocketEnabled=true
Expand All @@ -39,6 +43,13 @@ servicecomb:
allowedMethod: "*"
maxAge: 3600


key1: 1
key2: 3
key3: 5

test1: env
test2: applition
test3: service
test4: version
test5: tag
14 changes: 12 additions & 2 deletions demo/demo-etcd/test-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>registry-local</artifactId>
</dependency>
<dependency>
<groupId>io.etcd</groupId>
<artifactId>jetcd-core</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.25.5</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<profiles>
Expand All @@ -60,7 +70,7 @@
<configuration>
<images>
<image>
<name>bitnami/etcd:latest</name>
<name>bitnami/etcd:3.5.16</name>
<alias>etcd</alias>
<run>
<namingStrategy>alias</namingStrategy>
Expand All @@ -74,7 +84,7 @@
<time>60000</time>
</wait>
<ports>
<port>etcd.port:2379</port>
<port>2379:2379</port>
</ports>
<env>
<ALLOW_NONE_AUTHENTICATION>yes</ALLOW_NONE_AUTHENTICATION>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* 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.servicecomb.samples;

import java.nio.charset.StandardCharsets;

import org.apache.servicecomb.demo.CategorizedTestCase;
import org.apache.servicecomb.demo.TestMgr;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;

import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.Client;

@Component
public class EtcdConfigIT implements CategorizedTestCase {
RestOperations template = new RestTemplate();

private static final Logger LOGGER = LoggerFactory.getLogger(EtcdConfigIT.class);

@Override
public void testRestTransport() throws Exception {

testEnvironment();
testApplication();
testService();
testVersion();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case for priority? e.g. service configuration override application configuration

testTag();
testOverride();
}

private void testOverride() {

putValue("/servicecomb/config/environment/production/application2.properties",
"testValue=t1");
putValue("/servicecomb/config/application/production/demo-etcd/application2.properties",
"testValue=t2");
testGetConfig("testValue", "t2");
putValue("/servicecomb/config/service/production/demo-etcd/provider/application2.properties",
"testValue=t3");
testGetConfig("testValue", "t3");
putValue("/servicecomb/config/version/production/demo-etcd/provider/0.0.1/application2.properties",
"testValue=t4");
testGetConfig("testValue", "t4");
putValue("/servicecomb/config/tag/production/demo-etcd/provider/0.0.1/tag1/application2.properties",
"testValue=t5");
testGetConfig("testValue", "t5");
}

private void testEnvironment() {

putValue("/servicecomb/config/environment/production/application.properties",
"test1=env");
putValue("/servicecomb/config/environment/production/application.properties",
"test1=env1");
testGetConfig("test1", "env1");
}

private void testApplication() {

putValue("/servicecomb/config/application/production/demo-etcd/application.properties",
"test2=applition");
putValue("/servicecomb/config/application/production/demo-etcd/application.properties",
"test2=applition2");
testGetConfig("test2", "applition2");
}

private void testService() {

putValue("/servicecomb/config/service/production/demo-etcd/provider/application.properties",
"test3=service");
putValue("/servicecomb/config/service/production/demo-etcd/provider/application.properties",
"test3=service3");
testGetConfig("test3", "service3");
}

private void testVersion() {

putValue("/servicecomb/config/version/production/demo-etcd/provider/0.0.1/application.properties",
"test3=version");
putValue("/servicecomb/config/version/production/demo-etcd/provider/0.0.1/application.properties",
"test4=version4");
testGetConfig("test4", "version4");
}

private void testTag() {

putValue("/servicecomb/config/tag/production/demo-etcd/provider/0.0.1/tag1/application.properties",
"test5=tag");
putValue("/servicecomb/config/tag/production/demo-etcd/provider/0.0.1/tag1/application.properties",
"test5=tag5");
testGetConfig("test5", "tag5");
}


public void putValue(String key, String value) {
try (Client client = Client.builder().endpoints("http://localhost:2379").build()) {

client.getKVClient().put(
ByteSequence.from(key, StandardCharsets.UTF_8),
ByteSequence.from(value, StandardCharsets.UTF_8)
).get();

LOGGER.info("Value set successfully");
} catch (Exception e) {
e.printStackTrace();
}
}

private void testGetConfig(String key, String expectValue) {

String result = template
.getForObject(Config.GATEWAY_URL + "/getConfig?key=" + key, String.class);
TestMgr.check(expectValue, result);
}
}
12 changes: 12 additions & 0 deletions demo/demo-etcd/test-client/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,15 @@ servicecomb:

rest:
address: 0.0.0.0:9097 # should be same with server.port to use web container

config:
etcd:
instance-tag: tag1

test1: env
test2: applition
test3: service
test4: version
test5: tag


5 changes: 5 additions & 0 deletions dependencies/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@
<artifactId>registry-etcd</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>config-etcd</artifactId>
<version>${project.version}</version>
</dependency>
<!-- ServiceComb: solutions -->
<dependency>
<groupId>org.apache.servicecomb</groupId>
Expand Down
44 changes: 44 additions & 0 deletions dynamic-config/config-etcd/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dynamic-config</artifactId>
<groupId>org.apache.servicecomb</groupId>
<version>3.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>config-etcd</artifactId>
<name>Java Chassis::Dynamic Config::Zookeeper</name>
<dependencies>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>foundation-config</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicecomb</groupId>
<artifactId>foundation-vertx</artifactId>
</dependency>
<dependency>
<groupId>io.etcd</groupId>
<artifactId>jetcd-core</artifactId>
</dependency>
</dependencies>
</project>
Loading
Loading