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

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


The following commit(s) were added to refs/heads/master by this push:
     new 5e793852913 [SPARK-39572][PYTHON][TESTS] Fix `test_daemon.py` to 
support IPv6
5e793852913 is described below

commit 5e793852913bf34fe5bce60233850e35b8803650
Author: Dongjoon Hyun <dongj...@apache.org>
AuthorDate: Thu Jun 23 17:36:55 2022 -0700

    [SPARK-39572][PYTHON][TESTS] Fix `test_daemon.py` to support IPv6
    
    ### What changes were proposed in this pull request?
    
    This PR aims to fix `test_deamon.py` to support both IPv6 additionally.
    
    ### Why are the changes needed?
    
    To add IPv6-only test coverage.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Pass the CIs and do the following manually.
    ```
    $ build/sbt package
    $ SPARK_PREFER_IPV6=true python/run-tests.py --modules pyspark-core
    ```
    
    Closes #36971 from dongjoon-hyun/SPARK-39572.
    
    Authored-by: Dongjoon Hyun <dongj...@apache.org>
    Signed-off-by: Dongjoon Hyun <dongj...@apache.org>
---
 python/pyspark/tests/test_daemon.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/python/pyspark/tests/test_daemon.py 
b/python/pyspark/tests/test_daemon.py
index 87806da5580..d4cb90c4e81 100644
--- a/python/pyspark/tests/test_daemon.py
+++ b/python/pyspark/tests/test_daemon.py
@@ -24,10 +24,13 @@ from pyspark.serializers import read_int
 
 class DaemonTests(unittest.TestCase):
     def connect(self, port):
-        from socket import socket, AF_INET, SOCK_STREAM
+        from socket import socket, AF_INET, AF_INET6, SOCK_STREAM
 
-        sock = socket(AF_INET, SOCK_STREAM)
-        sock.connect(("127.0.0.1", port))
+        family, host = AF_INET, "127.0.0.1"
+        if os.environ.get("SPARK_PREFER_IPV6", "false").lower() == "true":
+            family, host = AF_INET6, "::1"
+        sock = socket(family, SOCK_STREAM)
+        sock.connect((host, port))
         # send a split index of -1 to shutdown the worker
         sock.send(b"\xFF\xFF\xFF\xFF")
         sock.close()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to