-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Expand file tree
/
Copy pathftr_configs.sh
More file actions
executable file
·186 lines (152 loc) · 6.34 KB
/
ftr_configs.sh
File metadata and controls
executable file
·186 lines (152 loc) · 6.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env bash
set -euo pipefail
source .buildkite/scripts/steps/functional/common.sh
source .buildkite/scripts/steps/test/ftr_job_annotation.sh
BUILDKITE_PARALLEL_JOB=${BUILDKITE_PARALLEL_JOB:-}
FTR_CONFIG_GROUP_KEY=${FTR_CONFIG_GROUP_KEY:-}
if [ "$FTR_CONFIG_GROUP_KEY" == "" ] && [ "$BUILDKITE_PARALLEL_JOB" == "" ]; then
echo "Missing FTR_CONFIG_GROUP_KEY env var"
exit 1
fi
EXTRA_ARGS=${FTR_EXTRA_ARGS:-}
test -z "$EXTRA_ARGS" || buildkite-agent meta-data set "ftr-extra-args" "$EXTRA_ARGS"
export JOB="$FTR_CONFIG_GROUP_KEY"
FAILED_CONFIGS_KEY="${BUILDKITE_STEP_ID}${FTR_CONFIG_GROUP_KEY}"
# a FTR failure will result in the script returning an exit code of 10
exitCode=0
annotation_rows=()
failure_detail_lines=()
retry_recovered=false
configs="${FTR_CONFIG:-}"
# The first retry should only run the configs that failed in the previous attempt
# Any subsequent retries, which would generally only happen by someone clicking the button in the UI, will run everything
if [[ ! "$configs" && "${BUILDKITE_RETRY_COUNT:-0}" == "1" ]]; then
configs=$(buildkite-agent meta-data get "$FAILED_CONFIGS_KEY" --default '')
if [[ "$configs" ]]; then
echo "--- Retrying only failed configs"
echo "$configs"
fi
fi
if [ "$configs" == "" ] && [ "$FTR_CONFIG_GROUP_KEY" != "" ]; then
echo "--- downloading ftr test run order"
download_tmp_artifact ftr_run_order.json . "$BUILDKITE_BUILD_ID"
configs=$(jq -r '.[env.FTR_CONFIG_GROUP_KEY].names[]' ftr_run_order.json)
fi
if [ "$configs" == "" ]; then
echo "unable to determine configs to run"
exit 1
fi
failedConfigs=""
results=()
# Capture which configs failed in the previous attempt before the meta-data key is overwritten below.
prevRunFailedConfigs=""
if [[ "${BUILDKITE_RETRY_COUNT:-0}" -ge "1" ]]; then
prevRunFailedConfigs=$(buildkite-agent meta-data get "$FAILED_CONFIGS_KEY" --default '' 2>/dev/null || true)
fi
while read -r config; do
if [[ ! "$config" ]]; then
continue;
fi
FULL_COMMAND="node scripts/functional_tests --bail --config $config $EXTRA_ARGS"
# see if this config has already been executed successfully
CONFIG_EXECUTION_KEY="${config}_executed"
IS_CONFIG_EXECUTION=$(buildkite-agent meta-data get "$CONFIG_EXECUTION_KEY" --default "false" --log-level error)
# we don't want this optimization for flaky test runs
IS_FLAKY_TEST_RUN=$(test -z "${KIBANA_FLAKY_TEST_RUNNER_CONFIG:-}" && echo "false" || echo "true")
if [[ "$IS_CONFIG_EXECUTION" == "true" && "$IS_FLAKY_TEST_RUN" == "false" ]]; then
echo "--- [ already-tested ] $FULL_COMMAND"
annotation_rows+=("| [\`${config}\`](https://github.com/elastic/kibana/blob/${BUILDKITE_COMMIT:-main}/${config}) | — | skipped (already-tested) |")
continue
else
echo "--- $ $FULL_COMMAND"
fi
start=$(date +%s)
if [[ "${USE_CHROME_BETA:-}" =~ ^(1|true)$ ]]; then
echo "USE_CHROME_BETA was set - using google-chrome-beta"
export TEST_BROWSER_BINARY_PATH="$(which google-chrome-beta)"
# download the beta version of chromedriver
export CHROMEDRIVER_VERSION=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json -s | jq -r '.channels.Beta.version')
export DETECT_CHROMEDRIVER_VERSION=false
node node_modules/chromedriver/install.js --chromedriver-force-download
# set annotation on the build
buildkite-agent annotate --style info --context chrome-beta """
⚠️This build uses Google Chrome Beta
Path: ${TEST_BROWSER_BINARY_PATH}
Version: $($TEST_BROWSER_BINARY_PATH --version)
Chromedriver version: ${CHROMEDRIVER_VERSION} / $(node node_modules/chromedriver/bin/chromedriver --version)
"""
fi
node scripts/ftr_annotation_helper snapshot "target/junit/$JOB" 2>/dev/null || true
# prevent non-zero exit code from breaking the loop
set +e;
node ./scripts/functional_tests \
--bail \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
--config="$config" \
"$EXTRA_ARGS"
lastCode=$?
set -e;
# Scout reporter
if [[ "${SCOUT_REPORTER_ENABLED:-}" =~ ^(1|true)$ ]]; then
# Upload events after running each config
echo "Upload Scout reporter events to AppEx QA's team cluster for config $config"
node scripts/scout upload-events --dontFailOnError
echo "Upload successful, removing local events at .scout/reports"
rm -rf .scout/reports
else
echo "SCOUT_REPORTER_ENABLED=$SCOUT_REPORTER_ENABLED, skipping event upload."
fi
timeSec=$(($(date +%s)-start))
if [[ $timeSec -gt 60 ]]; then
min=$((timeSec/60))
sec=$((timeSec-(min*60)))
duration="${min}m ${sec}s"
else
duration="${timeSec}s"
fi
results+=("- $config
duration: ${duration}
result: ${lastCode}")
config_link="[\`${config}\`](https://github.com/elastic/kibana/blob/${BUILDKITE_COMMIT:-main}/${config})"
if [ $lastCode -eq 0 ]; then
# Test was successful, so mark it as executed
buildkite-agent meta-data set "$CONFIG_EXECUTION_KEY" "true"
if [[ -n "$prevRunFailedConfigs" ]] && grep -qxF "$config" <<< "$prevRunFailedConfigs"; then
annotation_rows+=("| ${config_link} | ${duration} | recovered |")
else
annotation_rows+=("| ${config_link} | ${duration} | passed |")
fi
else
exitCode=10
echo "FTR exited with code $lastCode"
echo "^^^ +++"
if [[ "$failedConfigs" ]]; then
failedConfigs="${failedConfigs}"$'\n'"$config"
else
failedConfigs="$config"
fi
if [[ -n "$prevRunFailedConfigs" ]] && grep -qxF "$config" <<< "$prevRunFailedConfigs"; then
annotation_rows+=("| ${config_link} | ${duration} | **still failing** |")
elif [[ -n "$prevRunFailedConfigs" ]]; then
annotation_rows+=("| ${config_link} | ${duration} | **new failure** (was passing) |")
else
annotation_rows+=("| ${config_link} | ${duration} | **failed** |")
fi
config_failures=$(node scripts/ftr_annotation_helper list-new-failures "target/junit/$JOB" 2>/dev/null || true)
if [[ -n "$config_failures" ]]; then
failure_detail_lines+=("**Failing tests — \`${config}\`:**" "")
while IFS= read -r t; do
[[ -n "$t" ]] && failure_detail_lines+=("- ${t}")
done <<< "$config_failures"
failure_detail_lines+=("")
fi
fi
done <<< "$configs"
if [[ "$failedConfigs" ]]; then
buildkite-agent meta-data set "$FAILED_CONFIGS_KEY" "$failedConfigs"
fi
echo "--- FTR configs complete"
printf "%s\n" "${results[@]}"
echo ""
write_job_annotation
exit $exitCode