You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by tw...@apache.org on 2018/08/01 09:59:23 UTC

[flink] branch release-1.6 updated: [FLINK-9874][E2E Tests] Fix set_ssl_conf for macOS

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

twalthr pushed a commit to branch release-1.6
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.6 by this push:
     new ed20d4d  [FLINK-9874][E2E Tests] Fix set_ssl_conf for macOS
ed20d4d is described below

commit ed20d4dd76b1107bdd0987b3e6439a52c8aa6535
Author: Florian Schmidt <fl...@icloud.com>
AuthorDate: Mon Jul 30 11:36:09 2018 +0200

    [FLINK-9874][E2E Tests] Fix set_ssl_conf for macOS
    
    This fixes the set_ssl_conf utility function under macOS. The previous
    version was using `hostname -I` regardless of the OS, but the -I option
    is not available on the BSD version of hostname.
    
    This is now fixed by checking for all IPv4 addresses from ifconfig if the
    OS is macOS and formatting the output to be identical to `hostname -I`.
    
    Additionally the filtering of the output is removed so that now all
    ip addresses are appended to the SANSTRING instead of just one.
    
    This closes #9874.
---
 flink-end-to-end-tests/test-scripts/common.sh | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/flink-end-to-end-tests/test-scripts/common.sh b/flink-end-to-end-tests/test-scripts/common.sh
index 621db11..0ab2ffa 100644
--- a/flink-end-to-end-tests/test-scripts/common.sh
+++ b/flink-end-to-end-tests/test-scripts/common.sh
@@ -146,6 +146,27 @@ function create_ha_config() {
 EOL
 }
 
+function get_node_ip {
+    local ip_addr
+
+    if [[ ${OS_TYPE} == "linux" ]]; then
+        ip_addr=$(hostname -I)
+    elif [[ ${OS_TYPE} == "mac" ]]; then
+        ip_addr=$(
+            ifconfig |
+            grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | # grep IPv4 addresses only
+            grep -v 127.0.0.1 |                     # do not use 127.0.0.1 (to be consistent with hostname -I)
+            awk '{ print $2 }' |                    # extract ip from row
+            paste -sd " " -                         # combine everything to one line
+        )
+    else
+        echo "Warning: Unsupported OS_TYPE '${OS_TYPE}' for 'get_node_ip'. Falling back to 'hostname -I' (linux)"
+        ip_addr=$(hostname -I)
+    fi
+
+    echo ${ip_addr}
+}
+
 function set_conf_ssl {
 
     # clean up the dir that will be used for SSL certificates and trust stores
@@ -154,12 +175,15 @@ function set_conf_ssl {
        rm -rf "${TEST_DATA_DIR}/ssl"
     fi
     mkdir -p "${TEST_DATA_DIR}/ssl"
+
     NODENAME=`hostname -f`
     SANSTRING="dns:${NODENAME}"
-    for NODEIP in `hostname -I | cut -d' ' -f1` ; do
+    for NODEIP in $(get_node_ip) ; do
         SANSTRING="${SANSTRING},ip:${NODEIP}"
     done
 
+    echo "Using SAN ${SANSTRING}"
+
     # create certificates
     keytool -genkeypair -alias ca -keystore "${TEST_DATA_DIR}/ssl/ca.keystore" -dname "CN=Sample CA" -storepass password -keypass password -keyalg RSA -ext bc=ca:true
     keytool -keystore "${TEST_DATA_DIR}/ssl/ca.keystore" -storepass password -alias ca -exportcert > "${TEST_DATA_DIR}/ssl/ca.cer"