Skip to content

Commit

Permalink
Execute composition tests in parallel jobs
Browse files Browse the repository at this point in the history
Previously one job with multiple parallel steps (one per distro) was used.
With this behaviour only one executor was consumed for all these
distro-specific tests. Distribution between different build nodes wasn't
done, it was always on the first selected node.
This change uses existing composition test jobs to change the behaviour
which allows to distribute the now started jobs between build nodes.
Each started job will consume one executor.
The parallel execution is kept.

References CMK-20104

Change-Id: Iee625e7762bed5d7da0b0c0300694191fc6eb548
  • Loading branch information
okin committed Dec 2, 2024
1 parent cb00f63 commit 77b8534
Showing 1 changed file with 60 additions and 17 deletions.
77 changes: 60 additions & 17 deletions buildscripts/scripts/test-composition.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/// Other artifacts: ???
/// Depends on: ???

import org.jenkinsci.plugins.pipeline.modeldefinition.Utils

def main() {
check_job_parameters([
"EDITION",
Expand All @@ -24,7 +26,8 @@ def main() {
// TODO: we should always use USE_CASE directly from the job parameters
def use_case = (USE_CASE == "fips") ? USE_CASE : "daily_tests"
test_jenkins_helper.assert_fips_testing(use_case, NODE_LABELS);
def distros = versioning.get_distros(edition: EDITION, use_case: use_case, override: OVERRIDE_DISTROS);
def all_distros = versioning.get_distros(override: "all");
def distros_under_test = versioning.get_distros(edition: EDITION, use_case: use_case, override: OVERRIDE_DISTROS);

def safe_branch_name = versioning.safe_branch_name(scm);
def branch_version = versioning.get_branch_version(checkout_dir);
Expand All @@ -43,13 +46,13 @@ def main() {
|Run composition tests for<br>
|VERSION: ${VERSION}<br>
|EDITION: ${EDITION}<br>
|distros: ${distros}<br>
|distros: ${distros_under_test}<br>
""".stripMargin());

print(
"""
|===== CONFIGURATION ===============================
|distros:...................│${distros}
|distros:...................│${distros_under_test}
|branch_name:.............. │${branch_name}
|safe_branch_name:......... │${safe_branch_name}
|cmk_version:.............. │${cmk_version}
Expand All @@ -60,22 +63,62 @@ def main() {
|===================================================
""".stripMargin());

// TODO: don't run make test-composition-docker but use docker.inside() instead
stage('test cmk-docker integration') {
docker.withRegistry(DOCKER_REGISTRY, "nexus") {
testing_helper.run_make_targets(
DOCKER_GROUP_ID: get_docker_group_id(),
DISTRO_LIST: distros,
EDITION: EDITION,
VERSION: VERSION,
DOCKER_TAG: docker_tag,
MAKE_TARGET: "test-composition-docker",
BRANCH: branch_name,
cmk_version: cmk_version_rc_aware,
OTEL_EXPORTER_OTLP_ENDPOINT: env.OTEL_EXPORTER_OTLP_ENDPOINT,
);
def build_for_parallel = [:];
def parallel_stages_states = [];
def base_folder = "${currentBuild.fullProjectName.split('/')[0..-3].join('/')}";
def relative_job_name = "${base_folder}/builders/test-composition-single-f12less";

all_distros.each { item ->
def distro = item;
def stepName = "Composition test for ${distro}";

build_for_parallel[stepName] = { ->
def run_condition = distro in distros_under_test;
println("Should ${distro} be tested? ${run_condition}");

/// this makes sure the whole parallel thread is marked as skipped
if (! run_condition){
Utils.markStageSkippedForConditional(stepName);
}

smart_stage(
name: stepName,
condition: run_condition,
raiseOnError: false,
) {
def this_exit_successfully = false;
def job = build(
job: relative_job_name,
propagate: false, // do not raise here, continue, get status via result property later
parameters: [
string(name: "DISTRO", value: distro),
string(name: "EDITION", value: EDITION),
string(name: "VERSION", value: VERSION),
string(name: "DOCKER_TAG", value: docker_tag),
string(name: "CUSTOM_GIT_REF", value: CUSTOM_GIT_REF),
string(name: "CIPARAM_OVERRIDE_BUILD_NODE", value: CIPARAM_OVERRIDE_BUILD_NODE),
string(name: "CIPARAM_CLEANUP_WORKSPACE", value: CIPARAM_CLEANUP_WORKSPACE),
],
);
println("job result is: ${job.result}");
// be really really sure if it is a success
if (job.result == "SUCCESS") {
this_exit_successfully = true;
} else {
error("${distro.NAME} failed");
}
parallel_stages_states.add(this_exit_successfully);
}
}
}

stage('Run composition tests') {
parallel build_for_parallel;
}

println("All stages results: ${parallel_stages_states}");
all_true = parallel_stages_states.every { it == true } == true;
currentBuild.result = all_true ? "SUCCESS" : "FAILED";
}

return this;

0 comments on commit 77b8534

Please sign in to comment.