Skip to content

Add more collapsed sections in CI output #2639

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 52 additions & 39 deletions .buildkite/scripts/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,44 @@ while getopts ":t:p:sh" o; do
esac
done


upload_package_test_logs() {
local retry_count=0
local package_folder=""

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

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/"

}

if [[ "${TARGET}" == "" ]]; then
echo "Missing target"
usage
Expand All @@ -63,15 +101,15 @@ add_bin_path
if [[ "$SERVERLESS" == "false" ]]; then
# If packages are tested with Serverless, these action are already performed
# here: .buildkite/scripts/test_packages_with_serverless.sh
echo "--- install go"
echo "--- Install go"
with_go

if [[ "${TARGET}" != "${TEST_BUILD_ZIP_TARGET}" ]]; then
# Not supported in Macos ARM
echo "--- install docker"
echo "--- Install docker"
with_docker

echo "--- install docker-compose plugin"
echo "--- Install docker-compose plugin"
with_docker_compose_plugin
fi
fi
Expand All @@ -80,64 +118,39 @@ echo "--- install yq"
with_yq

if [[ "${TARGET}" == "${KIND_TARGET}" || "${TARGET}" == "${SYSTEM_TEST_FLAGS_TARGET}" ]]; then
echo "--- install kubectl & kind"
echo "--- Install kubectl & kind"
with_kubernetes
fi

label="${TARGET}"
if [ -n "${PACKAGE}" ]; then
label="${label} - ${PACKAGE}"
fi

echo "--- Install elastic-package"
make install

echo "--- Run integration test ${label}"
if [[ "${TARGET}" == "${PARALLEL_TARGET}" ]] || [[ "${TARGET}" == "${FALSE_POSITIVES_TARGET}" ]]; then
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

retry_count=${BUILDKITE_RETRY_COUNT:-"0"}

if [[ "${UPLOAD_SAFE_LOGS}" -eq 1 ]] ; then
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

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/"
upload_package_test_logs
fi

if [ $testReturnCode != 0 ]; then
echo "make SERVERLESS=${SERVERLESS} PACKAGE_UNDER_TEST=${PACKAGE} ${TARGET} failed with ${testReturnCode}"
exit ${testReturnCode}
fi

make check-git-clean
exit 0
else
make "${TARGET}"
fi

make install "${TARGET}" check-git-clean
echo "--- Check git clean"
make check-git-clean
exit 0
4 changes: 2 additions & 2 deletions .buildkite/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ VERSION=""
add_bin_path
with_go

echo "--- fetching tags"
echo "--- Fetching tags"
# Ensure that tags are present so goreleaser can build the changelog from the last release.
git rev-parse --is-shallow-repository
git fetch origin --tags

echo "--- running goreleaser"
echo "--- Running goreleaser"
# Run latest version of goreleaser
curl -sL https://git.io/goreleaser | bash
10 changes: 5 additions & 5 deletions .buildkite/scripts/test-with-integrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ set -euo pipefail

add_bin_path

echo "--- install gh cli"
echo "--- Install gh cli"
with_github_cli

echo "--- install jq"
echo "--- Install jq"
with_jq


