Skip to content

Commit 12cd1f5

Browse files
mergify[bot]mrodm
andauthored
[Buildkite] Ignore non successful exit code in cloud-deploy target (test-cloude2e) (#3243) (#3309)
Ensure that the process to clean/destroy the cloud deployment is executed even if there is any error in any previous command. Moved to a shell script the code to trigger the Cloud E2E tests. (cherry picked from commit 9f3f977) Co-authored-by: Mario Rodriguez Molins <mario.rodriguez@elastic.co>
1 parent f903d34 commit 12cd1f5

File tree

3 files changed

+44
-10
lines changed

3 files changed

+44
-10
lines changed

Makefile

+5-6
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,12 @@ test-e2e-set: ## - Run the blackbox end to end tests without setup.
386386
##################################################
387387
.PHONY: test-cloude2e
388388
test-cloude2e: prepare-test-context ## - Run cloude2e tests with full setup (slow!)
389-
@make -C ${CLOUD_TESTING_BASE} cloud-deploy
390-
$(eval FLEET_SERVER_URL := $(shell make -C ${CLOUD_TESTING_BASE} cloud-get-fleet-url))
391-
-@set -o pipefail; $(MAKE) test-cloude2e-set | tee build/test-cloude2e.out
392-
@make -C ${CLOUD_TESTING_BASE} cloud-clean
389+
@# Triggered using a shell script to ensure deployment is cleaned up even if errors (using trap).
390+
@# it would also ensure to exit with failure if any error happens
391+
@$(CLOUD_TESTING_BASE)/launch_cloud_e2e_tests.sh
393392

394393
.PHONY: test-cloude2e-set
395394
test-cloude2e-set: ## Run cloude2e test
396-
$(eval FLEET_SERVER_URL := $(shell make -C ${CLOUD_TESTING_BASE} cloud-get-fleet-url))
395+
$(eval FLEET_SERVER_URL := $(shell make --no-print-directory -C ${CLOUD_TESTING_BASE} cloud-get-fleet-url))
397396
make -C ${CLOUD_TESTING_BASE} cloud-get-fleet-url
398-
FLEET_SERVER_URL=${FLEET_SERVER_URL} go test -v -tags=cloude2e -count=1 -race -p 1 ./testing/cloude2e
397+
FLEET_SERVER_URL="${FLEET_SERVER_URL}" go test -v -tags=cloude2e -count=1 -race -p 1 ./testing/cloude2e

dev-tools/cloud/Makefile

+2-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,5 @@ cloud-clean: ## Clean cloud deployment
3636
@cd ${TERRAFORM_PATH}; terraform destroy -auto-approve
3737

3838
.PHONY: cloud-get-fleet-url
39-
cloud-get-fleet-url: ## Clean cloud deployment
40-
$(eval FLEET_SERVER_URL := $(shell terraform output --state=${TERRAFORM_PATH}/terraform.tfstate fleet_url))
41-
@echo '${FLEET_SERVER_URL}'
42-
39+
cloud-get-fleet-url: ## Get Fleet URL from this deployment
40+
@terraform output --raw --state=${TERRAFORM_PATH}/terraform.tfstate fleet_url
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
CLOUD_TESTING_BASE="$(dirname $0)"
6+
7+
cleanup() {
8+
r=$?
9+
10+
echo "--- Cleaning deployment"
11+
make -C "${CLOUD_TESTING_BASE}" cloud-clean
12+
13+
exit $r
14+
}
15+
trap cleanup EXIT INT TERM
16+
17+
echo "--- Creating deployment"
18+
make -C "${CLOUD_TESTING_BASE}" cloud-deploy
19+
20+
# Ensure Fleet server URL is defined to run the tests
21+
FLEET_SERVER_URL=$(make --no-print-directory -C "${CLOUD_TESTING_BASE}" cloud-get-fleet-url)
22+
echo "Fleet server: \"${FLEET_SERVER_URL}\""
23+
if [[ "${FLEET_SERVER_URL}" == "" ]]; then
24+
message="FLEET_SERVER_URL is empty, cloud e2e tests cannot be executed"
25+
if [[ "${CI}" == "true" ]]; then
26+
buildkite-agent annotate \
27+
"${message}" \
28+
--context "ctx-cloude2e-test" \
29+
--style "error"
30+
fi
31+
echo "${message}"
32+
exit 0
33+
fi
34+
35+
echo "--- Trigger cloud E2E test"
36+
make test-cloude2e-set | tee build/test-cloude2e-set
37+

0 commit comments

Comments
 (0)