diff --git a/.buildkite/pipeline.trigger.integration.tests.sh b/.buildkite/pipeline.trigger.integration.tests.sh index 3addbe9cd..654115367 100755 --- a/.buildkite/pipeline.trigger.integration.tests.sh +++ b/.buildkite/pipeline.trigger.integration.tests.sh @@ -128,36 +128,36 @@ done done popd > /dev/null -echo " - label: \":go: Integration test: build-zip\"" +# TODO: Missing docker & docker-compose in MACOS ARM agent image, skip installation of packages in the meantime. +# If docker and docker-compose are available for this platform/architecture, it could be added a step to test the stack commands (or even replace this one). +echo " - label: \":macos: :go: Integration test: build-zip\"" echo " command: ./.buildkite/scripts/integration_tests.sh -t test-build-zip" echo " agents:" -echo " provider: \"gcp\"" -echo " image: \"${UBUNTU_X86_64_AGENT_IMAGE}\"" +echo " provider: \"orka\"" +echo " imagePrefix: \"${MACOS_ARM_AGENT_IMAGE}\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/build-zip/logs/*.log" echo " - build/packages/*.sig" -# TODO: Missing docker & docker-compose in MACOS ARM agent image, skip installation of packages in the meantime. -# If docker and docker-compose are available for this platform/architecture, it could be added a step to test the stack commands (or even replace this one). -echo " - label: \":macos: :go: Integration test: build-zip\"" -echo " command: ./.buildkite/scripts/integration_tests.sh -t test-just-build-zip" +echo " - label: \":go: Integration test: build-install-zip\"" +echo " command: ./.buildkite/scripts/integration_tests.sh -t test-build-install-zip" echo " agents:" -echo " provider: \"orka\"" -echo " imagePrefix: \"${MACOS_ARM_AGENT_IMAGE}\"" +echo " provider: \"gcp\"" +echo " image: \"${UBUNTU_X86_64_AGENT_IMAGE}\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/build-zip/logs/*.log" echo " - build/packages/*.sig" -echo " - label: \":go: Integration test: install-zip\"" -echo " command: ./.buildkite/scripts/integration_tests.sh -t test-install-zip" +echo " - label: \":go: Integration test: build-install-zip-file\"" +echo " command: ./.buildkite/scripts/integration_tests.sh -t test-build-install-zip-file" echo " agents:" echo " provider: \"gcp\"" echo " image: \"${UBUNTU_X86_64_AGENT_IMAGE}\"" echo " artifact_paths:" echo " - build/elastic-stack-dump/install-zip/logs/*.log" -echo " - label: \":go: Integration test: install-zip-shellinit\"" -echo " command: ./.buildkite/scripts/integration_tests.sh -t test-install-zip-shellinit" +echo " - label: \":go: Integration test: build-install-zip-file-shellinit\"" +echo " command: ./.buildkite/scripts/integration_tests.sh -t test-build-install-zip-file-shellinit" echo " agents:" echo " provider: \"gcp\"" echo " image: \"${UBUNTU_X86_64_AGENT_IMAGE}\"" diff --git a/.buildkite/scripts/integration_tests.sh b/.buildkite/scripts/integration_tests.sh index 2c30000be..465a9d8d2 100755 --- a/.buildkite/scripts/integration_tests.sh +++ b/.buildkite/scripts/integration_tests.sh @@ -31,7 +31,7 @@ PARALLEL_TARGET="test-check-packages-parallel" FALSE_POSITIVES_TARGET="test-check-packages-false-positives" KIND_TARGET="test-check-packages-with-kind" SYSTEM_TEST_FLAGS_TARGET="test-system-test-flags" -TEST_JUST_BUILD_ZIP_TARGET="test-just-build-zip" +TEST_BUILD_ZIP_TARGET="test-build-zip" GOOGLE_CREDENTIALS_FILENAME="google-cloud-credentials.json" @@ -82,7 +82,7 @@ if [[ "$SERVERLESS" == "false" ]]; then echo "--- install go" with_go - if [[ "${TARGET}" != "${TEST_JUST_BUILD_ZIP_TARGET}" ]]; then + if [[ "${TARGET}" != "${TEST_BUILD_ZIP_TARGET}" ]]; then # Not supported in Macos ARM echo "--- install docker" with_docker @@ -92,11 +92,8 @@ if [[ "$SERVERLESS" == "false" ]]; then fi fi -if [[ "${TARGET}" == "${FALSE_POSITIVES_TARGET}" ]]; then - # just required for now while testing false positive targets - echo "--- install yq" - with_yq -fi +echo "--- install yq" +with_yq if [[ "${TARGET}" == "${KIND_TARGET}" || "${TARGET}" == "${SYSTEM_TEST_FLAGS_TARGET}" ]]; then echo "--- install kubectl & kind" diff --git a/Makefile b/Makefile index ba7818587..62b5609af 100644 --- a/Makefile +++ b/Makefile @@ -109,14 +109,14 @@ test-check-packages-with-custom-agent: test-build-zip: ./scripts/test-build-zip.sh -test-just-build-zip: - ./scripts/test-just-build-zip.sh +test-build-install-zip: + ./scripts/test-build-install-zip.sh -test-install-zip: - ./scripts/test-install-zip.sh +test-build-install-zip-file: + ./scripts/test-build-install-zip-file.sh -test-install-zip-shellinit: - ./scripts/test-install-zip.sh -s +test-build-install-zip-file-shellinit: + ./scripts/test-build-install-zip-file.sh -s test-system-test-flags: ./scripts/test-system-test-flags.sh @@ -127,7 +127,7 @@ test-profiles-command: test-check-update-version: ./scripts/test-check-update-version.sh -test: test-go test-stack-command test-check-packages test-profiles-command test-build-zip test-check-update-version +test: test-go test-stack-command test-check-packages test-profiles-command test-build-install-zip test-build-zip test-build-install-zip-file test-build-install-zip-file-shellinit test-check-update-version test-profiles-command test-system-test-flags check-git-clean: git update-index --really-refresh diff --git a/scripts/test-install-zip.sh b/scripts/test-build-install-zip-file.sh similarity index 100% rename from scripts/test-install-zip.sh rename to scripts/test-build-install-zip-file.sh diff --git a/scripts/test-build-install-zip.sh b/scripts/test-build-install-zip.sh new file mode 100755 index 000000000..5812f9583 --- /dev/null +++ b/scripts/test-build-install-zip.sh @@ -0,0 +1,73 @@ +#!/bin/bash + +set -euxo pipefail + +cleanup() { + r=$? + + # Dump stack logs + elastic-package stack dump -v --output build/elastic-stack-dump/build-zip + + # Take down the stack + elastic-package stack down -v + + # Clean used resources + for d in test/packages/*/*/; do + elastic-package clean -C "$d" -v + done + + exit $r +} + +testype() { + basename "$(dirname "$1")" +} + +trap cleanup EXIT + +OLDPWD=$PWD +# Build packages +export ELASTIC_PACKAGE_SIGNER_PRIVATE_KEYFILE="$OLDPWD/scripts/gpg-private.asc" +ELASTIC_PACKAGE_SIGNER_PASSPHRASE=$(cat "$OLDPWD/scripts/gpg-pass.txt") +export ELASTIC_PACKAGE_SIGNER_PASSPHRASE +ELASTIC_PACKAGE_LINKS_FILE_PATH="$(pwd)/scripts/links_table.yml" +export ELASTIC_PACKAGE_LINKS_FILE_PATH + +go run ./scripts/gpgkey + +for d in test/packages/*/*/; do + # Packages in false_positives can have issues. + if [ "$(testype $d)" == "false_positives" ]; then + continue + fi + elastic-package build -C "$d" --zip --sign -v +done + +# Remove unzipped built packages, leave .zip files +rm -r build/packages/*/ + +# Boot up the stack +elastic-package stack up -d -v + +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 + continue + fi + package_name=$(cat "${d}/manifest.yml" | yq -r .name) + package_version=$(cat "${d}/manifest.yml" | yq -r .version) + PACKAGE_NAME_VERSION="${package_name}-${package_version}" + + elastic-package install -C "$d" -v + + # check that the package is installed + curl -s \ + -u "${ELASTIC_PACKAGE_ELASTICSEARCH_USERNAME}:${ELASTIC_PACKAGE_ELASTICSEARCH_PASSWORD}" \ + --cacert "${ELASTIC_PACKAGE_CA_CERT}" \ + -H 'content-type: application/json' \ + -H 'kbn-xsrf: true' \ + -f "${ELASTIC_PACKAGE_KIBANA_HOST}/api/fleet/epm/packages/${PACKAGE_NAME_VERSION}" | grep -q '"status":"installed"' +done diff --git a/scripts/test-build-zip.sh b/scripts/test-build-zip.sh index 3616fdff3..bdd382cbb 100755 --- a/scripts/test-build-zip.sh +++ b/scripts/test-build-zip.sh @@ -5,12 +5,6 @@ set -euxo pipefail cleanup() { r=$? - # Dump stack logs - elastic-package stack dump -v --output build/elastic-stack-dump/build-zip - - # Take down the stack - elastic-package stack down -v - # Clean used resources for d in test/packages/*/*/; do elastic-package clean -C "$d" -v @@ -45,15 +39,3 @@ done # Remove unzipped built packages, leave .zip files rm -r build/packages/*/ - -# Boot up the stack -elastic-package stack up -d -v - -# Install zipped packages -for d in test/packages/*/*/; do - # Packages in false_positives can have issues. - if [ "$(testype $d)" == "false_positives" ]; then - continue - fi - elastic-package install -C "$d" -v -done diff --git a/scripts/test-just-build-zip.sh b/scripts/test-just-build-zip.sh deleted file mode 100755 index bdd382cbb..000000000 --- a/scripts/test-just-build-zip.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -set -euxo pipefail - -cleanup() { - r=$? - - # Clean used resources - for d in test/packages/*/*/; do - elastic-package clean -C "$d" -v - done - - exit $r -} - -testype() { - basename "$(dirname "$1")" -} - -trap cleanup EXIT - -OLDPWD=$PWD -# Build packages -export ELASTIC_PACKAGE_SIGNER_PRIVATE_KEYFILE="$OLDPWD/scripts/gpg-private.asc" -ELASTIC_PACKAGE_SIGNER_PASSPHRASE=$(cat "$OLDPWD/scripts/gpg-pass.txt") -export ELASTIC_PACKAGE_SIGNER_PASSPHRASE -ELASTIC_PACKAGE_LINKS_FILE_PATH="$(pwd)/scripts/links_table.yml" -export ELASTIC_PACKAGE_LINKS_FILE_PATH - -go run ./scripts/gpgkey - -for d in test/packages/*/*/; do - # Packages in false_positives can have issues. - if [ "$(testype $d)" == "false_positives" ]; then - continue - fi - elastic-package build -C "$d" --zip --sign -v -done - -# Remove unzipped built packages, leave .zip files -rm -r build/packages/*/