Skip to content
New issue

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

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

Already on GitHub? # to your account

Remove non-determinism from MySqlCreateDatabaseTest.test_3 #6240

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

Conversation

mohitbadve
Copy link

Problem Description:
For the test MySqlCreateDatabaseTest.test_3,
The function SQLASTOutputVisitor.visit() (Line:10474) method iterates a Set<Map.Entry<String, SQLName>> in a for loop, but the iteration is non-deterministic (as mentioned in javadocs) thus causing different outputs. Therefore, this test is non-determinstic since following assertions fail unexpectedly.

Error observed:
[INFO] Running com.alibaba.druid.bvt.sql.mysql.create.MySqlCreateDatabaseTest
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.414 s <<< FAILURE! - in com.alibaba.druid.bvt.sql.mysql.create.MySqlCreateDatabaseTest
[ERROR] com.alibaba.druid.bvt.sql.mysql.create.MySqlCreateDatabaseTest.test_3 Time elapsed: 0.403 s <<< FAILURE!
org.junit.ComparisonFailure:
expected:<...RED BY 'OTS'
WITH ([column_mapping = 'pk:pk,a:col1,b:col2', serializer = 'default]')> but was:<...RED BY 'OTS'
WITH ([serializer = 'default', column_mapping = 'pk:pk,a:col1,b:col2]')>
at org.junit.Assert.assertEquals(Assert.java:117)
at org.junit.Assert.assertEquals(Assert.java:146)
at com.alibaba.druid.bvt.sql.mysql.create.MySqlCreateDatabaseTest.test_3(MySqlCreateDatabaseTest.java:64)

Reproduce the failure:
One can check it using the Nondex:

cd core
mvn edu.illinois:nondex-maven-plugin:2.1.7:nondex -Dtest=MySqlCreateDatabaseTest#test_3 -DnondexRuns=10

Solution:
One solution that I thought of was to sort the set and then iterate to make the order deterministic.
Please let me know if you have any questions or need any additional justification/changes from my side.

@CLAassistant
Copy link

CLAassistant commented Nov 20, 2024

CLA assistant check
All committers have signed the CLA.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants