From 90b7c8d5b6ddde60c1055b7afdcb76fe8f167a70 Mon Sep 17 00:00:00 2001 From: LogicalGuy77 Date: Sun, 7 Jul 2024 19:31:49 +0530 Subject: [PATCH] Testing Commit Signed-off-by: LogicalGuy77 --- .../integration/es_index_cleaner_test.go | 29 ++++++++++++++----- scripts/es-integration-test.sh | 27 +++++++++++++---- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/plugin/storage/integration/es_index_cleaner_test.go b/plugin/storage/integration/es_index_cleaner_test.go index 6a945dfe363..d487689bcd7 100644 --- a/plugin/storage/integration/es_index_cleaner_test.go +++ b/plugin/storage/integration/es_index_cleaner_test.go @@ -17,6 +17,7 @@ package integration import ( "context" "fmt" + "os" "os/exec" "testing" @@ -27,16 +28,28 @@ import ( ) const ( - archiveIndexName = "jaeger-span-archive" - dependenciesIndexName = "jaeger-dependencies-2019-01-01" - samplingIndexName = "jaeger-sampling-2019-01-01" - spanIndexName = "jaeger-span-2019-01-01" - serviceIndexName = "jaeger-service-2019-01-01" - indexCleanerImage = "jaegertracing/jaeger-es-index-cleaner:latest" - rolloverImage = "jaegertracing/jaeger-es-rollover:1.57.0" - rolloverNowEnvVar = `CONDITIONS='{"max_age":"0s"}'` + archiveIndexName = "jaeger-span-archive" + dependenciesIndexName = "jaeger-dependencies-2019-01-01" + samplingIndexName = "jaeger-sampling-2019-01-01" + spanIndexName = "jaeger-span-2019-01-01" + serviceIndexName = "jaeger-service-2019-01-01" + defaultIndexCleanerImage = "jaegertracing/jaeger-es-index-cleaner:latest" + defaultRolloverImage = "jaegertracing/jaeger-es-rollover:1.57.0" + rolloverNowEnvVar = `CONDITIONS='{"max_age":"0s"}'` ) +var ( + indexCleanerImage = getEnvOrDefault("JAEGER_ES_INDEX_CLEANER_IMAGE", defaultIndexCleanerImage) + rolloverImage = getEnvOrDefault("JAEGER_ES_ROLLOVER_IMAGE", defaultRolloverImage) +) + +func getEnvOrDefault(key, defaultValue string) string { + if value, exists := os.LookupEnv(key); exists { + return value + } + return defaultValue +} + func TestIndexCleaner_doNotFailOnEmptyStorage(t *testing.T) { SkipUnlessEnv(t, "elasticsearch", "opensearch") client, err := createESClient() diff --git a/scripts/es-integration-test.sh b/scripts/es-integration-test.sh index 9b1ecf6e794..1b49b01cd1e 100755 --- a/scripts/es-integration-test.sh +++ b/scripts/es-integration-test.sh @@ -18,6 +18,20 @@ check_arg() { fi } +# Build local images for index cleaner and rollover +build_local_images() { + local j_version=$1 + JAEGER_VERSION=$(git describe --tags --abbrev=0) + LOCAL_TAG="local-${JAEGER_VERSION}" + + bash scripts/build-upload-a-docker-image.sh -b -c jaeger-es-index-cleaner -d cmd/es-index-cleaner -t "${LOCAL_TAG}" + bash scripts/build-upload-a-docker-image.sh -b -c jaeger-es-rollover -d cmd/es-rollover -t "${LOCAL_TAG}" + + # Set environment variables for the test + export JAEGER_ES_INDEX_CLEANER_IMAGE="jaegertracing/jaeger-es-index-cleaner:${LOCAL_TAG}" + export JAEGER_ES_ROLLOVER_IMAGE="jaegertracing/jaeger-es-rollover:${LOCAL_TAG}" +} + # start the elasticsearch/opensearch container setup_db() { local compose_file=$1 @@ -45,7 +59,7 @@ wait_for_storage() { echo "Attempt: ${attempt} ${distro} is not yet available at ${url}..." sleep 10 done - + # if after all the attempts the storage is not accessible, terminate it and exit if [[ "$(curl "${params[@]}" "${url}")" != "200" ]]; then echo "ERROR: ${distro} is not ready at ${url} after $(( attempt * 10 )) seconds" @@ -65,7 +79,7 @@ bring_up_storage() { local version=$2 local major_version=${version%%.*} local compose_file="docker-compose/${distro}/v${major_version}/docker-compose.yml" - + echo "starting ${distro} ${major_version}" for retry in 1 2 3 do @@ -100,10 +114,11 @@ main() { check_arg "$@" local distro=$1 local es_version=$2 - local j_version=$2 - + local j_version=$3 + + build_local_images "${j_version}" bring_up_storage "${distro}" "${es_version}" - + if [[ "${j_version}" == "v2" ]]; then STORAGE=${distro} SPAN_STORAGE_TYPE=${distro} make jaeger-v2-storage-integration-test else @@ -113,4 +128,4 @@ main() { fi } -main "$@" +main "$@" \ No newline at end of file