Skip to content

Commit

Permalink
Separate out coverage files for different executors (apache#16689)
Browse files Browse the repository at this point in the history
* Separate out coverage files for different executors

The coverage files and virtualenvs were not separated out
for different executors - running them in parallell could cause
the files override each other and mysterious failures of
the K8S tests.

This PR separates out the coverage files.

* Update TESTING.rst
  • Loading branch information
potiuk authored Jun 28, 2021
1 parent 866a601 commit 977da8d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
6 changes: 6 additions & 0 deletions TESTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ Running Kubernetes tests via shell:

.. code-block:: bash
export EXECUTOR="KubernetesExecutor" ## can be also CeleryExecutor or CeleryKubernetesExecutor
./scripts/ci/kubernetes/ci_run_kubernetes_tests.sh - runs all kubernetes tests
./scripts/ci/kubernetes/ci_run_kubernetes_tests.sh TEST [TEST ...] - runs selected kubernetes tests (from kubernetes_tests folder)
Expand Down Expand Up @@ -657,6 +659,10 @@ in the host.

You can enter the shell via those scripts

.. code-block:: bash
export EXECUTOR="KubernetesExecutor" ## can be also CeleryExecutor or CeleryKubernetesExecutor
./scripts/ci/kubernetes/ci_run_kubernetes_tests.sh [-i|--interactive] - Activates virtual environment ready to run tests and drops you in
./scripts/ci/kubernetes/ci_run_kubernetes_tests.sh [--help] - Prints this help message
Expand Down
7 changes: 5 additions & 2 deletions scripts/ci/kubernetes/ci_run_helm_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
# shellcheck source=scripts/ci/libraries/_script_init.sh
. "$( dirname "${BASH_SOURCE[0]}" )/../libraries/_script_init.sh"

EXECUTOR=KubernetesExecutor
export EXECUTOR

# We started with KubernetesExecutor. Let's run tests first
"$( dirname "${BASH_SOURCE[0]}" )/ci_run_kubernetes_tests.sh"
for mode in CeleryExecutor KubernetesExecutor
for EXECUTOR in CeleryExecutor KubernetesExecutor
do
kind::upgrade_airflow_with_helm "${mode}"
kind::upgrade_airflow_with_helm "${EXECUTOR}"
"$( dirname "${BASH_SOURCE[0]}" )/ci_run_kubernetes_tests.sh"
done
6 changes: 4 additions & 2 deletions scripts/ci/kubernetes/ci_run_kubernetes_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# shellcheck source=scripts/ci/libraries/_script_init.sh
. "$( dirname "${BASH_SOURCE[0]}" )/../libraries/_script_init.sh"

: "${EXECUTOR:?You must set EXECUTOR to one of 'KubernetesExecutor', 'CeleryExecutor', 'CeleryKubernetesExecutor' }"

kind::make_sure_kubernetes_tools_are_installed
kind::get_kind_cluster_name

Expand Down Expand Up @@ -62,7 +64,7 @@ function parse_tests_to_run() {
"--durations=100"
"--cov=airflow/"
"--cov-config=.coveragerc"
"--cov-report=xml:files/coverage=${KIND_CLUSTER_NAME}.xml"
"--cov-report=xml:files/coverage-${KIND_CLUSTER_NAME}-${HOST_PYTHON_VERSION}-${EXECUTOR}.xml"
"--color=yes"
"--maxfail=50"
"--pythonwarnings=ignore::DeprecationWarning"
Expand All @@ -76,7 +78,7 @@ function create_virtualenv() {
HOST_PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info[0]}.{sys.version_info[1]}")')
readonly HOST_PYTHON_VERSION

local virtualenv_path="${BUILD_CACHE_DIR}/.kubernetes_venv/${KIND_CLUSTER_NAME}_host_python_${HOST_PYTHON_VERSION}"
local virtualenv_path="${BUILD_CACHE_DIR}/.kubernetes_venv/${KIND_CLUSTER_NAME}_host_python_${HOST_PYTHON_VERSION}_${EXECUTOR}"

mkdir -pv "${BUILD_CACHE_DIR}/.kubernetes_venv/"
if [[ ! -d ${virtualenv_path} ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ fi
export PYTHON_MAJOR_MINOR_VERSION=$1
shift

if [[ $1 == "" ]]; then
>&2 echo "Requires executor mode as third parameter"
exit 1
fi
export EXECUTOR=$1
shift


# Requires PARALLEL_JOB_STATUS

Expand All @@ -41,6 +48,7 @@ fi
echo
echo "KUBERNETES_VERSION: ${KUBERNETES_VERSION}"
echo "PYTHON_MAJOR_MINOR_VERSION: ${PYTHON_MAJOR_MINOR_VERSION}"
echo "EXECUTOR: ${EXECUTOR}"
echo

# shellcheck source=scripts/ci/libraries/_script_init.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ fi
export PYTHON_MAJOR_MINOR_VERSION=$1
shift

if [[ $1 == "" ]]; then
>&2 echo "Requires executor mode as third parameter"
exit 1
fi
export EXECUTOR=$1
shift


# Requires PARALLEL_JOB_STATUS

Expand All @@ -41,6 +48,7 @@ fi
echo
echo "KUBERNETES_VERSION: ${KUBERNETES_VERSION}"
echo "PYTHON_MAJOR_MINOR_VERSION: ${PYTHON_MAJOR_MINOR_VERSION}"
echo "EXECUTOR: ${EXECUTOR}"
echo

# shellcheck source=scripts/ci/libraries/_script_init.sh
Expand Down
1 change: 0 additions & 1 deletion scripts/ci/libraries/_initialization.sh
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,6 @@ function initialization::make_constants_read_only() {
readonly KIND_VERSION
readonly HELM_VERSION
readonly KUBECTL_VERSION
readonly EXECUTOR
readonly POSTGRES_VERSION
readonly MYSQL_VERSION

Expand Down
8 changes: 5 additions & 3 deletions scripts/ci/libraries/_parallel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ function parallel::get_maximum_parallel_k8s_jobs() {
function parallel::run_single_helm_test() {
local kubernetes_version=$1
local python_version=$2
local single_job_filename=$3
local executor=$3
local single_job_filename=$4
local job="Cluster-${kubernetes_version}-python-${python_version}"

mkdir -p "${PARALLEL_MONITORED_DIR}/${SEMAPHORE_NAME}/${job}"
Expand All @@ -283,7 +284,7 @@ function parallel::run_single_helm_test() {
echo "Starting helm tests for kubernetes version ${kubernetes_version}, python version: ${python_version}"
parallel --ungroup --bg --semaphore --semaphorename "${SEMAPHORE_NAME}" \
--jobs "${MAX_PARALLEL_K8S_JOBS}" "${single_job_filename}" \
"${kubernetes_version}" "${python_version}" >"${JOB_LOG}" 2>&1
"${kubernetes_version}" "${python_version}" "${executor}" >"${JOB_LOG}" 2>&1
}

function parallel::run_helm_tests_in_parallel() {
Expand All @@ -305,7 +306,8 @@ function parallel::run_helm_tests_in_parallel() {
export FORWARDED_PORT_NUMBER
API_SERVER_PORT=$((19090 + index))
export API_SERVER_PORT
parallel::run_single_helm_test "${kubernetes_version}" "${python_version}" "${single_job_filename}" "${@}"
# shellcheck disable=SC2153
parallel::run_single_helm_test "${kubernetes_version}" "${python_version}" "${EXECUTOR}" "${single_job_filename}" "${@}"
done
set +e
parallel --semaphore --semaphorename "${SEMAPHORE_NAME}" --wait
Expand Down

0 comments on commit 977da8d

Please sign in to comment.