-
Notifications
You must be signed in to change notification settings - Fork 129
[CI] Refactor script to run integration tests #2768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d8219a0
abe2903
dd84b2e
f13dc34
d214271
f6cfbb5
9aa9efb
3a8ae6d
c1eed72
c4dd938
34d59cc
0c32d2a
a3af19f
2fc8ba6
d39eb61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,10 +13,11 @@ usage() { | |
| echo -e "\t-h: Show this message" | ||
| } | ||
|
|
||
| export UPLOAD_SAFE_LOGS=${UPLOAD_SAFE_LOGS:-"0"} | ||
|
|
||
| PARALLEL_TARGET="test-check-packages-parallel" | ||
| FALSE_POSITIVES_TARGET="test-check-packages-false-positives" | ||
| KIND_TARGET="test-check-packages-with-kind" | ||
| LOGSTASH_TARGET="test-check-packages-with-logstash" | ||
| SYSTEM_TEST_FLAGS_TARGET="test-system-test-flags" | ||
| TEST_BUILD_ZIP_TARGET="test-build-zip" | ||
| TEST_BUILD_INSTALL_ZIP_TARGET="test-build-install-zip" | ||
|
|
@@ -61,24 +62,71 @@ if [[ "${TARGET}" == "" ]]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "${SERVERLESS}" == "true" && "${TARGET}" != "${PARALLEL_TARGET}" ]]; then | ||
| # Just tested parallel target to run with Serverless projects, other Makefile targets | ||
| # have not been tested yet and could fail unexpectedly. For instance, "test-check-package-false-positives" | ||
| # target would require a different management to not stop Elastic stack after each package test. | ||
| echo "Target ${TARGET} is not supported for Serverless testing" | ||
| usage | ||
| exit 1 | ||
| fi | ||
| upload_package_test_logs() { | ||
| local retry_count=0 | ||
| local package_folder="" | ||
| local target="" | ||
|
|
||
| if [[ "${PACKAGE}" == "" ]]; then | ||
| echo "No package specified, skipping upload of safe logs" | ||
| return | ||
| fi | ||
|
|
||
| echo "--- Uploading safe logs to GCP bucket ${JOB_GCS_BUCKET_INTERNAL}" | ||
|
|
||
| retry_count=${BUILDKITE_RETRY_COUNT:-"0"} | ||
| # Add target as part of the package folder name to allow to distinguish | ||
| # different test runs for the same package in different Makefile targets. | ||
| # Currently, just for test-check-packages-* targets, but could be extended | ||
| # to other targets in the future. | ||
| target=${TARGET#"test-check-packages-"} | ||
| package_folder="${target}.${PACKAGE}" | ||
|
Comment on lines
+82
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added as part of the package folder the target that it is running. If it is required to add That makes me think that if we create two packages with the same folder name in the the folders as:
Logs from both executions would be uploaded to the same folder: Adding the target this would become:
Not added the full target name ( |
||
|
|
||
| if [[ "${ELASTIC_PACKAGE_TEST_ENABLE_INDEPENDENT_AGENT:-""}" == "false" ]]; then | ||
| package_folder="${package_folder}-stack_agent" | ||
| fi | ||
|
|
||
| if [[ "${ELASTIC_PACKAGE_FIELD_VALIDATION_TEST_METHOD:-""}" != "" ]]; then | ||
| package_folder="${package_folder}-${ELASTIC_PACKAGE_FIELD_VALIDATION_TEST_METHOD}" | ||
| fi | ||
|
|
||
| if [[ "${retry_count}" -ne 0 ]]; then | ||
| package_folder="${package_folder}_retry_${retry_count}" | ||
| fi | ||
|
|
||
| upload_safe_logs \ | ||
| "${JOB_GCS_BUCKET_INTERNAL}" \ | ||
| "build/elastic-stack-dump/check-${PACKAGE}/logs/elastic-agent-internal/*.*" \ | ||
| "insecure-logs/${package_folder}/elastic-agent-logs/" | ||
|
|
||
| # required for <8.6.0 | ||
| upload_safe_logs \ | ||
| "${JOB_GCS_BUCKET_INTERNAL}" \ | ||
| "build/elastic-stack-dump/check-${PACKAGE}/logs/elastic-agent-internal/default/*" \ | ||
| "insecure-logs/${package_folder}/elastic-agent-logs/default/" | ||
|
|
||
| upload_safe_logs \ | ||
| "${JOB_GCS_BUCKET_INTERNAL}" \ | ||
| "build/container-logs/*.log" \ | ||
| "insecure-logs/${package_folder}/container-logs/" | ||
| } | ||
|
|
||
| add_bin_path | ||
| install_required_tools() { | ||
| local target="${1}" | ||
|
|
||
| if [[ "${SERVERLESS}" == "true" ]]; then | ||
| # If packages are tested with Serverless, these action are already performed | ||
| # here: .buildkite/scripts/test_packages_with_serverless.sh | ||
| echo "Skipping installation of required tools for Serverless testing" | ||
| return | ||
| fi | ||
|
|
||
| add_bin_path | ||
|
|
||
| if [[ "$SERVERLESS" == "false" ]]; then | ||
| # If packages are tested with Serverless, these actions are already performed | ||
| # here: .buildkite/scripts/test_packages_with_serverless.sh | ||
| echo "--- Install go" | ||
| with_go | ||
|
|
||
| if [[ "${TARGET}" != "${TEST_BUILD_ZIP_TARGET}" ]]; then | ||
| if [[ "${target}" != "${TEST_BUILD_ZIP_TARGET}" ]]; then | ||
| # Not supported in Macos ARM | ||
| echo "--- Install docker" | ||
| with_docker | ||
|
|
@@ -87,87 +135,55 @@ if [[ "$SERVERLESS" == "false" ]]; then | |
| with_docker_compose_plugin | ||
| fi | ||
|
|
||
| case "${target}" in | ||
| "${KIND_TARGET}" | "${SYSTEM_TEST_FLAGS_TARGET}") | ||
| echo "--- Install kind" | ||
| with_kubernetes | ||
| ;; | ||
| "${FALSE_POSITIVES_TARGET}" | "${TEST_BUILD_INSTALL_ZIP_TARGET}") | ||
| echo "--- Install yq" | ||
| with_yq | ||
| ;; | ||
| esac | ||
|
|
||
| # In Serverless pipeline, elastic-package is installed in advance here: | ||
| # .buildkite/scripts/test_packages_with_serverless.sh | ||
| # No need to install it again for every package. | ||
| echo "--- Install elastic-package" | ||
| make install | ||
| fi | ||
| } | ||
|
|
||
| if [[ "${TARGET}" == "${KIND_TARGET}" || "${TARGET}" == "${SYSTEM_TEST_FLAGS_TARGET}" ]]; then | ||
| echo "--- Install kubectl & kind" | ||
| with_kubernetes | ||
| if [[ "${SERVERLESS}" == "true" && "${TARGET}" != "${PARALLEL_TARGET}" ]]; then | ||
| # Just tested parallel target to run with Serverless projects, other Makefile targets | ||
| # have not been tested yet and could fail unexpectedly. For instance, "test-check-packages-false-positives" | ||
| # target would require a different management to not stop Elastic stack after each package test. | ||
| echo "Target ${TARGET} is not supported for Serverless testing" | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "${TARGET}" == "${TEST_BUILD_INSTALL_ZIP_TARGET}" || "${TARGET}" == "${FALSE_POSITIVES_TARGET}" ]]; then | ||
| echo "--- Install yq" | ||
| with_yq | ||
| fi | ||
| install_required_tools "${TARGET}" | ||
|
|
||
| label="${TARGET}" | ||
| if [ -n "${PACKAGE}" ]; then | ||
| label="${label} - ${PACKAGE}" | ||
| fi | ||
|
|
||
| echo "--- Run integration test ${label}" | ||
| test_each_package=false | ||
| case "${TARGET}" in | ||
| "${PARALLEL_TARGET}" | "${FALSE_POSITIVES_TARGET}" | "${LOGSTASH_TARGET}") | ||
| test_each_package=true | ||
| ;; | ||
| esac | ||
| if [[ "${test_each_package}" == "true" ]]; then | ||
|
Comment on lines
-113
to
-119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simplified this code to call directly make target with the corresponding variables. |
||
| make install | ||
| # allow to fail this command, to be able to upload safe logs | ||
| set +e | ||
| make SERVERLESS="${SERVERLESS}" PACKAGE_UNDER_TEST="${PACKAGE}" "${TARGET}" | ||
| testReturnCode=$? | ||
| set -e | ||
|
|
||
|
|
||
| if [[ "${UPLOAD_SAFE_LOGS}" -eq 1 ]] ; then | ||
| retry_count=${BUILDKITE_RETRY_COUNT:-"0"} | ||
| package_folder="${PACKAGE}" | ||
|
|
||
| if [[ "${ELASTIC_PACKAGE_TEST_ENABLE_INDEPENDENT_AGENT:-""}" == "false" ]]; then | ||
| package_folder="${package_folder}-stack_agent" | ||
| fi | ||
|
|
||
| if [[ "${ELASTIC_PACKAGE_FIELD_VALIDATION_TEST_METHOD:-""}" != "" ]]; then | ||
| package_folder="${package_folder}-${ELASTIC_PACKAGE_FIELD_VALIDATION_TEST_METHOD}" | ||
| fi | ||
|
|
||
| if [[ "${retry_count}" -ne 0 ]]; then | ||
| package_folder="${package_folder}_retry_${retry_count}" | ||
| fi | ||
|
|
||
| echo "--- Uploading safe logs to GCP bucket ${JOB_GCS_BUCKET_INTERNAL}" | ||
|
|
||
| upload_safe_logs \ | ||
| "${JOB_GCS_BUCKET_INTERNAL}" \ | ||
| "build/elastic-stack-dump/check-${PACKAGE}/logs/elastic-agent-internal/*.*" \ | ||
| "insecure-logs/${package_folder}/elastic-agent-logs/" | ||
|
|
||
| # required for <8.6.0 | ||
| upload_safe_logs \ | ||
| "${JOB_GCS_BUCKET_INTERNAL}" \ | ||
| "build/elastic-stack-dump/check-${PACKAGE}/logs/elastic-agent-internal/default/*" \ | ||
| "insecure-logs/${package_folder}/elastic-agent-logs/default/" | ||
|
|
||
| upload_safe_logs \ | ||
| "${JOB_GCS_BUCKET_INTERNAL}" \ | ||
| "build/container-logs/*.log" \ | ||
| "insecure-logs/${package_folder}/container-logs/" | ||
| fi | ||
| # allow to fail this command, to be able to upload safe logs | ||
| set +e | ||
| make SERVERLESS="${SERVERLESS}" PACKAGE_UNDER_TEST="${PACKAGE}" "${TARGET}" | ||
| testReturnCode=$? | ||
| set -e | ||
|
|
||
| if [[ "${UPLOAD_SAFE_LOGS}" -eq 1 ]] ; then | ||
| upload_package_test_logs | ||
| fi | ||
|
|
||
| if [ $testReturnCode != 0 ]; then | ||
| echo "make SERVERLESS=${SERVERLESS} PACKAGE_UNDER_TEST=${PACKAGE} ${TARGET} failed with ${testReturnCode}" | ||
| exit ${testReturnCode} | ||
| fi | ||
| else | ||
| make "${TARGET}" | ||
| if [ $testReturnCode != 0 ]; then | ||
| echo "make SERVERLESS=${SERVERLESS} PACKAGE_UNDER_TEST=${PACKAGE} ${TARGET} failed with ${testReturnCode}" | ||
| exit ${testReturnCode} | ||
| fi | ||
|
|
||
| echo "--- Check git clean" | ||
| make check-git-clean | ||
| exit 0 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, logs are not uploaded to the private bucket.