From a2c8826586b4d32a71d5c2bf34d8c1563e87cb2a Mon Sep 17 00:00:00 2001 From: Siarhei Harbuz Date: Mon, 5 Feb 2024 12:52:45 +0200 Subject: [PATCH] full test --- .buildkite/metricbeat/pipeline.yml | 6 +-- .buildkite/scripts/common.sh | 52 +++++-------------- .../scripts/generate_libbeat_pipeline.sh | 8 +-- .../scripts/generate_metricbeat_pipeline.sh | 15 +++--- 4 files changed, 30 insertions(+), 51 deletions(-) diff --git a/.buildkite/metricbeat/pipeline.yml b/.buildkite/metricbeat/pipeline.yml index 0abc58a85ae..99134bf8392 100644 --- a/.buildkite/metricbeat/pipeline.yml +++ b/.buildkite/metricbeat/pipeline.yml @@ -14,10 +14,10 @@ env: steps: - input: "Input Parameters" - key: "input-run-all-stages" + key: "runMetricbeat" fields: - - select: "Metricbeat - runAllStages" - key: "runAllStages" + - select: "Metricbeat - runMetricbeat" + key: "runMetricbeat" options: - label: "True" value: "true" diff --git a/.buildkite/scripts/common.sh b/.buildkite/scripts/common.sh index 7f66a295574..f0d055acbf8 100755 --- a/.buildkite/scripts/common.sh +++ b/.buildkite/scripts/common.sh @@ -181,29 +181,20 @@ are_changed_only_paths() { return 1 } -# are_conditions_met_mandatory_tests() { -# if [[ "${BUILDKITE_PULL_REQUEST}" == "" ]] || [[ "${runAllStages}" == "true" ]] || [[ "${ONLY_DOCS}" == "false" && "${BUILDKITE_PULL_REQUEST}" != "" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L107-L137 -# if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || are_paths_changed "${ci_changeset[@]}" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12 -# if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" ]]; then -# if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat" ]] || [[ "${GITHUB_PR_LABELS}" =~ Metricbeat ]]; then -# return 0 -# elif [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" ]]; then -# if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test libbeat" || "${GITHUB_PR_LABELS}" =~ libbeat || "${runLibbeat}" == "true" ]]; then -# return 0 -# fi -# fi -# fi -# fi -# fi -# return 1 -# } - -# are_conditions_met_extended_tests() { -# if are_conditions_met_mandatory_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171 -# return 0 -# fi -# return 1 -# } +are_conditions_met_mandatory_tests() { + if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || are_paths_changed "${ci_changeset[@]}" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12 + if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" ]]; then + if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat" || "${GITHUB_PR_LABELS}" =~ Metricbeat || "${runMetricbeat}" == "true" ]]; then + return 0 + fi + elif [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-libbeat" ]]; then + if [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test libbeat" || "${GITHUB_PR_LABELS}" =~ libbeat || "${runLibbeat}" == "true" ]]; then + return 0 + fi + fi + fi + return 1 +} are_conditions_met_libbeat_arm_tests() { if are_conditions_met_mandatory_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171 @@ -217,31 +208,16 @@ are_conditions_met_libbeat_arm_tests() { } are_conditions_met_metricbeat_macos_tests() { - # if are_conditions_met_mandatory_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171 - # if [[ "$BUILDKITE_PIPELINE_SLUG" == "beats-metricbeat" ]]; then if [[ "${UI_MACOS_TESTS}" == true ]] || [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat for macos" ]] || [[ "${GITHUB_PR_LABELS}" =~ macOS ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12 return 0 fi - return 1 - # fi - # return 1 -} - -are_conditions_met_metricbeat_extended_windows_tests() { - if [[ "${ONLY_DOCS}" == "false" && "${BUILDKITE_PULL_REQUEST}" != "" ]] || [[ "${runAllStages}" == "true" ]]; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171 - if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || are_paths_changed "${ci_changeset[@]}" || [[ "${GITHUB_PR_TRIGGER_COMMENT}" == "/test metricbeat" ]] || [[ "${GITHUB_PR_LABELS}" =~ Metricbeat ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L3-L12 - return 0 - fi - fi return 1 } are_conditions_met_packaging() { - # if are_conditions_met_metricbeat_extended_windows_tests; then #from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/Jenkinsfile#L145-L171 if are_paths_changed "${metricbeat_changeset[@]}" || are_paths_changed "${oss_changeset[@]}" || [[ "${BUILDKITE_TAG}" == "" ]] || [[ "${BUILDKITE_PULL_REQUEST}" != "" ]]; then # from https://github.com/elastic/beats/blob/c5e79a25d05d5bdfa9da4d187fe89523faa42afc/metricbeat/Jenkinsfile.yml#L101-L103 return 0 fi - # fi return 1 } diff --git a/.buildkite/scripts/generate_libbeat_pipeline.sh b/.buildkite/scripts/generate_libbeat_pipeline.sh index 127e602a07b..e5e6baefaca 100755 --- a/.buildkite/scripts/generate_libbeat_pipeline.sh +++ b/.buildkite/scripts/generate_libbeat_pipeline.sh @@ -6,8 +6,9 @@ set -euo pipefail pipelineName="pipeline.libbeat-dynamic.yml" -echo "Adding the mandatory tests into the pipeline" -cat > $pipelineName <<- YAML +echo "Add the mandatory and extended tests without additional conditions into the pipeline" +if are_conditions_met_mandatory_tests; then + cat > $pipelineName <<- YAML steps: @@ -60,8 +61,9 @@ steps: artifact_paths: "${BEATS_PROJECT_NAME}/libbeat-stress-test.xml" YAML +fi -echo "Adding the additional tests into the pipeline" +echo "Check and add the Extended Tests into the pipeline" if are_conditions_met_libbeat_arm_tests; then cat >> $pipelineName <<- YAML diff --git a/.buildkite/scripts/generate_metricbeat_pipeline.sh b/.buildkite/scripts/generate_metricbeat_pipeline.sh index 4a09c546e11..9c2767edea6 100755 --- a/.buildkite/scripts/generate_metricbeat_pipeline.sh +++ b/.buildkite/scripts/generate_metricbeat_pipeline.sh @@ -6,8 +6,9 @@ set -euo pipefail pipelineName="pipeline.metricbeat-dynamic.yml" -echo "Adding the mandatory tests into the pipeline" -cat > $pipelineName <<- YAML +echo "Add the mandatory and extended tests without additional conditions into the pipeline" +if are_conditions_met_mandatory_tests; then + cat > $pipelineName <<- YAML steps: @@ -66,11 +67,8 @@ steps: - "${IMAGE_WIN_2022}" artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*" -YAML - -echo "Adding the extended windows tests into the pipeline" -#TODO: ADD conditions from the main pipeline -cat >> $pipelineName <<- YAML +# echo "Add the extended windows tests into the pipeline" +# TODO: ADD conditions from the main pipeline - group: "Extended Windowds Tests" key: "extended-win-tests" @@ -109,7 +107,9 @@ cat >> $pipelineName <<- YAML disk_type: "pd-ssd" artifact_paths: "${BEATS_PROJECT_NAME}/build/*.*" YAML +fi +echo "Check and add the Extended Tests into the pipeline" if are_conditions_met_metricbeat_macos_tests; then cat >> $pipelineName <<- YAML @@ -127,6 +127,7 @@ YAML fi +echo "Check and add the Packaging into the pipeline" if are_conditions_met_packaging; then cat >> $pipelineName <<- YAML