Skip to content

[Bug]: <Detect Flaky Test in MySQLSrcDataProviderTest> #2897

@LucaDai

Description

@LucaDai

Related Template(s)

v2/spanner-common

Template Version

N/A

What happened?

Detected flaky behavior in unit test under NonDex randomization.

Test class: com.google.cloud.teleport.v2.spanner.testutils.failureinjectiontesting.MySQLSrcDataProviderTest
Test method: testCreateSourceResourceManagerWithSchema

NonDex detected inconsistent test results caused by nondeterministic column ordering when generating SQL statements from HashMap entries.

Under certain random seeds, the generated SQL string for the books table can be either:

  • "book_id INT NOT NULL, name VARCHAR(200), author_id INT NOT NULL, PRIMARY KEY ( book_id )"
  • "book_id INT NOT NULL, author_id INT NOT NULL, name VARCHAR(200), PRIMARY KEY ( book_id )"

Expected:
Stable output independent of Map iteration order.

How to Reproduce

Reproduced the failure using NonDex, a tool from the University of Illinois designed to detect ID tests (Iteration-Dependent tests).

Environment

Java: 17.x
Maven: 3.9.x
Build module

mvn clean install -DskipTests -pl v2/spanner-common -am

Run a single test (no shuffling)

mvn test -pl v2/spanner-common \
  -Dtest=com.google.cloud.teleport.v2.spanner.testutils.failureinjectiontesting.MySQLSrcDataProviderTest \
  -Dmaven.test.redirectTestOutputToFile=false

Run with NonDex (shuffling)

mvn edu.illinois:nondex-maven-plugin:2.2.1:nondex \
  -pl v2/spanner-common \
  -Dtest=com.google.cloud.teleport.v2.spanner.testutils.failureinjectiontesting.MySQLSrcDataProviderTest \
  -DnondexRuns=5

Relevant log output

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   MySQLSrcDataProviderTest.testCreateSourceResourceManagerWithSchema:80 expected: book_id INT NOT NULL, name VARCHAR(200), author_id INT NOT NULL, PRIMARY KEY ( book_id )
but was : book_id INT NOT NULL, author_id INT NOT NULL, name VARCHAR(200), PRIMARY KEY ( book_id )
[INFO] 
[ERROR] Tests run: 335, Failures: 1, Errors: 0, Skipped: 0
[INFO] 
[ERROR] There are test failures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions