forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathci_run_airflow_testing.sh
executable file
·105 lines (88 loc) · 3.4 KB
/
ci_run_airflow_testing.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -euo pipefail
MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# shellcheck source=scripts/ci/_utils.sh
. "${MY_DIR}/_utils.sh"
export VERBOSE=${VERBOSE:="true"}
basic_sanity_checks
script_start
rebuild_ci_image_if_needed
# Test environment
export BACKEND=${BACKEND:="sqlite"}
export ENV=${ENV:="docker"}
export KUBERNETES_MODE=${KUBERNETES_MODE:="git_mode"}
# Whether local sources are mounted to docker
export MOUNT_LOCAL_SOURCES=${MOUNT_LOCAL_SOURCES:="false"}
# whethere verbose output should be produced
export AIRFLOW_CI_VERBOSE=${VERBOSE}
# opposite - whether diagnostict messages should be silenced
export AIRFLOW_CI_SILENT=${AIRFLOW_CI_SILENT:="true"}
if [[ ${MOUNT_LOCAL_SOURCES} == "true" ]]; then
DOCKER_COMPOSE_LOCAL=("-f" "${MY_DIR}/docker-compose-local.yml")
else
DOCKER_COMPOSE_LOCAL=()
fi
export AIRFLOW_CONTAINER_DOCKER_IMAGE=\
${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${AIRFLOW_CONTAINER_BRANCH_NAME}-python${PYTHON_VERSION}-ci
echo
echo "Using docker image: ${AIRFLOW_CONTAINER_DOCKER_IMAGE} for docker compose runs"
echo
HOST_USER_ID="$(id -ur)"
export HOST_USER_ID
HOST_GROUP_ID="$(id -gr)"
export HOST_GROUP_ID
set +u
if [[ "${ENV}" == "docker" ]]; then
docker-compose --log-level INFO \
-f "${MY_DIR}/docker-compose.yml" \
-f "${MY_DIR}/docker-compose-${BACKEND}.yml" \
"${DOCKER_COMPOSE_LOCAL[@]}" \
run airflow-testing /opt/airflow/scripts/ci/in_container/entrypoint_ci.sh;
elif [[ "${ENV}" == "kubernetes" ]]; then
echo
echo "Running kubernetes tests in ${KUBERNETES_MODE}"
echo
"${MY_DIR}/kubernetes/minikube/stop_minikube.sh"
"${MY_DIR}/kubernetes/setup_kubernetes.sh"
"${MY_DIR}/kubernetes/kube/deploy.sh" -d "${KUBERNETES_MODE}"
MINIKUBE_IP=$(minikube ip)
export MINIKUBE_IP
docker-compose --log-level ERROR \
-f "${MY_DIR}/docker-compose.yml" \
-f "${MY_DIR}/docker-compose-${BACKEND}.yml" \
-f "${MY_DIR}/docker-compose-kubernetes.yml" \
"${DOCKER_COMPOSE_LOCAL[@]}" \
run --no-deps airflow-testing /opt/airflow/scripts/ci/in_container/entrypoint_ci.sh;
"${MY_DIR}/kubernetes/minikube/stop_minikube.sh"
echo
echo "Finished Running kubernetes tests in ${KUBERNETES_MODE}"
echo
elif [[ "${ENV}" == "bare" ]]; then
docker-compose --log-level INFO \
-f "${MY_DIR}/docker-compose.yml" \
-f "${MY_DIR}/docker-compose-${BACKEND}.yml" \
"${DOCKER_COMPOSE_LOCAL[@]}" \
run --no-deps airflow-testing /opt/airflow/scripts/ci/in_container/entrypoint_ci.sh;
else
echo >&2
echo >&2 "ERROR: The ENV variable should be one of [docker, kubernetes, bare] and is '${ENV}'"
echo >&2
fi
set -u
script_end