Skip to content

Commit 31a10de

Browse files
committed
All kubernetes tests use the same host python version (#12374)
For Kubernetes tests all tests can be executed in the same python version - default one - no matter which PYTHON_MAJOR_MINOR is used. This is because we are testing Airflow which is deployed via production image. Thanks to that we can fix the python version to be default and avoid any python version problems (this is especially important for cherry-picking to 1.10 where we have python 2.7 and 3.5. (cherry-picked from commit cbd6daf)
1 parent 0c7c114 commit 31a10de

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ jobs:
620620
- name: "Setup python"
621621
uses: actions/setup-python@v2
622622
with:
623-
python-version: ${{ env.PYTHON_MAJOR_MINOR_VERSION }}
623+
python-version: ${{ needs.build-info.outputs.defaultPythonVersion }}
624624
- name: "Free space"
625625
run: ./scripts/ci/tools/ci_free_space_on_ci.sh
626626
- name: "Prepare PROD Image"
@@ -634,17 +634,19 @@ jobs:
634634
- name: "Cache virtualenv for kubernetes testing"
635635
uses: actions/cache@v2
636636
env:
637-
cache-name: cache-kubernetes-tests-virtualenv-v6-v1-10
637+
cache-name: cache-kubernetes-tests-v7-v1-10
638638
with:
639-
path: .build/.kubernetes_venv
640-
key: "${{ env.cache-name }}-${{ github.job }}-${{ hashFiles('setup.py') }}"
639+
path: ".build/.kubernetes_venv*"
640+
key: "venv-${{ env.cache-name }}-${{ github.job }}-${{ hashFiles('setup.py') }}\
641+
-${{ needs.build-info.outputs.defaultPythonVersion }}"
641642
- name: "Cache bin folder with tools for kubernetes testing"
642643
uses: actions/cache@v2
643644
env:
644-
cache-name: cache-kubernetes-tests-bin-v6-v1-10
645+
cache-name: cache-kubernetes-tests-v7-v1-10
645646
with:
646-
path: .build/bin
647-
key: "${{ env.cache-name }}-${{ github.job }}-${{ hashFiles('setup.py') }}\
647+
path: ".build/bin"
648+
key: "bin-${{ env.cache-name }}-${{ github.job }}-${{ hashFiles('setup.py') }}\
649+
-${{ needs.build-info.outputs.defaultPythonVersion }}\
648650
-${{ needs.build-info.outputs.defaultKindVersion }}\
649651
-${{ needs.build-info.outputs.defaultHelmVersion }}\
650652
-${{ matrix.kubernetes-version }}"

TESTING.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ The virtualenv required will be created automatically when the scripts are run.
623623
624624
4b) You can enter an interactive shell to run tests one-by-one
625625

626-
This prepares and enters the virtualenv in ``.build/.kubernetes_venv`` folder:
626+
This prepares and enters the virtualenv in ``.build/.kubernetes_venv_<YOUR_CURRENT_PYTHON_VERSION>`` folder:
627627

628628
.. code-block:: bash
629629
@@ -666,7 +666,8 @@ a) Add the virtualenv as interpreter for the project:
666666
:align: center
667667
:alt: Kubernetes testing virtualenv
668668

669-
The virtualenv is created in your "Airflow" source directory in ``.build/.kubernetes_venv/`` folder and you
669+
The virtualenv is created in your "Airflow" source directory in the
670+
``.build/.kubernetes_venv_<YOUR_CURRENT_PYTHON_VERSION>`` folder and you
670671
have to find ``python`` binary and choose it when selecting interpreter.
671672

672673
b) Choose pytest as test runner:

scripts/ci/kubernetes/ci_run_kubernetes_tests.sh

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ else
6161
"--durations=100"
6262
"--cov=airflow/"
6363
"--cov-config=.coveragerc"
64-
"--cov-report=html:airflow/www/static/coverage/"
64+
"--cov-report=xml:files/coverage.xml"
6565
"--color=yes"
6666
"--maxfail=50"
6767
"--pythonwarnings=ignore::DeprecationWarning"
@@ -72,29 +72,27 @@ fi
7272

7373
cd "${AIRFLOW_SOURCES}" || exit 1
7474

75-
virtualenv_path="${BUILD_CACHE_DIR}/.kubernetes_venv"
75+
HOST_PYTHON_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info[0]}.{sys.version_info[1]}")')
76+
readonly HOST_PYTHON_VERSION
77+
78+
virtualenv_path="${BUILD_CACHE_DIR}/.kubernetes_venv_${HOST_PYTHON_VERSION}"
7679

7780
if [[ ! -d ${virtualenv_path} ]]; then
7881
echo
7982
echo "Creating virtualenv at ${virtualenv_path}"
8083
echo
81-
python -m venv "${virtualenv_path}"
84+
python3 -m venv "${virtualenv_path}"
8285
fi
8386

84-
# In Python 3.5 activating virtualenv hits undefined variable
85-
set +u
86-
8787
. "${virtualenv_path}/bin/activate"
8888

89-
set -u
90-
91-
pip install --upgrade pip==20.2.3
89+
pip install --upgrade pip==20.2.3 wheel==0.35.1
9290

9391
pip install pytest freezegun pytest-cov \
94-
--constraint "https://raw.githubusercontent.com/apache/airflow/${DEFAULT_CONSTRAINTS_BRANCH}/constraints-${PYTHON_MAJOR_MINOR_VERSION}.txt"
92+
--constraint "https://raw.githubusercontent.com/apache/airflow/${DEFAULT_CONSTRAINTS_BRANCH}/constraints-${HOST_PYTHON_VERSION}.txt"
9593

9694
pip install -e ".[kubernetes]" \
97-
--constraint "https://raw.githubusercontent.com/apache/airflow/${DEFAULT_CONSTRAINTS_BRANCH}/constraints-${PYTHON_MAJOR_MINOR_VERSION}.txt"
95+
--constraint "https://raw.githubusercontent.com/apache/airflow/${DEFAULT_CONSTRAINTS_BRANCH}/constraints-${HOST_PYTHON_VERSION}.txt"
9896

9997
if [[ ${interactive} == "true" ]]; then
10098
echo

0 commit comments

Comments
 (0)