Skip to content

Commit 247a5fa

Browse files
committed
[WAYANG-594] Fix flaky test in TensorflowIrisScalaLikeApiIT
Replace invalid random comparator (sort(e -> r.nextInt())) with a stable random-key shuffle to satisfy the comparator contract and eliminate intermittent test failures.
1 parent c9f3702 commit 247a5fa

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

wayang-tests-integration/src/test/java/org/apache/wayang/tests/TensorflowIrisScalaLikeApiIT.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,13 @@ void test() {
160160
DataQuantaBuilder<?, String> textFileSource = plan.readTextFile(uri.toString());
161161

162162
if (random) {
163+
// Assign random keys for shuffling, then sort by those keys
164+
// This avoids comparator contract violations from r.nextInt()
163165
Random r = new Random();
164-
textFileSource = textFileSource.sort(e -> r.nextInt());
166+
textFileSource = textFileSource
167+
.map(line -> new Tuple<>(r.nextDouble(), line))
168+
.sort(tuple -> tuple.field0)
169+
.map(tuple -> tuple.field1);
165170
}
166171

167172
MapDataQuantaBuilder<String, Tuple<float[], Integer>> mapXY = textFileSource.map(line -> {

0 commit comments

Comments
 (0)