You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/06/03 00:44:48 UTC

[GitHub] [spark] HyukjinKwon commented on a diff in pull request #36701: [SPARK-39179][PYTHON][TESTS] Improve the test coverage for pyspark/shuffle.py

HyukjinKwon commented on code in PR #36701:
URL: https://github.com/apache/spark/pull/36701#discussion_r888519237


##########
python/pyspark/tests/test_shuffle.py:
##########
@@ -54,6 +63,49 @@ def test_medium_dataset(self):
         self.assertTrue(m.spills >= 1)
         self.assertEqual(sum(sum(v) for k, v in m.items()), sum(range(self.N)) * 3)
 
+    def test_shuffle_data_with_multiple_locations(self):
+        # SPARK-39179: Test shuffle of data with multiple location also check
+        # shuffle locations get randomized
+
+        with tempfile.TemporaryDirectory() as tempdir1, tempfile.TemporaryDirectory() as tempdir2:
+            os.environ["SPARK_LOCAL_DIRS"] = tempdir1 + "," + tempdir2
+            index_of_tempdir1 = [False, False]
+            for idx in range(10):
+                m = ExternalMerger(self.agg, 20)
+                if m.localdirs[0].startswith(tempdir1):
+                    index_of_tempdir1[0] = True
+                elif m.localdirs[1].startswith(tempdir1):
+                    index_of_tempdir1[1] = True
+                m.mergeValues(self.data)
+                self.assertTrue(m.spills >= 1)
+                self.assertEqual(sum(sum(v) for k, v in m.items()), sum(range(self.N)))
+            self.assertTrue(index_of_tempdir1[0] and (index_of_tempdir1[0] == index_of_tempdir1[1]))
+            del os.environ["SPARK_LOCAL_DIRS"]

Review Comment:
   @pralabhkumar let's probably restore to the original value so other tests won't be affected. For exmaple, after this test, `SPARK_LOCAL_DIRS` will be removed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org