Expand Down Expand Up @@ -73,7 +73,7 @@ create_integrations_pull_request() {

update_dependency() {
# it needs to set the Golang version from the integrations repository (.go-version file)
echo "--- install go for integrations repository :go:"
echo "--- Install go for integrations repository :go:"
with_go

echo "--- Updating go.mod and go.sum with ${GITHUB_PR_HEAD_SHA} :hammer_and_wrench:"
Expand Down Expand Up @@ -154,7 +154,7 @@ create_or_update_pull_request() {

rm -rf "${temp_path}"

echo "--- adding comment into ${GITHUB_PR_BASE_REPO} pull request :memo:"
echo "--- Adding comment into ${GITHUB_PR_BASE_REPO} pull request :memo:"
add_pr_comment "${BUILDKITE_PULL_REQUEST}" "$(get_integrations_pr_link "${integrations_pr_number}")"
}

Expand All @@ -170,5 +170,5 @@ add_pr_comment() {
}


echo "--- creating or updating integrations pull request"
echo "--- Creating or updating integrations pull request"
create_or_update_pull_request
4 changes: 2 additions & 2 deletions .buildkite/scripts/test_packages_with_serverless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fi

add_bin_path

echo "--- install go"
echo "--- Install go"
with_go

echo "--- Install docker"
Expand All @@ -42,7 +42,7 @@ echo "--- Install docker-compose"
with_docker_compose_plugin

if [[ "${BUILDKITE_PULL_REQUEST}" != "false" ]]; then
echo "--- install gh cli"
echo "--- Install gh cli"
with_github_cli

add_pr_comment "${BUILDKITE_PULL_REQUEST}" "${BUILDKITE_BUILD_URL}"
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/unit_tests_macos_arm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -euo pipefail

add_bin_path

echo "--- install go"
echo "--- Install go"
with_go

echo "--- Running unit tests"
Expand Down
9 changes: 7 additions & 2 deletions scripts/test-build-install-zip-file.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#!/bin/bash

set -euxo pipefail
set -euo pipefail

cleanup() {
local r=$?
if [ "${r}" -ne 0 ]; then
# Ensure that the group where the failure happened is opened.
echo "^^^ +++"
fi
echo "~~~ elastic-package cleanup"

local output_path="build/elastic-stack-dump/install-zip"
if [ ${USE_SHELLINIT} -eq 1 ]; then
output_path="${output_path}-shellinit"
fi

# Dump stack logs
elastic-package stack dump -v --output ${output_path}
elastic-package stack dump -v --output ${output_path} || true

# Take down the stack
elastic-package stack down -v
Expand Down
18 changes: 13 additions & 5 deletions scripts/test-build-install-zip.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/bin/bash

set -euxo pipefail
set -euo pipefail

cleanup() {
r=$?
local r=$?
if [ "${r}" -ne 0 ]; then
# Ensure that the group where the failure happened is opened.
echo "^^^ +++"
fi
echo "~~~ elastic-package cleanup"

# Dump stack logs
elastic-package stack dump -v --output build/elastic-stack-dump/build-zip
elastic-package stack dump -v --output build/elastic-stack-dump/build-zip || true

# Take down the stack
elastic-package stack down -v
Expand Down Expand Up @@ -37,15 +42,17 @@ go run ./scripts/gpgkey

for d in test/packages/*/*/; do
# Packages in false_positives can have issues.
if [ "$(testype $d)" == "false_positives" ]; then
if [ "$(testype "$d")" == "false_positives" ]; then
continue
fi
echo "--- Building package: ${d}"
elastic-package build -C "$d" --zip --sign -v
done

# Remove unzipped built packages, leave .zip files
rm -r build/packages/*/

echo "--- Prepare Elastic stack"
# Boot up the stack
elastic-package stack up -d -v

Expand All @@ -54,12 +61,13 @@ eval "$(elastic-package stack shellinit)"
# Install packages from working copy
for d in test/packages/*/*/; do
# Packages in false_positives can have issues.
if [ "$(testype $d)" == "false_positives" ]; then
if [ "$(testype "$d")" == "false_positives" ]; then
continue
fi
package_name=$(yq -r '.name' "${d}/manifest.yml")
package_version=$(yq -r '.version' "${d}/manifest.yml")

echo "--- Installing package: ${package_name} (${package_version})"
elastic-package install -C "$d" -v

# check that the package is installed
Expand Down
13 changes: 9 additions & 4 deletions scripts/test-build-zip.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash

set -euxo pipefail
set -euo pipefail

cleanup() {
r=$?
local r=$?
if [ "${r}" -ne 0 ]; then
# Ensure that the group where the failure happened is opened.
echo "^^^ +++"
fi
echo "~~~ elastic-package cleanup"

# Clean used resources
for d in test/packages/*/*/; do
Expand Down Expand Up @@ -31,9 +35,10 @@ go run ./scripts/gpgkey

for d in test/packages/*/*/; do
# Packages in false_positives can have issues.
if [ "$(testype $d)" == "false_positives" ]; then
if [ "$(testype "$d")" == "false_positives" ]; then
continue
fi
echo "--- Building zip package: ${d}"
elastic-package build -C "$d" --zip --sign -v
done

Expand Down
10 changes: 9 additions & 1 deletion scripts/test-check-false-positives.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ set -euxo pipefail

function cleanup() {
r=$?
if [ "${r}" -ne 0 ]; then
# Ensure that the group where the failure happened is opened.
echo "^^^ +++"
fi
echo "~~~ elastic-package cleanup"

# Dump stack logs
elastic-package stack dump -v --output "build/elastic-stack-dump/check-${PACKAGE_UNDER_TEST:-${PACKAGE_TEST_TYPE:-*}}"
elastic-package stack dump -v --output "build/elastic-stack-dump/check-${PACKAGE_UNDER_TEST:-${PACKAGE_TEST_TYPE:-*}}" || true

# Take down the stack
elastic-package stack down -v
Expand Down Expand Up @@ -94,6 +99,7 @@ export ELASTIC_PACKAGE_LINKS_FILE_PATH

stack_args=$(stack_version_args) # --version <version>

echo "--- Prepare Elastic stack"
# Update the stack
elastic-package stack update -v ${stack_args}

Expand All @@ -108,6 +114,8 @@ elastic-package stack status

# Run package tests
for d in test/packages/${PACKAGE_TEST_TYPE:-false_positives}/${PACKAGE_UNDER_TEST:-*}/; do
echo "--- Check build output: ${d}"
check_build_output "$d"
echo "--- Check expected errors: ${d}"
check_expected_errors "$d"
done
Loading