Skip to content

Commit b558150

Browse files
jsvddonoghuc
andauthored
refactor travis tests for the new release cadence (#1192)
Co-authored-by: Cas Donoghue <[email protected]>
1 parent d5f0130 commit b558150

File tree

3 files changed

+84
-53
lines changed

3 files changed

+84
-53
lines changed

.ci/docker-setup.sh

Lines changed: 69 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,88 @@
11
#!/bin/bash
22

3-
# This is intended to be run the plugin's root directory. `.ci/docker-setup.sh`
3+
# This is intended to be run the plugin's root directory. `ci/unit/docker-test.sh`
44
# Ensure you have Docker installed locally and set the ELASTIC_STACK_VERSION environment variable.
55
set -e
66

7-
VERSION_URL="https://raw.githubusercontent.com/elastic/logstash/master/ci/logstash_releases.json"
8-
9-
107
pull_docker_snapshot() {
118
project="${1?project name required}"
12-
local docker_image="docker.elastic.co/${project}/${project}:${ELASTIC_STACK_VERSION}"
9+
local docker_image="docker.elastic.co/${project}/${project}${DISTRIBUTION_SUFFIX}:${ELASTIC_STACK_VERSION}"
1310
echo "Pulling $docker_image"
14-
docker pull "$docker_image"
11+
if docker pull "$docker_image" ; then
12+
echo "docker pull successful"
13+
else
14+
case "$ELASTIC_STACK_VERSION_ARG" in
15+
"8.previous"|"8.current"|"8.next")
16+
exit 1
17+
;;
18+
*)
19+
exit 2
20+
;;
21+
esac
22+
fi
1523
}
1624

17-
if [ "$ELASTIC_STACK_VERSION" ]; then
18-
echo "Fetching versions from $VERSION_URL"
19-
VERSIONS=$(curl --silent $VERSION_URL)
20-
if [[ "$SNAPSHOT" = "true" ]]; then
21-
ELASTIC_STACK_RETRIEVED_VERSION=$(echo $VERSIONS | jq '.snapshots."'"$ELASTIC_STACK_VERSION"'"')
22-
echo $ELASTIC_STACK_RETRIEVED_VERSION
23-
else
24-
ELASTIC_STACK_RETRIEVED_VERSION=$(echo $VERSIONS | jq '.releases."'"$ELASTIC_STACK_VERSION"'"')
25-
fi
26-
if [[ "$ELASTIC_STACK_RETRIEVED_VERSION" != "null" ]]; then
27-
# remove starting and trailing double quotes
28-
ELASTIC_STACK_RETRIEVED_VERSION="${ELASTIC_STACK_RETRIEVED_VERSION%\"}"
29-
ELASTIC_STACK_RETRIEVED_VERSION="${ELASTIC_STACK_RETRIEVED_VERSION#\"}"
30-
echo "Translated $ELASTIC_STACK_VERSION to ${ELASTIC_STACK_RETRIEVED_VERSION}"
31-
export ELASTIC_STACK_VERSION=$ELASTIC_STACK_RETRIEVED_VERSION
32-
fi
25+
VERSION_URL="https://raw.githubusercontent.com/elastic/logstash/main/ci/logstash_releases.json"
26+
27+
if [ -z "${ELASTIC_STACK_VERSION}" ]; then
28+
echo "Please set the ELASTIC_STACK_VERSION environment variable"
29+
echo "For example: export ELASTIC_STACK_VERSION=7.x"
30+
exit 1
31+
fi
3332

34-
echo "Testing against version: $ELASTIC_STACK_VERSION"
33+
# save the original arg if needed
34+
ELASTIC_STACK_VERSION_ARG="$ELASTIC_STACK_VERSION"
3535

36-
if [[ "$ELASTIC_STACK_VERSION" = *"-SNAPSHOT" ]]; then
37-
pull_docker_snapshot "logstash"
38-
if [ "$INTEGRATION" == "true" ]; then
39-
pull_docker_snapshot "elasticsearch"
40-
fi
41-
fi
36+
echo "Fetching versions from $VERSION_URL"
37+
VERSIONS=$(curl -s $VERSION_URL)
4238

43-
if [ -f Gemfile.lock ]; then
44-
rm Gemfile.lock
45-
fi
39+
if [[ "$SNAPSHOT" = "true" ]]; then
40+
ELASTIC_STACK_RETRIEVED_VERSION=$(echo $VERSIONS | jq '.snapshots."'"$ELASTIC_STACK_VERSION"'"')
41+
echo $ELASTIC_STACK_RETRIEVED_VERSION
42+
else
43+
ELASTIC_STACK_RETRIEVED_VERSION=$(echo $VERSIONS | jq '.releases."'"$ELASTIC_STACK_VERSION"'"')
44+
fi
4645

