Skip to content

Commit 232b61f

Browse files
wangyang0918rmetzger
authored andcommitted
[FLINK-17857][e2e] Fix Kubernetes e2e tests on Mac OS
This closes #12451
1 parent 84a6025 commit 232b61f

File tree

5 files changed

+31
-4
lines changed

5 files changed

+31
-4
lines changed

flink-end-to-end-tests/test-scripts/common_docker.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ function containers_health_check() {
3535

3636
function build_image() {
3737
local image_name=${1:-flink-job}
38+
local default_file_server_address="localhost"
39+
[[ "${OS_TYPE}" != "linux" ]] && default_file_server_address="host.docker.internal"
40+
local file_server_address=${2:-${default_file_server_address}}
3841

3942
echo "Starting fileserver for Flink distribution"
4043
pushd ${FLINK_DIR}/..
@@ -47,7 +50,7 @@ function build_image() {
4750
echo "Preparing Dockeriles"
4851
git clone https://github.com/apache/flink-docker.git --branch dev-master --single-branch
4952
cd flink-docker
50-
./add-custom.sh -u localhost:9999/flink.tgz -n ${image_name}
53+
./add-custom.sh -u ${file_server_address}:9999/flink.tgz -n ${image_name}
5154

5255
echo "Building images"
5356
run_with_timeout 600 docker build --no-cache --network="host" -t ${image_name} dev/${image_name}-debian

flink-end-to-end-tests/test-scripts/common_kubernetes.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ function start_kubernetes {
9696
echo "$NON_LINUX_ENV_NOTE"
9797
exit 1
9898
fi
99+
# Mount Flink dist into minikube virtual machine because we need to mount hostPath as usrlib
100+
minikube mount $FLINK_DIR:$FLINK_DIR &
101+
export minikube_mount_pid=$!
99102
else
100103
setup_kubernetes_for_linux
101104
if ! retry_times ${MINIKUBE_START_RETRIES} ${MINIKUBE_START_BACKOFF} start_kubernetes_if_not_running; then
@@ -109,6 +112,7 @@ function start_kubernetes {
109112
function stop_kubernetes {
110113
if [[ "${OS_TYPE}" != "linux" ]]; then
111114
echo "$NON_LINUX_ENV_NOTE"
115+
kill $minikube_mount_pid 2> /dev/null
112116
else
113117
echo "Stopping minikube ..."
114118
stop_command="sudo $MINIKUBE_PATH stop"
@@ -174,4 +178,24 @@ function cleanup {
174178
stop_kubernetes
175179
}
176180

181+
function setConsoleLogging {
182+
cat >> $FLINK_DIR/conf/log4j.properties <<END
183+
rootLogger.appenderRef.console.ref = ConsoleAppender
184+
185+
# Log all infos to the console
186+
appender.console.name = ConsoleAppender
187+
appender.console.type = CONSOLE
188+
appender.console.layout.type = PatternLayout
189+
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t] %-60c %x - %m%n
190+
END
191+
}
192+
193+
function get_host_machine_address {
194+
if [[ "${OS_TYPE}" != "linux" ]]; then
195+
echo $(minikube ssh "route -n | grep ^0.0.0.0 | awk '{ print \$2 }' | tr -d '[:space:]'")
196+
else
197+
echo "localhost"
198+
fi
199+
}
200+
177201
on_exit cleanup

flink-end-to-end-tests/test-scripts/test_kubernetes_application.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function internal_cleanup {
3131

3232
start_kubernetes
3333

34-
build_image ${FLINK_IMAGE_NAME}
34+
build_image ${FLINK_IMAGE_NAME} $(get_host_machine_address)
3535

3636
kubectl create clusterrolebinding ${CLUSTER_ROLE_BINDING} --clusterrole=edit --serviceaccount=default:default --namespace=default
3737

flink-end-to-end-tests/test-scripts/test_kubernetes_embedded_job.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ start_kubernetes
3636

3737
mkdir -p $OUTPUT_VOLUME
3838

39-
build_image ${FLINK_IMAGE_NAME}
39+
build_image ${FLINK_IMAGE_NAME} $(get_host_machine_address)
4040

4141
export USER_LIB=${FLINK_DIR}/examples/batch
4242
kubectl create -f ${CONTAINER_SCRIPTS}/job-cluster-service.yaml

flink-end-to-end-tests/test-scripts/test_kubernetes_session.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function internal_cleanup {
5252

5353
start_kubernetes
5454

55-
build_image ${FLINK_IMAGE_NAME}
55+
build_image ${FLINK_IMAGE_NAME} $(get_host_machine_address)
5656

5757
kubectl create clusterrolebinding ${CLUSTER_ROLE_BINDING} --clusterrole=edit --serviceaccount=default:default --namespace=default
5858

0 commit comments

Comments
 (0)