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

test: fix UT failed in AsyncWorkerTest and LockManagerTest #4731

Merged
merged 2 commits into from Jun 29, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion changes/en-us/develop.md
Expand Up @@ -24,14 +24,16 @@ Add changes here for all PR submitted to the develop branch.
- [[#4670](https://github.com/seata/seata/pull/4670)] optimize the thread pool size of branchResultMessageExecutor
- [[#4662](https://github.com/seata/seata/pull/4662)] optimize rollback transaction metrics
- [[#4693](https://github.com/seata/seata/pull/4693)] optimize the console navigation bar
- [[#4544](https://github.com/seata/seata/pull/4544)] optimize jackson dependencies in TransactionContextFilterTest
- [[#4700](https://github.com/seata/seata/pull/4700)] fix maven-compiler-plugin and maven-resources-plugin execute failed
- [[#4711](https://github.com/seata/seata/pull/4711)] separate lib dependencies for deployments
- [[#4720](https://github.com/seata/seata/pull/4720)] optimize pom description
- [[#4728](https://github.com/seata/seata/pull/4728)] upgrade logback dependency to 1.2.9

### test:

- [[#4544](https://github.com/seata/seata/pull/4544)] optimize jackson dependencies in TransactionContextFilterTest
- [[#4731](https://github.com/seata/seata/pull/4731)] fix UT failed in AsyncWorkerTest and LockManagerTest

Thanks to these contributors for their code commits. Please report an unintended omission.

<!-- Please make sure your Github ID is in the list below -->
Expand Down
3 changes: 2 additions & 1 deletion changes/zh-cn/develop.md
Expand Up @@ -23,13 +23,14 @@
- [[#4670](https://github.com/seata/seata/pull/4670)] 优化branchResultMessageExecutor线程池的线程数
- [[#4662](https://github.com/seata/seata/pull/4662)] 优化回滚事务监控指标
- [[#4693](https://github.com/seata/seata/pull/4693)] 优化控制台导航栏
- [[#4544](https://github.com/seata/seata/pull/4544)] 优化测试用例TransactionContextFilterTest中jackson包依赖问题
- [[#4700](https://github.com/seata/seata/pull/4700)] 修复 maven-compiler-plugin 和 maven-resources-plugin 执行失败
- [[#4711](https://github.com/seata/seata/pull/4711)] 分离部署时 lib 依赖
- [[#4720](https://github.com/seata/seata/pull/4720)] 优化pom描述
- [[#4728](https://github.com/seata/seata/pull/4728)] 将logback版本依赖升级至1.2.9

### test:
- [[#4544](https://github.com/seata/seata/pull/4544)] 优化TransactionContextFilterTest中jackson包依赖问题
- [[#4731](https://github.com/seata/seata/pull/4731)] 修复 AsyncWorkerTest 和 LockManagerTest 的单测问题。


非常感谢以下 contributors 的代码贡献。若有无意遗漏,请报告。
Expand Down
Expand Up @@ -34,6 +34,7 @@
import com.google.common.collect.Lists;
import io.seata.common.thread.NamedThreadFactory;
import io.seata.common.util.IOUtil;
import io.seata.common.util.StringUtils;
import io.seata.config.ConfigurationFactory;
import io.seata.core.model.BranchStatus;
import io.seata.rm.datasource.undo.UndoLogManager;
Expand Down Expand Up @@ -127,13 +128,22 @@ private void doBranchCommit() {
Map<String, List<Phase2Context>> groupedByResourceId(List<Phase2Context> contexts) {
Map<String, List<Phase2Context>> groupedContexts = new HashMap<>(DEFAULT_RESOURCE_SIZE);
contexts.forEach(context -> {
if (StringUtils.isBlank(context.resourceId)) {
LOGGER.warn("resourceId is empty, resource:{}", context);
return;
}
List<Phase2Context> group = groupedContexts.computeIfAbsent(context.resourceId, key -> new LinkedList<>());
group.add(context);
});
return groupedContexts;
}

private void dealWithGroupedContexts(String resourceId, List<Phase2Context> contexts) {
if (StringUtils.isBlank(resourceId)) {
//ConcurrentHashMap required notNull key
LOGGER.warn("resourceId is empty and will skip.");
return;
}
DataSourceProxy dataSourceProxy = dataSourceManager.get(resourceId);
if (dataSourceProxy == null) {
LOGGER.warn("failed to find resource for {} and requeue", resourceId);
Expand Down Expand Up @@ -210,5 +220,11 @@ public Phase2Context(String xid, long branchId, String resourceId) {
* The Resource id.
*/
String resourceId;

@Override
public String toString() {
return "Phase2Context{" + "xid='" + xid + '\'' + ", branchId=" + branchId + ", resourceId='" + resourceId
+ '\'' + '}';
}
}
}
Expand Up @@ -39,13 +39,13 @@
import io.seata.server.session.GlobalSession;
import io.seata.server.session.SessionCondition;
import io.seata.server.session.SessionManager;
import io.seata.server.store.AbstractTransactionStoreManager;
import io.seata.server.storage.file.FlushDiskMode;
import io.seata.server.storage.file.ReloadableStore;
import io.seata.server.storage.file.TransactionWriteStore;
import io.seata.server.store.AbstractTransactionStoreManager;
import io.seata.server.store.SessionStorable;
import io.seata.server.store.StoreConfig;
import io.seata.server.store.TransactionStoreManager;
import io.seata.server.storage.file.TransactionWriteStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
Expand Down Expand Up @@ -335,7 +335,9 @@ public void shutdown() {
}
}
try {
currFileChannel.force(true);
if (currFileChannel.isOpen()) {
currFileChannel.force(true);
}
} catch (IOException e) {
LOGGER.error("fileChannel force error: {}", e.getMessage(), e);
}
Expand Down