potiuk commented on a change in pull request #15939: URL: https://github.com/apache/airflow/pull/15939#discussion_r636683793
########## File path: scripts/ci/kubernetes/ci_upgrade_cluster_with_different_executors_in_parallel.sh ########## @@ -0,0 +1,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 + +# We cannot perform full initialization because it will be done later in the "single run" scripts +# And some readonly variables are set there, therefore we only selectively reuse parallel lib needed +LIBRARIES_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/../libraries/" && pwd) +# shellcheck source=scripts/ci/libraries/_all_libs.sh +source "${LIBRARIES_DIR}/_all_libs.sh" +export SEMAPHORE_NAME="helm-chart-upgrade-test" + +function get_maximum_parallel_k8s_jobs() { + docker_engine_resources::get_available_cpus_in_docker + if [[ -n ${RUNS_ON=} && ${RUNS_ON} != *"self-hosted"* ]]; then + echo + echo "${COLOR_YELLOW}This is a Github Public runner - for now we are forcing max parallel K8S tests jobs to 1 for those${COLOR_RESET}" + echo + export MAX_PARALLEL_K8S_JOBS="1" + else + if [[ ${MAX_PARALLEL_K8S_JOBS=} != "" ]]; then + echo + echo "${COLOR_YELLOW}Maximum parallel k8s jobs forced vi MAX_PARALLEL_K8S_JOBS = ${MAX_PARALLEL_K8S_JOBS}${COLOR_RESET}" + echo + else + MAX_PARALLEL_K8S_JOBS=${CPUS_AVAILABLE_FOR_DOCKER} + echo + echo "${COLOR_YELLOW}Maximum parallel k8s jobs set to number of CPUs available for Docker = ${MAX_PARALLEL_K8S_JOBS}${COLOR_RESET}" + echo + fi + fi + export MAX_PARALLEL_K8S_JOBS +} + +# Launches parallel building of images. Redirects output to log set the right directories +# $1 - test_specification +# $2 - bash file to execute in parallel +function run_helm_upgrade_test() { + local kubernetes_version=$1 + local python_version=$2 + local job="Helm-Cluster-${kubernetes_version}-python-${python_version}" + + mkdir -p "${PARALLEL_MONITORED_DIR}/${SEMAPHORE_NAME}/${job}" + export JOB_LOG="${PARALLEL_MONITORED_DIR}/${SEMAPHORE_NAME}/${job}/stdout" + export PARALLEL_JOB_STATUS="${PARALLEL_MONITORED_DIR}/${SEMAPHORE_NAME}/${job}/status" + 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}" \ + "$(dirname "${BASH_SOURCE[0]}")/ci_upgrade_cluster_with_different_executors_single_job.sh" \ + "${kubernetes_version}" "${python_version}" >"${JOB_LOG}" 2>&1 +} + +function run_helm_tests_in_parallel() { Review comment: Similarly here. I think we can move it to "_kind.sh" with kind:: prefix and make it "reused". We could pass the name of the script to run as parameter and use it from there. Happy to help if needed (though I am a bit less available today) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