47-
cd .ci
46+
if [[ "$ELASTIC_STACK_RETRIEVED_VERSION" != "null" ]]; then
47+
# remove starting and trailing double quotes
48+
ELASTIC_STACK_RETRIEVED_VERSION="${ELASTIC_STACK_RETRIEVED_VERSION%\"}"
49+
ELASTIC_STACK_RETRIEVED_VERSION="${ELASTIC_STACK_RETRIEVED_VERSION#\"}"
50+
echo "Translated $ELASTIC_STACK_VERSION to ${ELASTIC_STACK_RETRIEVED_VERSION}"
51+
export ELASTIC_STACK_VERSION=$ELASTIC_STACK_RETRIEVED_VERSION
52+
elif [[ "$ELASTIC_STACK_VERSION" == "8.next" ]]; then
53+
# we know "8.next" only exists between FF and GA of a minor
54+
# exit 1 so the build is skipped
55+
exit 1
56+
fi
57+
58+
case "${DISTRIBUTION}" in
59+
default) DISTRIBUTION_SUFFIX="" ;; # empty string when explicit "default" is given
60+
*) DISTRIBUTION_SUFFIX="${DISTRIBUTION/*/-}${DISTRIBUTION}" ;;
61+
esac
62+
export DISTRIBUTION_SUFFIX
63+
64+
echo "Testing against version: $ELASTIC_STACK_VERSION (distribution: ${DISTRIBUTION:-"default"})"
4865

66+
if [[ "$ELASTIC_STACK_VERSION" = *"-SNAPSHOT" ]]; then
67+
pull_docker_snapshot "logstash"
4968
if [ "$INTEGRATION" == "true" ]; then
50-
docker-compose down
51-
docker-compose build --quiet
52-
else
53-
docker-compose down
54-
docker-compose build logstash --quiet
69+
pull_docker_snapshot "elasticsearch"
5570
fi
56-
else
57-
echo "Please set the ELASTIC_STACK_VERSION environment variable"
58-
echo "For example: export ELASTIC_STACK_VERSION=6.2.4"
59-
exit 1
6071
fi
6172

73+
if [ -f Gemfile.lock ]; then
74+
rm Gemfile.lock
75+
fi
76+
77+
CURRENT_DIR=$(dirname "${BASH_SOURCE[0]}")
78+
79+
cd .ci
80+
81+
export BUILDKIT_PROGRESS=plain
82+
if [ "$INTEGRATION" == "true" ]; then
83+
docker-compose down
84+
docker-compose build --quiet
85+
else
86+
docker-compose down
87+
docker-compose build logstash --quiet
88+
fi

.ci/logstash-run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ wait_for_es() {
2222
[[ $count -eq 0 ]] && exit 1
2323
sleep 1
2424
done
25-
echo $(curl $CURL_OPTS -vi $ES_URL | python -c "import sys, json; print(json.load(sys.stdin)['version']['number'])")
25+
echo $(curl $CURL_OPTS -vi $ES_URL | jq -r .version.number)
2626
}
2727

2828
if [[ "$INTEGRATION" != "true" ]]; then

.travis.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import:
22
- logstash-plugins/.ci:travis/[email protected]
33

4-
env:
5-
- INTEGRATION=false ELASTIC_STACK_VERSION=7.x
6-
- INTEGRATION=false ELASTIC_STACK_VERSION=8.x SNAPSHOT=true
7-
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x
8-
- INTEGRATION=true ELASTIC_STACK_VERSION=7.x SNAPSHOT=true LOG_LEVEL=info
9-
- INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true LOG_LEVEL=info
10-
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=8.x SNAPSHOT=true LOG_LEVEL=info
11-
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x LOG_LEVEL=info
12-
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x ES_SSL_KEY_INVALID=true LOG_LEVEL=info
13-
- SECURE_INTEGRATION=true INTEGRATION=true ELASTIC_STACK_VERSION=7.x ES_SSL_SUPPORTED_PROTOCOLS=TLSv1.3 LOG_LEVEL=info
4+
jobs:
5+
include:
6+
- stage: "Integration Tests"
7+
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=7.current
8+
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.previous
9+
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.current
10+
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.next
11+
- env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.future
12+
# - env: INTEGRATION=true SNAPSHOT=true LOG_LEVEL=info ELASTIC_STACK_VERSION=main
13+
- stage: "Secure Integration Tests"
14+
- env: SECURE_INTEGRATION=true INTEGRATION=true LOG_LEVEL=info ELASTIC_STACK_VERSION=8.current SNAPSHOT=true
15+
- env: SECURE_INTEGRATION=true INTEGRATION=true LOG_LEVEL=info ELASTIC_STACK_VERSION=7.current
16+
- env: SECURE_INTEGRATION=true INTEGRATION=true LOG_LEVEL=info ELASTIC_STACK_VERSION=7.current ES_SSL_KEY_INVALID=true
17+
- env: SECURE_INTEGRATION=true INTEGRATION=true LOG_LEVEL=info ELASTIC_STACK_VERSION=7.current ES_SSL_SUPPORTED_PROTOCOLS=TLSv1.3

0 commit comments

Comments
 (0)