Skip to content
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

Use local images for ES integration tests #5715

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 21 additions & 8 deletions plugin/storage/integration/es_index_cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package integration
import (
"context"
"fmt"
"os"
"os/exec"
"testing"

Expand All @@ -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()
Expand Down
27 changes: 21 additions & 6 deletions scripts/es-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ check_arg() {
fi
}

# Build local images for index cleaner and rollover
build_local_images() {
local j_version=$1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it was an unused variable. I've removed it now.

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
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -113,4 +128,4 @@ main() {
fi
}

main "$@"
main "$@"
Loading