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


##########
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:
   @HyukjinKwon , sorry didn't understand it completely . Please help . 
   Originally SPARK_LOCAL_DIRS is not set in the environment variable(it has no 
default value)  . So as part of this test it was set , once test case completed 
, it was removed at the end of the test case, so that rest of the cases work as 
is . 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to