Skip to content

Commit 5539069

Browse files
authored
Running tests in parallel (#14531)
This is by far the biggest improvements of the test execution time we can get now when we are using self-hosted runners. This change drives down the time of executing all tests on self-hosted runners from ~ 50 minutes to ~ 13 minutes due to heavy parallelisation we can implement for different test types and the fact that our machines for self-hosted runners are far more capable - they have more CPU, more memory and the fact that we are using tmpfs for everything. This change will also drive the cost of our self-hosted runners down. Since we have auto-scaling infrastructure we will simply need the machines to run tests for far shorter time. Since the number of test jobs we run on those self hosted runners is substantial (10 jobs), we are going to save ~ 6 build hours per one PR/merged commit! This also allows the developers to use the power of their development machines - when you use `./scripts/ci/testing/ci_run_airflow_testing.sh` the script detects how many CPU cores are available and it will run as many parallel test types as many cores you have. Also in case of Integration tests - they require more memory to run all the integrations, so in case there is less than ~ 32 GB of RAM available to Docker, the integration tests are run sequentially at the end. This drives stability up for machines with lower memory. On one personal PC (64GB RAM, 8 CPUS/16 cores, fast SSD) the full test suite execution went down from 30 minutes to 5 minutes. There is a continuous progress information printed every 10 seconds when either parallel or sequential tests are run, and the full output is shown at the end - failed tests are marked in red groups, and succesful are marked in green groups. This makes it easier to see and analyse errors.
1 parent 68e4c4d commit 5539069

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

‎scripts/ci/images/ci_wait_for_ci_image.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
push_pull_remove_images::check_if_github_registry_wait_for_image_enabled
2222

23-
build_image::configure_github_docker_registry
23+
build_image::configure_docker_registry
2424

2525
export AIRFLOW_CI_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-ci"
2626

‎scripts/ci/images/ci_wait_for_prod_image.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
push_pull_remove_images::check_if_github_registry_wait_for_image_enabled
2222

23-
build_image::configure_github_docker_registry
23+
build_image::configure_docker_registry
2424

2525
export AIRFLOW_PROD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}"
2626
start_end::group_start "Waiting for ${AIRFLOW_PROD_IMAGE_NAME} image to appear"

‎scripts/ci/libraries/_build_images.sh‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,9 @@ function build_images::get_docker_image_names() {
460460
# either GITHUB_TOKEN or CONTAINER_REGISTRY_TOKEN depending on the registry.
461461
# In case Personal Access token is not set, skip logging in
462462
# Also enable experimental features of docker (we need `docker manifest` command)
463-
function build_image::configure_github_docker_registry() {
463+
function build_image::configure_docker_registry() {
464464
if [[ ${USE_GITHUB_REGISTRY} == "true" ]]; then
465-
start_end::group_start "Determine GitHub Registry token used and login if needed"
465+
start_end::group_start "Determine GitHub Registry token"
466466
local token=""
467467
if [[ "${GITHUB_REGISTRY}" == "ghcr.io" ]]; then
468468
# For now ghcr.io can only authenticate using Personal Access Token with package access scope.
@@ -482,6 +482,8 @@ function build_image::configure_github_docker_registry() {
482482
echo
483483
exit 1
484484
fi
485+
start_end::group_end
486+
start_end::group_start "Logging in to GitHub Registry"
485487
if [[ -z "${token}" ]] ; then
486488
verbosity::print_info
487489
verbosity::print_info "Skip logging in to GitHub Registry. No Token available!"
@@ -495,13 +497,14 @@ function build_image::configure_github_docker_registry() {
495497
else
496498
verbosity::print_info "Skip Login to GitHub Registry ${GITHUB_REGISTRY} as token is missing"
497499
fi
498-
verbosity::print_info "Make sure experimental docker features are enabled"
500+
start_end::group_end
501+
502+
start_end::group_start "Make sure experimental docker features are enabled"
499503
local new_config
500504
new_config=$(jq '.experimental = "enabled"' "${HOME}/.docker/config.json")
501505
echo "${new_config}" > "${HOME}/.docker/config.json"
502-
verbosity::print_info "Docker config after change:"
503-
verbosity::print_info "${new_config}"
504506
start_end::group_end
507+
505508
fi
506509
}
507510

@@ -521,7 +524,7 @@ function build_images::prepare_ci_build() {
521524
export AIRFLOW_IMAGE="${AIRFLOW_CI_IMAGE}"
522525
readonly AIRFLOW_IMAGE
523526

524-
build_image::configure_github_docker_registry
527+
build_image::configure_docker_registry
525528
sanity_checks::go_to_airflow_sources
526529
permissions::fix_group_permissions
527530
}
@@ -844,7 +847,7 @@ function build_images::prepare_prod_build() {
844847
export AIRFLOW_IMAGE="${AIRFLOW_PROD_IMAGE}"
845848
readonly AIRFLOW_IMAGE
846849

847-
build_image::configure_github_docker_registry
850+
build_image::configure_docker_registry
848851
AIRFLOW_BRANCH_FOR_PYPI_PRELOADING="${BRANCH_NAME}"
849852
sanity_checks::go_to_airflow_sources
850853
}

0 commit comments

Comments
 (0)