Skip to content

Add unit test for multiple WAL consumers concurrently do synchronization #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

saeidrastak
Copy link

@saeidrastak saeidrastak commented Jul 26, 2022

Add unit test for multiple WAL consumers concurrently do synchronization

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

// Start WAL consumers.
WalConsumer[] consumers = new WalConsumer[numConsumers];
for (int i = 0; i < numConsumers; i++) {
consumers[i] = new WalConsumer(TestWalEntity.class, this::synchronizeModel, sessionFactory, "my_app");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can not check the order using HashMap, so for this test, it is better to use a Vector or CopyOnWriteArrayList (which are thread-safe) and check the exact order on them. So please define two methods: synchronizeMap (for the first test) and synchronizeVector (for the second test). Also rename the data structures to targetMap and targetVector.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants