Skip to content

Commit

Permalink
test: fix testCompensationStateMachine fail (#6565)
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes authored May 21, 2024
1 parent 3445656 commit 682b830
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6484](https://github.com/apache/incubator-seata/pull/6484)] fix FileConfigurationTest and MockServerTest fail
- [[#6545](https://github.com/apache/incubator-seata/pull/6545)] fix TestConfigCustomSPI compatibility test fail
- [[#6560](https://github.com/apache/incubator-seata/pull/6560)] fix mock-server test, do not shutdown in Runtime.getRuntime().addShutdownHook
- [[#6565](https://github.com/apache/incubator-seata/pull/6565)] fix testCompensationStateMachine fail

### refactor:
- [[#6280](https://github.com/apache/incubator-seata/pull/6280)] refactor Saga designer using diagram-js
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@
- [[#6484](https://github.com/apache/incubator-seata/pull/6484)] 修复FileConfigurationTest和MockServerTest失败
- [[#6545](https://github.com/apache/incubator-seata/pull/6545)] 修复 TestConfigCustomSPI 兼容性测试失败
- [[#6560](https://github.com/apache/incubator-seata/pull/6560)] 修复 mockserver test,不在 Runtime.getRuntime().addShutdownHook 中关闭
- [[#6565](https://github.com/apache/incubator-seata/pull/6565)] 修复 testCompensationStateMachine 与mockServer单测冲突

### refactor:
- [[#6280](https://github.com/apache/incubator-seata/pull/6280)] 使用diagram-js重构Saga设计器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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;
Expand All @@ -30,6 +31,7 @@
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;
Expand All @@ -45,6 +47,7 @@ public class MockServerTest {

@BeforeAll
public static void before() {
ConfigurationFactory.reload();
ConfigurationTestHelper.putConfig(ConfigurationKeys.SERVER_SERVICE_PORT_CAMEL, String.valueOf(ProtocolTestConstants.MOCK_SERVER_PORT));
MockServer.start(ProtocolTestConstants.MOCK_SERVER_PORT);
TmNettyRemotingClient.getInstance().destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.apache.seata.core.context.RootContext;
import org.apache.seata.core.exception.TransactionException;
import org.apache.seata.core.model.GlobalStatus;
import org.apache.seata.core.rpc.netty.RmNettyRemotingClient;
import org.apache.seata.core.rpc.netty.TmNettyRemotingClient;
import org.apache.seata.saga.engine.AsyncCallback;
import org.apache.seata.saga.engine.StateMachineEngine;
import org.apache.seata.saga.engine.exception.EngineExecutionException;
Expand All @@ -47,6 +49,7 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
Expand All @@ -65,9 +68,9 @@ public class StateMachineDBTests extends AbstractServerTest {

@BeforeAll
public static void initApplicationContext() throws InterruptedException {

startSeataServer();

TmNettyRemotingClient.getInstance().destroy();
RmNettyRemotingClient.getInstance().destroy();
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:saga/spring/statemachine_engine_db_test.xml");
stateMachineEngine = applicationContext.getBean("stateMachineEngine", StateMachineEngine.class);
StateMachineEngineHolder.setStateMachineEngine(stateMachineEngine);
Expand All @@ -76,6 +79,8 @@ public static void initApplicationContext() throws InterruptedException {
@AfterAll
public static void destory() throws InterruptedException {
stopSeataServer();
TmNettyRemotingClient.getInstance().destroy();
RmNettyRemotingClient.getInstance().destroy();
}

private GlobalTransaction getGlobalTransaction(StateMachineInstance instance) {
Expand Down

0 comments on commit 682b830

Please sign in to comment.