diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 6598020360a..cd974187de5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -28,20 +28,27 @@ jobs:
# step 3
- name: "Print maven version"
run: ./mvnw -version
- # step 4
- - name: "Build with Maven"
+ # step 4.1
+ - name: "Test, Check style, Check license with Maven and Java8"
+ if: matrix.java == '8'
+ run: |
+ ./mvnw -T 4C clean test \
+ -Dcheckstyle.skip=false -Dlicense.skip=false \
+ -Dmaven.git-commit-id.skip=true \
+ -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
+ # step 4.2
+ - name: "Test with Maven and Java${{ matrix.java }}"
+ if: matrix.java != '8'
run: |
- if [ "${{ matrix.java }}" == "8" ]; then
- ./mvnw -T 4C clean test -Dcheckstyle.skip=false -Dlicense.skip=false -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
- elif [ "${{ matrix.java }}" == "17" ]; then
- ./mvnw -T 4C clean test -Dcheckstyle.skip=true -Dlicense.skip=true -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
- fi
+ ./mvnw -T 4C clean test \
+ -Dmaven.git-commit-id.skip=true \
+ -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
# step 5
- name: "Codecov"
if: matrix.java == '8'
uses: codecov/codecov-action@v3.1.4
- # job 2: Test on 'arm64v8/ubuntu' OS.
+ # job 2: Build on 'arm64v8/ubuntu' OS (Skip tests).
build_arm64-binary:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && (github.ref_name == 'develop' || github.ref_name == 'snapshot' || github.ref_name == '2.x') }}
@@ -56,11 +63,15 @@ jobs:
id: qemu
uses: docker/setup-qemu-action@v3
# step 3
- - name: "Build arm-binary"
+ - name: "Build with Maven on 'arm64v8/ubuntu:20.04' OS (Skip tests)"
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
arm64v8/ubuntu:20.04 \
bash -exc 'apt-get update -y && \
apt-get install maven -y && \
mvn -version && \
- mvn -Prelease-seata -DskipTests -Dmaven.git-commit-id.skip=true clean install -U'
+ mvn clean install \
+ -Prelease-seata \
+ -DskipTests \
+ -Dmaven.git-commit-id.skip=true \
+ -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
diff --git a/.github/workflows/test-druid.yml b/.github/workflows/test-druid.yml
index 741a28c4f79..f004c41db81 100644
--- a/.github/workflows/test-druid.yml
+++ b/.github/workflows/test-druid.yml
@@ -11,8 +11,8 @@ jobs:
strategy:
fail-fast: false
matrix:
- java: [ 8, 11, 17, 21 ]
druid: [
+ 1.2.20,
1.2.19,
#1.2.18, # Unit test triggered a bug in Druid, see the commit https://github.com/alibaba/druid/commit/6c493f852852fb287ed5fd31ee16c27ead0ea5cf
#1.2.17, # Unit test triggered a bug in Druid, see the commit https://github.com/alibaba/druid/commit/6c493f852852fb287ed5fd31ee16c27ead0ea5cf
@@ -50,15 +50,14 @@ jobs:
uses: actions/setup-java@v3.12.0
with:
distribution: 'zulu'
- java-version: ${{ matrix.java }}
+ java-version: 8
# step 3
- name: "Print maven version"
run: ./mvnw -version
# step 4
- - name: "Test with Maven"
+ - name: "Test with Maven and Druid ${{ matrix.druid }}"
run: |
- if [ "${{ matrix.java }}" == "8" ]; then
- ./mvnw -T 4C clean test -Ddruid.version=${{ matrix.druid }} -Dcheckstyle.skip=false -Dlicense.skip=false -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
- else
- ./mvnw -T 4C clean test -Ddruid.version=${{ matrix.druid }} -Dcheckstyle.skip=true -Dlicense.skip=true -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
- fi
+ ./mvnw -T 4C clean test \
+ -Ddruid.version=${{ matrix.druid }} \
+ -Dmaven.git-commit-id.skip=true \
+ -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index b5c502761d8..feda1f93072 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -8,26 +8,25 @@ jobs:
# job 1
test:
name: "test"
- runs-on: ubuntu-latest
+ runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
java: [ 8, 11, 17, 21 ]
+ os: [
+ ubuntu,
+ macos,
+ windows, # Skip tests, because too many errors in unit-test.
+ ]
springboot: [
- 2.7.16 -Dspring-framework.version=5.3.30,
- 2.6.15 -Dspring-framework.version=5.3.27,
- 2.5.15 -Dspring-framework.version=5.3.27,
- 2.4.13 -Dspring-framework.version=5.3.13,
- 2.3.12.RELEASE -Dspring-framework.version=5.2.15.RELEASE,
- 2.2.13.RELEASE -Dspring-framework.version=5.2.12.RELEASE,
+ 2.7.18 -D spring-framework.version=5.3.31,
+ 2.6.15 -D spring-framework.version=5.3.27,
+ 2.5.15 -D spring-framework.version=5.3.27,
+ 2.4.13 -D spring-framework.version=5.3.13,
+ 2.3.12.RELEASE -D spring-framework.version=5.2.15.RELEASE,
+ 2.2.13.RELEASE -D spring-framework.version=5.2.12.RELEASE,
#2.1.18.RELEASE,
#2.0.9.RELEASE,
- #1.5.22.RELEASE,
- #1.4.7.RELEASE,
- #1.3.8.RELEASE,
- #1.2.8.RELEASE,
- #1.1.12.RELEASE,
- #1.0.2.RELEASE
]
steps:
# step 1
@@ -40,29 +39,40 @@ jobs:
distribution: 'zulu'
java-version: ${{ matrix.java }}
# step 3
- - name: "Print maven version"
- run: ./mvnw -version
- # step 4
- - name: "Test with Maven"
- # https://docs.github.com/cn/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-context
+ ## step 3.1: for Ubuntu and MacOS
+ - name: "Test with Maven on '${{ matrix.os }}' OS"
+ if: matrix.os != 'windows'
run: |
- if [ "${{ matrix.java }}" == "8" ]; then
- ./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=false -Dlicense.skip=false -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
- else
- ./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
- fi
+ ./mvnw -version;
+ ./mvnw -T 4C clean test \
+ -P args-for-client-test \
+ -Dspring-boot.version=${{ matrix.springboot }} \
+ -Dmaven.git-commit-id.skip=true \
+ -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
+ ## step 3.2: for Windows
+ - name: "Build with Maven on 'windows' OS (Skip tests)"
+ if: matrix.os == 'windows'
+ run: | # Skip tests, because too many errors in unit-test.
+ ./mvnw.cmd -version;
+ ./mvnw.cmd clean install -P args-for-client-test -DskipTests -D spring-boot.version=${{ matrix.springboot }} -D maven.git-commit-id.skip=true -e -B -D org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
# job 2
test-springboot3x:
name: "test-springboot3.x"
- runs-on: ubuntu-latest
+ runs-on: "${{ matrix.os }}-latest"
strategy:
fail-fast: false
matrix:
java: [ 17, 21 ]
+ os: [
+ ubuntu,
+ macos,
+ windows, # Skip tests, because too many errors in unit-test.
+ ]
springboot: [
- 3.1.4 -Dspring-framework.version=6.0.12,
- 3.0.11 -Dspring-framework.version=6.0.12,
+ 3.2.0 -D spring-framework.version=6.1.1,
+ 3.1.6 -D spring-framework.version=6.0.14,
+ 3.0.13 -D spring-framework.version=6.0.14,
]
steps:
# step 1
@@ -75,34 +85,39 @@ jobs:
distribution: 'zulu'
java-version: ${{ matrix.java }}
# step 3
- - name: "Print maven version"
- run: ./mvnw -version
- # step 4
- - name: "Test with Maven"
+ ## step 3.1: for Ubuntu and MacOS
+ - name: "Test with Maven on '${{ matrix.os }}' OS"
+ if: matrix.os != 'windows'
run: |
- ./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dkotlin-maven-plugin.version=1.7.22 -Dcheckstyle.skip=true -Dlicense.skip=true -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
+ ./mvnw -version;
+ ./mvnw -T 4C clean install \
+ -P args-for-client-test \
+ -Dspring-boot.version=${{ matrix.springboot }} \
+ -Dmaven.git-commit-id.skip=true \
+ -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
+ ## step 3.2: for Windows
+ - name: "Build with Maven on 'windows' OS (Skip tests)"
+ if: matrix.os == 'windows'
+ run: | # Skip tests, because too many errors in unit-test.
+ ./mvnw.cmd -version;
+ ./mvnw.cmd clean install -P args-for-client-test -DskipTests -D spring-boot.version=${{ matrix.springboot }} -D maven.git-commit-id.skip=true -e -B -D org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn;
# job 3
- arm64-test:
+ test-arm64:
+ name: "test-arm64"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
springboot: [
- 2.7.16 -Dspring-framework.version=5.3.30,
- 2.6.15 -Dspring-framework.version=5.3.27,
- 2.5.15 -Dspring-framework.version=5.3.27,
+ #2.7.18 -Dspring-framework.version=5.3.31, # The maven-compiler-plugin will throw an error for an unknown reason.
+ #2.6.15 -Dspring-framework.version=5.3.27, # The maven-compiler-plugin will throw an error for an unknown reason.
+ #2.5.15 -Dspring-framework.version=5.3.27, # The maven-compiler-plugin will throw an error for an unknown reason.
2.4.13 -Dspring-framework.version=5.3.13,
2.3.12.RELEASE -Dspring-framework.version=5.2.15.RELEASE,
2.2.13.RELEASE -Dspring-framework.version=5.2.12.RELEASE,
#2.1.18.RELEASE,
#2.0.9.RELEASE,
- #1.5.22.RELEASE,
- #1.4.7.RELEASE,
- #1.3.8.RELEASE,
- #1.2.8.RELEASE,
- #1.1.12.RELEASE,
- #1.0.2.RELEASE
]
steps:
# step 1
@@ -111,18 +126,18 @@ jobs:
# step 2
- name: "Set up QEMU"
id: qemu
- uses: docker/setup-qemu-action@v1
+ uses: docker/setup-qemu-action@v3
# step 3
- - name: "install"
+ - name: "Build with Maven on 'arm64v8/ubuntu:20.04' OS (Skip tests)"
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
arm64v8/ubuntu:20.04 \
bash -exc 'apt-get update -y && \
- apt-get install maven -y'
- # step 4
- - name: "Print maven version"
- run: ./mvnw -version
- # step 5
- - name: "test-arm64"
- run: |
- ./mvnw -T 4C clean test -P args-for-client-test -Dspring-boot.version=${{ matrix.springboot }} -Dcheckstyle.skip=true -Dlicense.skip=true -Dmaven.git-commit-id.skip=true -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
+ apt-get install maven -y && \
+ mvn -version && \
+ mvn -T 4C clean install \
+ -Dspring-boot.version=${{ matrix.springboot }} \
+ -Prelease-seata \
+ -DskipTests \
+ -Dmaven.git-commit-id.skip=true \
+ -e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn'
diff --git a/build/pom.xml b/build/pom.xml
index bb1c3971a9f..946fa0f7244 100644
--- a/build/pom.xml
+++ b/build/pom.xml
@@ -87,7 +87,7 @@
3.8.1
0.6.1
- 1.3.72
+ 1.9.21
3.8
1.3.6
@@ -431,6 +431,8 @@
--add-opens java.sql/java.sql=ALL-UNNAMED
--add-opens java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED
+
+ -Dnet.bytebuddy.experimental=true
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 7372d30071f..449b1bd01f2 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -30,6 +30,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6069](https://github.com/seata/seata/pull/6069)] Upgrade Guava dependencies to fix security vulnerabilities
### test:
+- [[#6081](https://github.com/seata/seata/pull/6081)] add `test-os.yml` for testing the OS
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] A brief and accurate description of PR
- [[#6125](https://github.com/seata/seata/pull/6125)] unbind xid in TransactionTemplateTest
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index a1d3c279d30..87126af81d3 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -29,7 +29,7 @@
- [[#6069](https://github.com/seata/seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞
### test:
-- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] 准确简要的PR描述
+- [[#6081](https://github.com/seata/seata/pull/6081)] 添加 `test-os.yml` 用于测试seata在各种操作系统下的运行情况
- [[#6125](https://github.com/seata/seata/pull/6125)] TransactionTemplateTest单测unbind xid
非常感谢以下 contributors 的代码贡献。若有无意遗漏,请报告。
diff --git a/core/src/main/java/io/seata/core/rpc/netty/AbstractNettyRemotingClient.java b/core/src/main/java/io/seata/core/rpc/netty/AbstractNettyRemotingClient.java
index 1e052d27af8..ee105091614 100644
--- a/core/src/main/java/io/seata/core/rpc/netty/AbstractNettyRemotingClient.java
+++ b/core/src/main/java/io/seata/core/rpc/netty/AbstractNettyRemotingClient.java
@@ -269,7 +269,7 @@ protected String loadBalance(String transactionServiceGroup, Object msg) {
RegistryFactory.getInstance().aliveLookup(transactionServiceGroup);
address = this.doSelect(inetSocketAddressList, msg);
} catch (Exception ex) {
- LOGGER.error(ex.getMessage());
+ LOGGER.error("Select the address failed: {}", ex.getMessage());
}
if (address == null) {
throw new FrameworkException(NoAvailableService);
diff --git a/core/src/main/java/io/seata/core/serializer/SerializerSecurityRegistry.java b/core/src/main/java/io/seata/core/serializer/SerializerSecurityRegistry.java
index 1d4b65e4fd1..0f922d97885 100644
--- a/core/src/main/java/io/seata/core/serializer/SerializerSecurityRegistry.java
+++ b/core/src/main/java/io/seata/core/serializer/SerializerSecurityRegistry.java
@@ -103,17 +103,54 @@ private static String[] getDenyClassPatternList() {
}
private static Set> getProtocolType() {
- Enumeration packageDir = null;
- String packageName = "io.seata.core.protocol";
Set> classNameSet = new HashSet<>();
+
try {
- packageDir = Thread.currentThread().getContextClassLoader().getResources(packageName.replace(".", "/"));
+ String packageName = "io.seata.core.protocol";
+ Enumeration packageDir = Thread.currentThread().getContextClassLoader().getResources(packageName.replace(".", "/"));
+ while (packageDir.hasMoreElements()) {
+ String filePath = packageDir.nextElement().getFile();
+ findProtocolClassByPackage(filePath, packageName, classNameSet);
+ }
} catch (IOException ignore) {
}
- while (packageDir.hasMoreElements()) {
- String filePath = packageDir.nextElement().getFile();
- findProtocolClassByPackage(filePath, packageName, classNameSet);
+
+ if (classNameSet.size() < 30) {
+ // package io.seata.core.protocol
+ classNameSet.add(io.seata.core.protocol.BatchResultMessage.class);
+ classNameSet.add(io.seata.core.protocol.HeartbeatMessage.class);
+ classNameSet.add(io.seata.core.protocol.MergedWarpMessage.class);
+ classNameSet.add(io.seata.core.protocol.MergeResultMessage.class);
+ classNameSet.add(io.seata.core.protocol.RegisterRMRequest.class);
+ classNameSet.add(io.seata.core.protocol.RegisterRMResponse.class);
+ classNameSet.add(io.seata.core.protocol.RegisterTMRequest.class);
+ classNameSet.add(io.seata.core.protocol.RegisterTMResponse.class);
+ classNameSet.add(io.seata.core.protocol.RpcMessage.class);
+
+ // package io.seata.core.protocol.transaction
+ classNameSet.add(io.seata.core.protocol.transaction.BranchCommitRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.BranchCommitResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.BranchRegisterRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.BranchRegisterResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.BranchReportRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.BranchReportResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.BranchRollbackRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.BranchRollbackResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalBeginRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalBeginResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalCommitRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalCommitResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalLockQueryResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalLockQueryRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalReportRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalReportResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalRollbackRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalRollbackResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalStatusRequest.class);
+ classNameSet.add(io.seata.core.protocol.transaction.GlobalStatusResponse.class);
+ classNameSet.add(io.seata.core.protocol.transaction.UndoLogDeleteRequest.class);
}
+
return classNameSet;
}
diff --git a/discovery/seata-discovery-core/src/main/java/io/seata/discovery/registry/FileRegistryServiceImpl.java b/discovery/seata-discovery-core/src/main/java/io/seata/discovery/registry/FileRegistryServiceImpl.java
index 16614cd1807..9be433e9951 100644
--- a/discovery/seata-discovery-core/src/main/java/io/seata/discovery/registry/FileRegistryServiceImpl.java
+++ b/discovery/seata-discovery-core/src/main/java/io/seata/discovery/registry/FileRegistryServiceImpl.java
@@ -90,7 +90,7 @@ public List lookup(String key) throws Exception {
for (String endpoint : endpoints) {
String[] ipAndPort = NetUtil.splitIPPortStr(endpoint);
if (ipAndPort.length != 2) {
- throw new IllegalArgumentException("endpoint format should like ip:port");
+ throw new IllegalArgumentException("endpoint format should like ip:port, the invalid endpoint: " + endpoint);
}
inetSocketAddresses.add(new InetSocketAddress(ipAndPort[0], Integer.parseInt(ipAndPort[1])));
}
diff --git a/server/src/test/java/io/seata/server/session/redis/RedisDistributedLockerTest.java b/server/src/test/java/io/seata/server/session/redis/RedisDistributedLockerTest.java
index ccb0c3496d3..693b9f46923 100644
--- a/server/src/test/java/io/seata/server/session/redis/RedisDistributedLockerTest.java
+++ b/server/src/test/java/io/seata/server/session/redis/RedisDistributedLockerTest.java
@@ -45,6 +45,7 @@
public class RedisDistributedLockerTest {
private String retryRollbacking = "RetryRollbacking";
+ private String retryRollbacking2 = "RetryRollbacking2";
private String retryCommiting = "RetryCommiting";
private String lockValue = "127.1.1.1:9081";
private static DistributedLocker distributedLocker;
@@ -69,25 +70,29 @@ public static void after() throws IOException {
@Test
public void test_acquireScheduledLock_success() {
- boolean acquire = distributedLocker.acquireLock(new DistributedLockDO(retryRollbacking, lockValue, 60000L));
+ String lockKey = retryRollbacking;
+
+ boolean acquire = distributedLocker.acquireLock(new DistributedLockDO(lockKey, lockValue, 60000L));
Assertions.assertTrue(acquire);
- String lockValueExisted = jedis.get(retryRollbacking);
+ String lockValueExisted = jedis.get(lockKey);
Assertions.assertEquals(lockValue, lockValueExisted);
- boolean release = distributedLocker.releaseLock(new DistributedLockDO(retryRollbacking, lockValue, null));
+ boolean release = distributedLocker.releaseLock(new DistributedLockDO(lockKey, lockValue, null));
Assertions.assertTrue(release);
- Assertions.assertNull(jedis.get(retryRollbacking));
+ Assertions.assertNull(jedis.get(lockKey));
}
@Test
- public void test_acquireScheduledLock_success_() throws UnknownHostException {
+ public void test_acquireScheduledLock_success_() {
+ String lockKey = retryRollbacking2;
SessionHolder.init(SessionMode.REDIS);
- boolean accquire = SessionHolder.acquireDistributedLock(retryRollbacking);
+
+ boolean accquire = SessionHolder.acquireDistributedLock(lockKey);
Assertions.assertTrue(accquire);
- String lockValueExisted = jedis.get(retryRollbacking);
+ String lockValueExisted = jedis.get(lockKey);
Assertions.assertEquals(XID.getIpAddressAndPort(), lockValueExisted);
- boolean release = SessionHolder.releaseDistributedLock(retryRollbacking);
+ boolean release = SessionHolder.releaseDistributedLock(lockKey);
Assertions.assertTrue(release);
- Assertions.assertNull(jedis.get(retryRollbacking));
+ Assertions.assertNull(jedis.get(lockKey));
}
@Test
diff --git a/test/src/test/java/io/seata/core/rpc/netty/TmNettyClientTest.java b/test/src/test/java/io/seata/core/rpc/netty/TmNettyClientTest.java
index 2447ba0d272..8b09fbc6cd3 100644
--- a/test/src/test/java/io/seata/core/rpc/netty/TmNettyClientTest.java
+++ b/test/src/test/java/io/seata/core/rpc/netty/TmNettyClientTest.java
@@ -19,6 +19,7 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
import io.netty.channel.Channel;
import io.seata.common.XID;
@@ -32,14 +33,17 @@
import io.seata.server.session.SessionHolder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-
-import static io.seata.common.DefaultValues.DEFAULT_SEATA_GROUP;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author slievrly
*/
public class TmNettyClientTest extends AbstractServerTest {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TmNettyClientTest.class);
+
+
public static ThreadPoolExecutor initMessageExecutor() {
return new ThreadPoolExecutor(100, 500, 500, TimeUnit.SECONDS,
new LinkedBlockingQueue(20000), new ThreadPoolExecutor.CallerRunsPolicy());
@@ -55,21 +59,39 @@ public void testDoConnect() throws Exception {
ThreadPoolExecutor workingThreads = initMessageExecutor();
NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(workingThreads);
//start services server first
+ AtomicBoolean serverStatus = new AtomicBoolean();
Thread thread = new Thread(() -> {
- nettyRemotingServer.setHandler(DefaultCoordinator.getInstance(nettyRemotingServer));
- // set registry
- XID.setIpAddress(NetUtil.getLocalIp());
- XID.setPort(8091);
- // init snowflake for transactionId, branchId
- UUIDGenerator.init(1L);
- System.out.println("pid info: "+ ManagementFactory.getRuntimeMXBean().getName());
- nettyRemotingServer.init();
+ try {
+ nettyRemotingServer.setHandler(DefaultCoordinator.getInstance(nettyRemotingServer));
+ // set registry
+ XID.setIpAddress(NetUtil.getLocalIp());
+ XID.setPort(8091);
+ // init snowflake for transactionId, branchId
+ UUIDGenerator.init(1L);
+ System.out.println("pid info: " + ManagementFactory.getRuntimeMXBean().getName());
+ nettyRemotingServer.init();
+ serverStatus.set(true);
+ } catch (Throwable t) {
+ serverStatus.set(false);
+ LOGGER.error("The seata-server failed to start", t);
+ }
});
thread.start();
- //then test client
- Thread.sleep(3000);
+ //Wait for the seata-server to start.
+ long start = System.nanoTime();
+ long maxWaitNanoTime = 10 * 1000 * 1000 * 1000L; // 10s
+ while (System.nanoTime() - start < maxWaitNanoTime) {
+ Thread.sleep(100);
+ if (serverStatus.get()) {
+ break;
+ }
+ }
+ if (!serverStatus.get()) {
+ throw new RuntimeException("Waiting for a while, but the seata-server did not start successfully.");
+ }
+ //then test client
String applicationId = "app 1";
String transactionServiceGroup = "group A";
TmNettyRemotingClient tmNettyRemotingClient = TmNettyRemotingClient.getInstance(applicationId, transactionServiceGroup);