[AIRFLOW-5005] Split kubernetes tests into separate jobs (#5625)

(cherry picked from commit 87150e26fb3912dadaaa50b073d5f95ad4df1b0a)
This commit is contained in:
Jarek Potiuk 2019-07-24 08:34:14 +02:00 коммит произвёл GitHub
Родитель 078e5f8c08
Коммит 96148478ef
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 55 добавлений и 37 удалений

Просмотреть файл

@ -27,16 +27,24 @@ stages:
- test
jobs:
include:
- env: BACKEND=postgres ENV=docker
- name: "Tests postgres python 3.6"
env: BACKEND=postgres ENV=docker
python: "3.6"
stage: test
- env: BACKEND=sqlite ENV=docker
- name: "Tests sqlite python 3.5"
env: BACKEND=sqlite ENV=docker
python: "3.5"
stage: test
- env: BACKEND=mysql ENV=docker
- name: "Tests mysql python 3.6"
env: BACKEND=mysql ENV=docker
python: "3.6"
stage: test
- env: BACKEND=postgres ENV=kubernetes KUBERNETES_VERSION=v1.13.0
- name: "Tests postgres kubernetes python 3.6 (persistent)"
env: BACKEND=postgres ENV=kubernetes KUBERNETES_VERSION=v1.13.0 KUBERNETES_MODE=persistent_mode
python: "3.6"
stage: test
- name: "Tests postgres kubernetes python 3.6 (git)"
env: BACKEND=postgres ENV=kubernetes KUBERNETES_VERSION=v1.13.0 KUBERNETES_MODE=git_mode
python: "3.6"
stage: test
- name: Flake8

Просмотреть файл

@ -449,20 +449,23 @@ PYTHON_VERSION=3.5 BACKEND=postgres ENV=docker ./scripts/ci/local_ci_run_airflow
Running kubernetes tests:
```bash
KUBERNETES_VERSION==v1.13.0 BACKEND=postgres ENV=kubernetes ./scripts/ci/local_ci_run_airflow_testing.sh
KUBERNETES_VERSION==v1.13.0 KUBERNETES_MODE=persistent_mode BACKEND=postgres ENV=kubernetes \
./scripts/ci/local_ci_run_airflow_testing.sh
```
* PYTHON_VERSION might be one of 3.5/3.6
* BACKEND might be one of postgres/sqlite/mysql
* ENV might be one of docker/kubernetes/bare
* KUBERNETES_VERSION - required for Kubernetes tests - currently KUBERNETES_VERSION=v1.13.0.
* KUBERNETES_MODE - mode of kubernetes, one of persistent_mode, git_mode
The following environments are possible:
* The "docker" environment (default) - it starts all dependencies required by full suite of tests
including postgres/mysql and other components. It's quite resource heavy so do not forget to stop
the environment using [Stop environment](#stopping-the-environment) when you finish working wit it. It
can also slow down your local machine.
* The "kubernetes" environment is used to run tests with kubernetes cluster.
* The "kubernetes" environment is used to run tests with kubernetes cluster (requires KUBERNETES_VERSION
and KUBERNETES_MODE variables).
* The "bare" environment is used to run a bare docker instance of Airflow without any external dependencies
which means that you can only run it with sqlite backend.

Просмотреть файл

@ -34,6 +34,7 @@ rebuild_image_if_needed_for_tests
export BACKEND=${BACKEND:="sqlite"}
export ENV=${ENV:="docker"}
export KUBERNETES_MODE=${KUBERNETES_MODE:="git_mode"}
export MOUNT_LOCAL_SOURCES=${MOUNT_LOCAL_SOURCES:="false"}
export WEBSERVER_HOST_PORT=${WEBSERVER_HOST_PORT:="8080"}
export AIRFLOW_CI_VERBOSE=${VERBOSE}
@ -65,31 +66,35 @@ if [[ "${ENV}" == "docker" ]]; then
-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
"${MY_DIR}/kubernetes/minikube/stop_minikube.sh" && "${MY_DIR}/kubernetes/setup_kubernetes.sh" && \
"${MY_DIR}/kubernetes/kube/deploy.sh" -d persistent_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;
set +x
"${MY_DIR}/kubernetes/minikube/stop_minikube.sh"
"${MY_DIR}/kubernetes/minikube/stop_minikube.sh" && "${MY_DIR}/kubernetes/setup_kubernetes.sh" && \
"${MY_DIR}/kubernetes/kube/deploy.sh" -d git_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 >&2
echo >&2 "ERROR! The ENV variable should be one of [docker, kubernetes, bare] and is '${ENV}'"
echo >&2
fi
set -u

Просмотреть файл

@ -20,6 +20,7 @@ services:
network_mode: host
environment:
- KUBERNETES_VERSION
- KUBERNETES_MODE
- MINIKUBE_IP
volumes:
- /usr/local/bin/kubectl:/usr/local/bin/kubectl

Просмотреть файл

@ -38,6 +38,7 @@ PYTHON_VERSION=${PYTHON_VERSION:=3.6}
ENV=${ENV:=docker}
BACKEND=${BACKEND:=sqlite}
KUBERNETES_VERSION=${KUBERNETES_VERSION:=""}
KUBERNETES_MODE=${KUBERNETES_MODE:=""}
export AIRFLOW_HOME=${AIRFLOW_HOME:=${HOME}}
@ -218,7 +219,8 @@ else
echo "Running CI tests with ${ARGS[*]}"
echo
"${MY_DIR}/run_ci_tests.sh" tests.minikube "${ARGS[@]}"
codecov -e "py${PYTHON_VERSION}-backend_${BACKEND}-env_${ENV}"
codecov -e \
"py${PYTHON_VERSION}-backend_${BACKEND}-env_${ENV}-mode_${KUBERNETES_MODE}-version_${KUBERNETES_VERSION}"
fi
in_container_script_end

Просмотреть файл

@ -21,11 +21,12 @@ under the License.
If you don't have minikube installed, please run `./minikube/start_minikube.sh`
to start a k8s-instance on your local machine. Make sure that your `kubectl` is
pointing to the local k8s instance.
pointing to the local k8s instance.
First build the docker images by running `./docker/build.sh`. This will build
the image and push it to the local registry.
Secondly, deploy Apache Airflow using `./kube/deploy.sh -d persistent_mode`.
Secondly, deploy Apache Airflow using `./kube/deploy.sh -d persistent_mode` or
`./kube/deploy.sh -d git_mode`.
Finally, open the Airflow webserver
page by browsing to `http://192.168.99.100:30809/admin/` (on OSX).

Просмотреть файл

@ -15,8 +15,7 @@
# KIND, either express or implied. See the License for the *
# specific language governing permissions and limitations *
# under the License. *
set -o xtrace
set -e
set -euo pipefail
echo "This script downloads minikube, starts a driver=None minikube cluster, builds the airflow source\
and docker image, and then deploys airflow onto kubernetes"
@ -27,12 +26,11 @@ DIRNAME=$(cd "$(dirname "$0")" && pwd)
# Fix file permissions
# TODO: change this - it should be Travis independent
if [[ "${TRAVIS}" == true ]]; then
if [[ "${TRAVIS:=}" == true ]]; then
sudo chown -R travis.travis .
fi
"${DIRNAME}/minikube/start_minikube.sh"
"${DIRNAME}/docker/build.sh"
echo "Airflow environment on kubernetes is good to go!"