From 0b4ff7c9bd0d7a0180f80606a68380eb18db4bf2 Mon Sep 17 00:00:00 2001 From: Kristof Gyuracz Date: Tue, 7 May 2024 13:23:47 +0200 Subject: [PATCH] chore: update makefile and e2e script to handle macos Signed-off-by: Kristof Gyuracz --- Makefile | 9 ++++++++- e2e/e2e_test.sh | 13 +++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 37ddd813..3e5172f6 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,13 @@ else GOBIN=$(shell go env GOBIN) endif +ifeq ($(go env GOOS),darwin) + TIMEOUT_CMD=gtimeout +else + TIMEOUT_CMD=timeout +endif + + # CONTAINER_TOOL defines the container tool to be used for building images. # Be aware that the target commands are only tested with Docker which is # scaffolded by default. However, you might want to replace it to use other @@ -212,7 +219,7 @@ tidy: ## Tidy Go modules .PHONY: e2e-test e2e-test: ## Run e2e tests - cd e2e && export CI_MODE=$(CI_MODE_ENABLED) NO_KIND_CLEANUP=$(NO_KIND_CLEANUP) && timeout --foreground 15m ./e2e_test.sh || (echo "E2E test failed"; exit 1) + cd e2e && export CI_MODE=$(CI_MODE_ENABLED) NO_KIND_CLEANUP=$(NO_KIND_CLEANUP) && $(TIMEOUT_CMD) --foreground 15m ./e2e_test.sh || (echo "E2E test failed"; exit 1) .PHONY: e2e-test-ci e2e-test-ci: CI_MODE_ENABLED=1 diff --git a/e2e/e2e_test.sh b/e2e/e2e_test.sh index 6062723c..de0cd5c5 100755 --- a/e2e/e2e_test.sh +++ b/e2e/e2e_test.sh @@ -1,4 +1,4 @@ -#!/bin/env bash +#!/usr/bin/env bash set -eou pipefail @@ -14,6 +14,15 @@ CI_MODE=${CI_MODE:-} # Backup current kubernetes context CURRENT_K8S_CTX=$(kubectl config view | grep "current" | cut -f 2 -d : | xargs) +if GOOS="darwin" +then + TIMEOUT_CMD=gtimeout +else + TIMEOUT_CMD=timeout +fi + + + # Prepare env kind create cluster --name "${KIND_CLUSTER_NAME}" --wait 5m kubectl config set-context kind-"${KIND_CLUSTER_NAME}" @@ -41,7 +50,7 @@ kubectl wait --namespace opentelemetry-operator-system --for=condition=available kubectl apply -f ../e2e/testdata/one_tenant_two_subscriptions if [[ -z "${CI_MODE}" ]]; then - $(cd .. && timeout 5m make run &) + $(cd .. && $(TIMEOUT_CMD) 5m make run &) else kind load docker-image controller:latest --name "${KIND_CLUSTER_NAME}" cd .. && make deploy && cd -