This is an automated email from the ASF dual-hosted git repository.

jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new a3aa11bcf5 test : old version(< 0.7.1) client test case for 
multi-version protocol  (#6695)
a3aa11bcf5 is described below

commit a3aa11bcf5d17091b2d732416a679402cff4368d
Author: justabug <bug...@users.noreply.github.com>
AuthorDate: Tue Jul 30 15:12:34 2024 +0800

    test : old version(< 0.7.1) client test case for multi-version protocol  
(#6695)
---
 changes/en-us/2.x.md                               |  1 +
 changes/zh-cn/2.x.md                               |  1 +
 pom.xml                                            |  1 +
 test-old-version/pom.xml                           | 76 ++++++++++++++++++
 .../src/test/java/io/seata/MockTest.java           | 70 ++++++++---------
 .../test/java/io/seata/core/rpc/netty/Action1.java | 45 +++++++++++
 .../java/io/seata/core/rpc/netty/Action1Impl.java  | 64 +++++++++++++++
 .../core/rpc/netty/ProtocolTestConstants.java      | 27 +++++++
 .../java/io/seata/core/rpc/netty/RmClientTest.java | 85 ++++++++++++++++++++
 .../java/io/seata/core/rpc/netty/TmClientTest.java | 83 ++++++++++++++++++++
 .../org.apache.seata.common.loader.LoaderTestSPI   | 18 +++++
 test-old-version/src/test/resources/README.md      | 21 +++++
 test-old-version/src/test/resources/file.conf      | 78 +++++++++++++++++++
 test-old-version/src/test/resources/logback.xml    | 31 ++++++++
 test-old-version/src/test/resources/registry.conf  | 90 ++++++++++++++++++++++
 .../core/rpc/netty/mockserver/MockServerTest.java  |  4 +-
 16 files changed, 656 insertions(+), 39 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 509f2a22cd..e83eaa555b 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -43,6 +43,7 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#6533](https://github.com/apache/incubator-seata/pull/6533)] increase 
integration-tx-api module unit test coverage
 - [[#6608](https://github.com/apache/incubator-seata/pull/6608)] add unit test 
for sql-parser-core
 - [[#6647](https://github.com/apache/incubator-seata/pull/6647)] improve the 
test case coverage of saga module to 70%
+- [[#6695](https://github.com/apache/incubator-seata/pull/6695)] old version(< 
0.7.1) client test case for multi-version protocol
 
 Thanks to these contributors for their code commits. Please report an 
unintended omission.
 
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 24b4265240..5a651a2acd 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -45,6 +45,7 @@
 - [[#6533](https://github.com/apache/incubator-seata/pull/6533)] 增加 
Integration-TX-API 模块单元测试覆盖范围
 - [[#6608](https://github.com/apache/incubator-seata/pull/6608)] 
添加sql-parser-core模块测试用例
 - [[#6647](https://github.com/apache/incubator-seata/pull/6647)] 
增加saga模块的测试用例覆盖率
+- [[#6695](https://github.com/apache/incubator-seata/pull/6695)] 多版本协议的旧版本(< 
0.7.1)客户端测试用例
 
 
 
diff --git a/pom.xml b/pom.xml
index c2e923af7e..0edf5b1060 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,6 +62,7 @@
         <module>tcc</module>
         <module>test</module>
         <module>test-mock-server</module>
+        <module>test-old-version</module>
         <module>tm</module>
         <module>metrics</module>
         <module>serializer</module>
diff --git a/test-old-version/pom.xml b/test-old-version/pom.xml
new file mode 100644
index 0000000000..057f2c671a
--- /dev/null
+++ b/test-old-version/pom.xml
@@ -0,0 +1,76 @@
+<?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>
+        <groupId>org.apache.seata</groupId>
+        <artifactId>seata-parent</artifactId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>seata-test-old-version</artifactId>
+    <packaging>jar</packaging>
+    <name>seata-test-old-version</name>
+    <description>test for Seata Old Version Client</description>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
+                <configuration>
+                    <skip>true</skip>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>seata-mock-server</artifactId>
+            <version>${project.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>${project.groupId}</groupId>
+                    <artifactId>seata-spring-autoconfigure-core</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>io.seata</groupId>
+            <artifactId>seata-all</artifactId>
+            <version>0.6.1</version>
+        </dependency>
+        <dependency>
+            <groupId>io.seata</groupId>
+            <artifactId>seata-tm</artifactId>
+            <version>0.6.1</version>
+        </dependency>
+        <dependency>
+            <groupId>io.seata</groupId>
+            <artifactId>seata-rm</artifactId>
+            <version>0.6.1</version>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file
diff --git 
a/test/src/test/java/org/apache/seata/core/rpc/netty/mockserver/MockServerTest.java
 b/test-old-version/src/test/java/io/seata/MockTest.java
similarity index 65%
copy from 
test/src/test/java/org/apache/seata/core/rpc/netty/mockserver/MockServerTest.java
copy to test-old-version/src/test/java/io/seata/MockTest.java
index d1923a0816..1a06b872d1 100644
--- 
a/test/src/test/java/org/apache/seata/core/rpc/netty/mockserver/MockServerTest.java
+++ b/test-old-version/src/test/java/io/seata/MockTest.java
@@ -14,24 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.seata.core.rpc.netty.mockserver;
-
-import org.apache.seata.common.ConfigurationKeys;
-import org.apache.seata.common.ConfigurationTestHelper;
-import org.apache.seata.config.ConfigurationFactory;
-import org.apache.seata.core.exception.TransactionException;
-import org.apache.seata.core.model.BranchType;
-import org.apache.seata.core.model.GlobalStatus;
-import org.apache.seata.core.model.TransactionManager;
-import org.apache.seata.core.rpc.netty.RmNettyRemotingClient;
-import org.apache.seata.core.rpc.netty.TmNettyRemotingClient;
+package io.seata;
+
+import io.seata.core.rpc.netty.Action1Impl;
+import io.seata.core.rpc.netty.ProtocolTestConstants;
+import io.seata.core.rpc.netty.RmClientTest;
+import io.seata.core.rpc.netty.RmRpcClient;
+import io.seata.core.rpc.netty.TmClientTest;
+import io.seata.core.rpc.netty.TmRpcClient;
+import io.seata.rm.DefaultResourceManager;
+import io.seata.core.exception.TransactionException;
+import io.seata.core.model.BranchType;
+import io.seata.core.model.GlobalStatus;
+import io.seata.core.model.TransactionManager;
 import org.apache.seata.mockserver.MockCoordinator;
 import org.apache.seata.mockserver.MockServer;
-import org.apache.seata.rm.DefaultResourceManager;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -39,52 +39,47 @@ import org.slf4j.LoggerFactory;
 /**
  * the type MockServerTest
  */
-public class MockServerTest {
-
-    static String RESOURCE_ID = "mock-action";
+public class MockTest {
 
-    Logger logger = LoggerFactory.getLogger(MockServerTest.class);
+    static String RESOURCE_ID = "mock-action-061";
+    Logger logger = LoggerFactory.getLogger(MockTest.class);
 
     @BeforeAll
     public static void before() {
-        ConfigurationFactory.reload();
-        
ConfigurationTestHelper.putConfig(ConfigurationKeys.SERVER_SERVICE_PORT_CAMEL, 
String.valueOf(ProtocolTestConstants.MOCK_SERVER_PORT));
+        System.setProperty("server.servicePort", 
ProtocolTestConstants.MOCK_SERVER_PORT+"");
         MockServer.start(ProtocolTestConstants.MOCK_SERVER_PORT);
-        TmNettyRemotingClient.getInstance().destroy();
-        RmNettyRemotingClient.getInstance().destroy();
     }
 
     @AfterAll
     public static void after() {
-        //MockServer.close();
-        
ConfigurationTestHelper.removeConfig(ConfigurationKeys.SERVER_SERVICE_PORT_CAMEL);
-        TmNettyRemotingClient.getInstance().destroy();
-        RmNettyRemotingClient.getInstance().destroy();
+        MockServer.close();
+        TmRpcClient.getInstance().destroy();
+        RmRpcClient.getInstance().destroy();
     }
 
     @Test
-    public void testCommit() throws TransactionException {
+    public void testCommit() throws Exception {
         String xid = doTestCommit(0);
         Assertions.assertEquals(1, Action1Impl.getCommitTimes(xid));
         Assertions.assertEquals(0, Action1Impl.getRollbackTimes(xid));
     }
 
     @Test
-    public void testCommitRetry() throws TransactionException {
+    public void testCommitRetry() throws Exception {
         String xid = doTestCommit(2);
         Assertions.assertEquals(3, Action1Impl.getCommitTimes(xid));
         Assertions.assertEquals(0, Action1Impl.getRollbackTimes(xid));
     }
 
     @Test
-    public void testRollback() throws TransactionException {
+    public void testRollback() throws Exception {
         String xid = doTestRollback(0);
         Assertions.assertEquals(0, Action1Impl.getCommitTimes(xid));
         Assertions.assertEquals(1, Action1Impl.getRollbackTimes(xid));
     }
 
     @Test
-    public void testRollbackRetry() throws TransactionException {
+    public void testRollbackRetry() throws Exception {
         String xid = doTestRollback(2);
         Assertions.assertEquals(0, Action1Impl.getCommitTimes(xid));
         Assertions.assertEquals(3, Action1Impl.getRollbackTimes(xid));
@@ -97,33 +92,34 @@ public class MockServerTest {
 
     @Test
     public void testRm() throws Exception {
-        RmClientTest.testRm();
+        RmClientTest.testRm("testRM01");
     }
 
-    private String doTestCommit(int times) throws TransactionException {
+    private String doTestCommit(int times) throws TransactionException, 
NoSuchMethodException {
         TransactionManager tm = TmClientTest.getTm();
         DefaultResourceManager rm = RmClientTest.getRm(RESOURCE_ID);
 
-        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP, "test", 60000);
+        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP, "test-commit", 60000);
+        logger.info("doTestCommit(0.6.1) xid:{}", xid);
         MockCoordinator.getInstance().setExpectedRetry(xid, times);
         Long branchId = rm.branchRegister(BranchType.TCC, RESOURCE_ID, "1", 
xid, "{\"mock\":\"mock\"}", "1");
+        logger.info("branch register(0.6.1) ok, branchId=" + branchId);
         GlobalStatus commit = tm.commit(xid);
         Assertions.assertEquals(GlobalStatus.Committed, commit);
         return xid;
-
     }
 
-    private String doTestRollback(int times) throws TransactionException {
+    private String doTestRollback(int times) throws TransactionException, 
NoSuchMethodException {
         TransactionManager tm = TmClientTest.getTm();
         DefaultResourceManager rm = RmClientTest.getRm(RESOURCE_ID);
 
-        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP, "test", 60000);
-        logger.info("doTestRollback xid:{}", xid);
+        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP, "test-rollback", 60000);
+        logger.info("doTestRollback(0.6.1) xid:{}", xid);
         MockCoordinator.getInstance().setExpectedRetry(xid, times);
         Long branchId = rm.branchRegister(BranchType.TCC, RESOURCE_ID, "1", 
xid, "{\"mock\":\"mock\"}", "1");
+        logger.info("branch register(0.6.1) ok, branchId=" + branchId);
         GlobalStatus rollback = tm.rollback(xid);
         Assertions.assertEquals(GlobalStatus.Rollbacked, rollback);
         return xid;
-
     }
 }
diff --git 
a/test-old-version/src/test/java/io/seata/core/rpc/netty/Action1.java 
b/test-old-version/src/test/java/io/seata/core/rpc/netty/Action1.java
new file mode 100644
index 0000000000..1134da402d
--- /dev/null
+++ b/test-old-version/src/test/java/io/seata/core/rpc/netty/Action1.java
@@ -0,0 +1,45 @@
+/*
+ * 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 io.seata.core.rpc.netty;
+
+import io.seata.rm.tcc.api.BusinessActionContext;
+import io.seata.rm.tcc.api.BusinessActionContextParameter;
+import io.seata.rm.tcc.api.LocalTCC;
+import io.seata.rm.tcc.api.TwoPhaseBusinessAction;
+
+import java.util.Map;
+
+/**
+ * The interface Action1.
+ *
+ */
+@LocalTCC
+public interface Action1 {
+
+    @TwoPhaseBusinessAction(name = "mock-action", commitMethod = "commitTcc", 
rollbackMethod = "cancel"
+//            , useTCCFence = true
+    )
+    String insert(@BusinessActionContextParameter Long reqId,
+            @BusinessActionContextParameter(paramName = "params") Map<String, 
String> params
+    );
+
+
+    boolean commitTcc(BusinessActionContext actionContext);
+
+
+    boolean cancel(BusinessActionContext actionContext);
+}
diff --git 
a/test-old-version/src/test/java/io/seata/core/rpc/netty/Action1Impl.java 
b/test-old-version/src/test/java/io/seata/core/rpc/netty/Action1Impl.java
new file mode 100644
index 0000000000..c13a344043
--- /dev/null
+++ b/test-old-version/src/test/java/io/seata/core/rpc/netty/Action1Impl.java
@@ -0,0 +1,64 @@
+/*
+ * 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 io.seata.core.rpc.netty;
+
+import io.seata.rm.tcc.api.BusinessActionContext;
+import org.springframework.stereotype.Service;
+import vlsi.utils.CompactHashMap;
+
+import java.util.Map;
+
+/**
+ * The type Action1.
+ */
+@Service
+public class Action1Impl implements Action1 {
+
+    private static Map<String, Integer> commitMap = new CompactHashMap<>();
+    private static Map<String, Integer> rollbackMap = new CompactHashMap<>();
+
+    @Override
+    public String insert(Long reqId, Map<String, String> params) {
+        System.out.println("prepare");
+        return "prepare";
+    }
+
+
+    @Override
+    public boolean commitTcc(BusinessActionContext actionContext) {
+        String xid = actionContext.getXid();
+        System.out.println("commitTcc:" + xid + "," + 
actionContext.getActionContext());
+        commitMap.compute(xid, (k, v) -> v == null ? 1 : v + 1);
+        return true;
+    }
+
+    @Override
+    public boolean cancel(BusinessActionContext actionContext) {
+        String xid = actionContext.getXid();
+        System.out.println("cancelTcc:" + xid + "," + 
actionContext.getActionContext());
+        rollbackMap.compute(xid, (k, v) -> v == null ? 1 : v + 1);
+        return true;
+    }
+
+    public static int getCommitTimes(String xid) {
+        return commitMap.getOrDefault(xid, 0);
+    }
+
+    public static int getRollbackTimes(String xid) {
+        return rollbackMap.getOrDefault(xid, 0);
+    }
+}
diff --git 
a/test-old-version/src/test/java/io/seata/core/rpc/netty/ProtocolTestConstants.java
 
b/test-old-version/src/test/java/io/seata/core/rpc/netty/ProtocolTestConstants.java
new file mode 100644
index 0000000000..c76c418dc6
--- /dev/null
+++ 
b/test-old-version/src/test/java/io/seata/core/rpc/netty/ProtocolTestConstants.java
@@ -0,0 +1,27 @@
+/*
+ * 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 io.seata.core.rpc.netty;
+
+/**
+ * Mock Constants
+ **/
+public class ProtocolTestConstants {
+    public static final String APPLICATION_ID = "mock_tx_app_id_061";
+    public static final String SERVICE_GROUP = "mock_tx_group";
+    public static final int MOCK_SERVER_PORT = 8077;
+    public static final String MOCK_SERVER_ADDRESS = "0.0.0.0:" + 
MOCK_SERVER_PORT;
+}
diff --git 
a/test-old-version/src/test/java/io/seata/core/rpc/netty/RmClientTest.java 
b/test-old-version/src/test/java/io/seata/core/rpc/netty/RmClientTest.java
new file mode 100644
index 0000000000..3246586d27
--- /dev/null
+++ b/test-old-version/src/test/java/io/seata/core/rpc/netty/RmClientTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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 io.seata.core.rpc.netty;
+
+import io.seata.common.util.ReflectionUtil;
+import io.seata.core.exception.TransactionException;
+import io.seata.core.model.BranchType;
+import io.seata.rm.DefaultResourceManager;
+import io.seata.rm.RMClient;
+import io.seata.rm.tcc.TCCResource;
+import io.seata.rm.tcc.api.BusinessActionContext;
+import org.junit.jupiter.api.Assertions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * rm client test
+ **/
+public class RmClientTest {
+
+    protected static final Logger LOGGER = 
LoggerFactory.getLogger(RmClientTest.class);
+    private static DefaultResourceManager rm = null;
+
+    public static void testRm(String resourceId) throws TransactionException, 
NoSuchMethodException {
+        String xid = "1111";
+
+        DefaultResourceManager rm = getRm(resourceId);
+
+        //branchRegister:TYPE_BRANCH_REGISTER = 11 , 
TYPE_BRANCH_REGISTER_RESULT = 12
+        Long branchId = rm.branchRegister(BranchType.AT, resourceId, "1", xid, 
"1", "1");
+        Assertions.assertTrue(branchId > 0);
+
+
+        // (not support)branchReport:TYPE_BRANCH_STATUS_REPORT = 13 , 
TYPE_BRANCH_STATUS_REPORT_RESULT = 14
+        // (not support)lockQuery:TYPE_GLOBAL_LOCK_QUERY = 21 , 
TYPE_GLOBAL_LOCK_QUERY_RESULT = 22
+
+    }
+
+
+    public static DefaultResourceManager getRm(String resourceId) throws 
NoSuchMethodException {
+        if (rm == null) {
+            synchronized (RmClientTest.class) {
+                if (rm == null) {
+                    //register:TYPE_REG_RM = 103 , TYPE_REG_RM_RESULT = 104
+                    RMClient.init(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP);
+
+                    DefaultResourceManager resourceManager = 
DefaultResourceManager.get();
+                    
resourceManager.getResourceManager(BranchType.TCC).getManagedResources().clear();
+
+                    rm = resourceManager;
+                }
+            }
+        }
+        Action1 target = new Action1Impl();
+        TCCResource tccResource = new TCCResource();
+        tccResource.setActionName(resourceId);
+        tccResource.setTargetBean(target);
+        tccResource.setPrepareMethod(target.getClass().getMethod("insert", 
Long.class, Map.class));
+        tccResource.setCommitMethodName("commitTcc");
+        tccResource.setRollbackMethodName("cancel");
+        tccResource.setCommitMethod(ReflectionUtil.getMethod(Action1.class, 
"commitTcc", new Class[]{BusinessActionContext.class}));
+        tccResource.setRollbackMethod(ReflectionUtil.getMethod(Action1.class, 
"cancel", new Class[]{BusinessActionContext.class}));
+        rm.registerResource(tccResource);
+        LOGGER.info("registerResource ok");
+        return rm;
+    }
+
+
+}
diff --git 
a/test-old-version/src/test/java/io/seata/core/rpc/netty/TmClientTest.java 
b/test-old-version/src/test/java/io/seata/core/rpc/netty/TmClientTest.java
new file mode 100644
index 0000000000..254caffa87
--- /dev/null
+++ b/test-old-version/src/test/java/io/seata/core/rpc/netty/TmClientTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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 io.seata.core.rpc.netty;
+
+import io.netty.channel.Channel;
+import io.seata.core.model.GlobalStatus;
+import io.seata.core.model.TransactionManager;
+import io.seata.tm.DefaultTransactionManager;
+import org.junit.jupiter.api.Assertions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * TmClient Test
+ **/
+public class TmClientTest {
+
+    protected static final Logger LOGGER = 
LoggerFactory.getLogger(TmClientTest.class);
+    private static TransactionManager tm = null;
+
+    public static void testTm() throws Exception {
+        TransactionManager tm = getTm();
+
+        //globalBegin:TYPE_GLOBAL_BEGIN = 1 , TYPE_GLOBAL_BEGIN_RESULT = 2
+        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID,
+                ProtocolTestConstants.SERVICE_GROUP, "test", 60000);
+        LOGGER.info("globalBegin ok:xid=" + xid);
+
+        //globalCommit:TYPE_GLOBAL_COMMIT = 7 , TYPE_GLOBAL_COMMIT_RESULT = 8
+        GlobalStatus commit = tm.commit(xid);
+        LOGGER.info("globalCommit ok:" + commit);
+        Assertions.assertEquals(commit, GlobalStatus.Committed);
+
+        //globalRollback:TYPE_GLOBAL_ROLLBACK = 9 , 
TYPE_GLOBAL_ROLLBACK_RESULT = 10
+        GlobalStatus rollback = tm.rollback(xid);
+        LOGGER.info("globalRollback ok:" + rollback);
+        Assertions.assertEquals(rollback, GlobalStatus.Rollbacked);
+
+        //getStatus:TYPE_GLOBAL_STATUS = 15 , TYPE_GLOBAL_STATUS_RESULT = 16
+        GlobalStatus status = tm.getStatus(xid);
+        LOGGER.info("getStatus ok:" + status);
+        Assertions.assertEquals(status, GlobalStatus.Rollbacked);
+
+        //globalReport:TYPE_GLOBAL_REPORT = 17 , TYPE_GLOBAL_REPORT_RESULT = 
18 (0.6.1 not support)
+//        GlobalStatus globalReport = tm.globalReport(xid, 
GlobalStatus.Committed);
+
+        GlobalStatus rollback2 = tm.rollback(xid);
+        LOGGER.info("globalRollback ok:" + rollback2);
+    }
+
+    public static TransactionManager getTm() {
+        if (tm == null) {
+            synchronized (TmClientTest.class) {
+                if (tm == null) {
+                    TmRpcClient tmRpcClient = 
TmRpcClient.getInstance(ProtocolTestConstants.APPLICATION_ID,
+                            ProtocolTestConstants.SERVICE_GROUP);
+                    tmRpcClient.init();
+                    tm = new DefaultTransactionManager();
+                }
+            }
+        }
+        return tm;
+    }
+
+
+}
diff --git 
a/test-old-version/src/test/resources/META-INF/services/org.apache.seata.common.loader.LoaderTestSPI
 
b/test-old-version/src/test/resources/META-INF/services/org.apache.seata.common.loader.LoaderTestSPI
new file mode 100644
index 0000000000..d848065778
--- /dev/null
+++ 
b/test-old-version/src/test/resources/META-INF/services/org.apache.seata.common.loader.LoaderTestSPI
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+org.apache.seata.common.loader.LoaderTestImpl1
+org.apache.seata.common.loader.LoaderTestImpl2
\ No newline at end of file
diff --git a/test-old-version/src/test/resources/README.md 
b/test-old-version/src/test/resources/README.md
new file mode 100644
index 0000000000..c162008b3b
--- /dev/null
+++ b/test-old-version/src/test/resources/README.md
@@ -0,0 +1,21 @@
+## MySQLUpdateJoinTest
+##测试表结构
+CREATE TABLE `t` (
+`id` int NOT NULL,
+`a` int DEFAULT NULL,
+`c` int DEFAULT NULL,
+PRIMARY KEY (`id`),
+KEY `a` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE `t1` (
+`id` int NOT NULL,
+`a` int DEFAULT NULL,
+`b` int DEFAULT NULL,
+`c` int DEFAULT NULL,
+PRIMARY KEY (`id`),
+KEY `a` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
+###测试数据
+insert into t(id,a,c) values(1,1,1);\
+insert into t1(id,a,b,c) values(2,1,2,2)
\ No newline at end of file
diff --git a/test-old-version/src/test/resources/file.conf 
b/test-old-version/src/test/resources/file.conf
new file mode 100644
index 0000000000..f72d16eedb
--- /dev/null
+++ b/test-old-version/src/test/resources/file.conf
@@ -0,0 +1,78 @@
+#
+# 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.
+#
+
+transport {
+  # tcp, unix-domain-socket
+  type = "TCP"
+  #NIO, NATIVE
+  server = "NIO"
+  #enable heartbeat
+  heartbeat = true
+  # the tm client batch send request enable
+  enableTmClientBatchSendRequest = true
+  # the rm client batch send request enable
+  enableRmClientBatchSendRequest = true
+  #thread factory for netty
+  threadFactory {
+    bossThreadPrefix = "NettyBoss"
+    workerThreadPrefix = "NettyServerNIOWorker"
+    serverExecutorThread-prefix = "NettyServerBizHandler"
+    shareBossWorker = false
+    clientSelectorThreadPrefix = "NettyClientSelector"
+    clientSelectorThreadSize = 1
+    clientWorkerThreadPrefix = "NettyClientWorkerThread"
+    # netty boss thread size
+    bossThreadSize = 1
+    #auto default pin or 8
+    workerThreadSize = "default"
+  }
+  shutdown {
+    # when destroy server, wait seconds
+    wait = 3
+  }
+  serialization = "seata"
+  compressor = "none"
+
+  enableRmClientChannelCheckFailFast = false
+  enableTmClientChannelCheckFailFast = false
+}
+
+
+service {
+  #transaction service group mapping
+  vgroup_mapping.default_tx_group = "default"
+  vgroup_mapping.mock_tx_group = "mock"
+  #only support when registry.type=file, please don't set multiple addresses
+  default.grouplist = "127.0.0.1:8078"
+  mock.grouplist = "127.0.0.1:8077"
+  #disable seata
+  disableGlobalTransaction = false
+}
+
+client {
+  rm {
+    reportSuccessEnable = false
+    sagaBranchRegisterEnable = false
+    sagaJsonParser = jackson
+    sagaRetryPersistModeUpdate = false
+    sagaCompensatePersistModeUpdate = false
+  }
+  loadBalance {
+      type = "XID"
+      virtualNodes = 10
+  }
+}
diff --git a/test-old-version/src/test/resources/logback.xml 
b/test-old-version/src/test/resources/logback.xml
new file mode 100755
index 0000000000..8004d75c74
--- /dev/null
+++ b/test-old-version/src/test/resources/logback.xml
@@ -0,0 +1,31 @@
+<?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.
+
+-->
+<configuration>
+       <!-- Console output log -->
+       <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+               <layout class="ch.qos.logback.classic.PatternLayout">
+                       <Pattern>%date [SEATA] [%thread] %-5level %logger{80} - 
%msg%n</Pattern>
+               </layout>
+       </appender>
+
+       <root level="INFO">
+               <appender-ref ref="STDOUT" />
+       </root>
+</configuration>
diff --git a/test-old-version/src/test/resources/registry.conf 
b/test-old-version/src/test/resources/registry.conf
new file mode 100644
index 0000000000..bab6e8ec0e
--- /dev/null
+++ b/test-old-version/src/test/resources/registry.conf
@@ -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.
+#
+
+registry {
+  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
+  type = "file"
+
+  nacos {
+    serverAddr = "localhost"
+    namespace = ""
+    cluster = "default"
+  }
+  eureka {
+    serviceUrl = "http://localhost:8761/eureka";
+    application = "default"
+    weight = "1"
+  }
+  redis {
+    serverAddr = "localhost:6379"
+    db = "0"
+  }
+  zk {
+    cluster = "default"
+    serverAddr = "127.0.0.1:2181"
+    sessionTimeout = 6000
+    connectTimeout = 2000
+  }
+  consul {
+    cluster = "default"
+    serverAddr = "127.0.0.1:8500"
+  }
+  etcd3 {
+    cluster = "default"
+    serverAddr = "http://localhost:2379";
+  }
+  sofa {
+    serverAddr = "127.0.0.1:9603"
+    application = "default"
+    region = "DEFAULT_ZONE"
+    datacenter = "DefaultDataCenter"
+    cluster = "default"
+    group = "SEATA_GROUP"
+    addressWaitTime = "3000"
+  }
+  file {
+    name = "file.conf"
+  }
+}
+
+config {
+  # file、nacos 、apollo、zk、consul、etcd3
+  type = "file"
+
+  nacos {
+    serverAddr = "localhost"
+    namespace = ""
+  }
+  consul {
+    serverAddr = "127.0.0.1:8500"
+  }
+  apollo {
+    appId = "seata-server"
+    apolloMeta = "http://192.168.1.204:8801";
+  }
+  zk {
+    serverAddr = "127.0.0.1:2181"
+    sessionTimeout = 6000
+    connectTimeout = 2000
+  }
+  etcd3 {
+    serverAddr = "http://localhost:2379";
+  }
+  file {
+    name = "file.conf"
+  }
+}
diff --git 
a/test/src/test/java/org/apache/seata/core/rpc/netty/mockserver/MockServerTest.java
 
b/test/src/test/java/org/apache/seata/core/rpc/netty/mockserver/MockServerTest.java
index d1923a0816..88f7fa7e6f 100644
--- 
a/test/src/test/java/org/apache/seata/core/rpc/netty/mockserver/MockServerTest.java
+++ 
b/test/src/test/java/org/apache/seata/core/rpc/netty/mockserver/MockServerTest.java
@@ -104,7 +104,7 @@ public class MockServerTest {
         TransactionManager tm = TmClientTest.getTm();
         DefaultResourceManager rm = RmClientTest.getRm(RESOURCE_ID);
 
-        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP, "test", 60000);
+        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP, "test-commit", 60000);
         MockCoordinator.getInstance().setExpectedRetry(xid, times);
         Long branchId = rm.branchRegister(BranchType.TCC, RESOURCE_ID, "1", 
xid, "{\"mock\":\"mock\"}", "1");
         GlobalStatus commit = tm.commit(xid);
@@ -117,7 +117,7 @@ public class MockServerTest {
         TransactionManager tm = TmClientTest.getTm();
         DefaultResourceManager rm = RmClientTest.getRm(RESOURCE_ID);
 
-        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP, "test", 60000);
+        String xid = tm.begin(ProtocolTestConstants.APPLICATION_ID, 
ProtocolTestConstants.SERVICE_GROUP, "test-rollback", 60000);
         logger.info("doTestRollback xid:{}", xid);
         MockCoordinator.getInstance().setExpectedRetry(xid, times);
         Long branchId = rm.branchRegister(BranchType.TCC, RESOURCE_ID, "1", 
xid, "{\"mock\":\"mock\"}", "1");


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org


Reply via email to