You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by sh...@apache.org on 2026/05/21 15:28:10 UTC

(beam) branch master updated: Fix flaky MatrixPowerTest.test_basics by reading all generated shards (#38585)

This is an automated email from the ASF dual-hosted git repository.

shunping pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 898c1a8e22a Fix flaky MatrixPowerTest.test_basics by reading all generated shards (#38585)
898c1a8e22a is described below

commit 898c1a8e22aa6a3048f6a9bab82d008155613fbe
Author: Shunping Huang <sh...@google.com>
AuthorDate: Thu May 21 11:28:01 2026 -0400

    Fix flaky MatrixPowerTest.test_basics by reading all generated shards (#38585)
    
    * Fix flaky MatrixPowerTest.test_basics by reading all generated shards
    
    * Address comments.
---
 sdks/python/apache_beam/examples/matrix_power_test.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/sdks/python/apache_beam/examples/matrix_power_test.py b/sdks/python/apache_beam/examples/matrix_power_test.py
index ff17ca5ff12..b824ba7e24c 100644
--- a/sdks/python/apache_beam/examples/matrix_power_test.py
+++ b/sdks/python/apache_beam/examples/matrix_power_test.py
@@ -17,6 +17,7 @@
 
 """Test for the matrix power integration test."""
 
+import glob
 import logging
 import tempfile
 import unittest
@@ -51,9 +52,15 @@ class MatrixPowerTest(unittest.TestCase):
         '--input_matrix=%s --input_vector=%s --exponent=%d --output=%s.result' %
         (matrix_path, vector_path, self.EXPONENT, vector_path)).split())
     # Parse result file and compare.
-    with open(vector_path + '.result-00000-of-00001') as result_file:
-      results = result_file.read()
-      self.assertEqual(sorted(self.EXPECTED_OUTPUT), sorted(results))
+    shard_paths = glob.glob(vector_path + '.result*')
+    self.assertTrue(
+        shard_paths,
+        'No output shards found matching prefix: %s.result' % vector_path)
+    results = []
+    for path in shard_paths:
+      with open(path) as result_file:
+        results.append(result_file.read())
+    self.assertEqual(sorted(self.EXPECTED_OUTPUT), sorted(''.join(results)))
 
 
 if __name__ == '__main__':