Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix seata-test module UT not work #4276

Merged
merged 8 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions changes/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#4220](https://github.com/seata/seata/pull/4220)] 修复 `zstd-compressor` 模块未合并到 `seata-all` 中的问题,同时修正其包名。另外,补充了 `kotlin-maven-plugin` 的版本号;顺便优化打包配置。
- [[#4222](https://github.com/seata/seata/pull/4222)] 修复字段列表为空时,插入语句无法回滚的问题
- [[#4233](https://github.com/seata/seata/pull/4233)] 修复 lock 和 branch 数据残留问题
- [[#4276](https://github.com/seata/seata/pull/4276)] 修复 seata-test 单测不运行的问题


### optimize:
Expand Down Expand Up @@ -197,6 +198,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [portman](https://github.com/iportman)
- [lcmvs](https://github.com/lcmvs)
- [pengten](https://github.com/pengten)
- [anselleeyy](https://github.com/anselleeyy)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。

Expand Down
2 changes: 2 additions & 0 deletions changes/en-us/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
- [[#4220](https://github.com/seata/seata/pull/4220)] fix some problems with `zstd` compressor and add the version of the `kotlin-maven-plugin`
- [[#4222](https://github.com/seata/seata/pull/4222)] fix could not rollback when insert field list is empty
- [[#4233](https://github.com/seata/seata/pull/4233)] fix data remanence problems in lock and branch under specific circumstances.
- [[#4276](https://github.com/seata/seata/pull/4276)] fix seata-test module UT not work


### optimize:
Expand Down Expand Up @@ -196,6 +197,7 @@
- [portman](https://github.com/iportman)
- [lcmvs](https://github.com/lcmvs)
- [pengten](https://github.com/pengten)
- [anselleeyy](https://github.com/anselleeyy)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,27 +286,23 @@ protected Object invokeMethod(Object serviceBean, Method method, Object... input
}
}

protected Object toJavaObject(Object value, Class<?> paramType) {
protected Object toJavaObject(Object value, Class paramType) {
if (value == null) {
return value;
}

if (value instanceof Map || value instanceof List) {
return jsonParseToJavaObject(value, paramType);
} else if (paramType.isAssignableFrom(value.getClass()) || isPrimitive(paramType)) {
if (paramType.isAssignableFrom(value.getClass())) {
return value;
} else if (isPrimitive(paramType)) {
return value;
} else {
return jsonParseToJavaObject(value, paramType);
}
}

protected Object jsonParseToJavaObject(Object value, Class<?> paramType) {
JsonParser jsonParser = JsonParserFactory.getJsonParser(getSagaJsonParser());
if (jsonParser == null) {
throw new RuntimeException("Cannot get JsonParser by name : " + getSagaJsonParser());
JsonParser jsonParser = JsonParserFactory.getJsonParser(getSagaJsonParser());
if (jsonParser == null) {
throw new RuntimeException("Cannot get JsonParser by name : " + getSagaJsonParser());
}
String jsonValue = jsonParser.toJsonString(value, true, false);
return jsonParser.parse(jsonValue, paramType, false);
}
String jsonValue = jsonParser.toJsonString(value, true, false);
return jsonParser.parse(jsonValue, paramType, false);
}

protected boolean isPrimitive(Class<?> clazz) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public String toJsonString(Object o, boolean ignoreAutoType, boolean prettyPrint
@Override
public <T> T parse(String json, Class<T> type, boolean ignoreAutoType) {
if (ignoreAutoType) {
return JSON.parseObject(json, type, Feature.DisableSpecialKeyDetect, Feature.OrderedField);
return JSON.parseObject(json, type, Feature.IgnoreAutoType, Feature.OrderedField);
}
else {
return JSON.parseObject(json, type, Feature.SupportAutoType, Feature.OrderedField);
Expand Down
8 changes: 7 additions & 1 deletion test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
<skip>true</skip>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
Expand All @@ -59,6 +59,12 @@
<groupId>${project.groupId}</groupId>
<artifactId>seata-server</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>io.seata</groupId>
<artifactId>seata-spring-autoconfigure-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
*/
package io.seata.core.rpc.netty;

import java.lang.management.ManagementFactory;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import io.netty.channel.Channel;
import io.seata.common.XID;
import io.seata.common.util.NetUtil;
Expand All @@ -24,15 +29,9 @@
import io.seata.saga.engine.db.AbstractServerTest;
import io.seata.server.UUIDGenerator;
import io.seata.server.coordinator.DefaultCoordinator;
import io.seata.server.session.SessionHolder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

import java.lang.management.ManagementFactory;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
* @author slievrly
Expand Down Expand Up @@ -121,6 +120,7 @@ public void testSendMsgWithResponse() throws Exception {
ThreadPoolExecutor workingThreads = initMessageExecutor();
NettyRemotingServer nettyRemotingServer = new NettyRemotingServer(workingThreads);
new Thread(() -> {
SessionHolder.init(null);
nettyRemotingServer.setHandler(DefaultCoordinator.getInstance(nettyRemotingServer));
// set registry
XID.setIpAddress(NetUtil.getLocalIp());
Expand All @@ -147,7 +147,7 @@ public void testSendMsgWithResponse() throws Exception {
BranchRegisterResponse branchRegisterResponse = (BranchRegisterResponse) tmNettyRemotingClient.sendSyncRequest(request);
Assertions.assertNotNull(branchRegisterResponse);
Assertions.assertEquals(ResultCode.Failed, branchRegisterResponse.getResultCode());
Assertions.assertEquals("RuntimeException[SessionManager is NOT init!]",
Assertions.assertEquals("TransactionException[Could not found global transaction xid = 127.0.0.1:8091:1249853, may be has finished.]",
branchRegisterResponse.getMsg());
nettyRemotingServer.destroy();
tmNettyRemotingClient.destroy();
Expand Down
33 changes: 33 additions & 0 deletions test/src/test/resources/file.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
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"
}

service {
#transaction service group mapping
vgroupMapping.default_tx_group = "default"
Expand Down