@@ -39,7 +39,9 @@ droute_send() {
39
39
if [[ " ${OPENSHIFT_CI} " != " true" ]]; then return 0; fi
40
40
temp_kubeconfig=$( mktemp) # Create temporary KUBECONFIG to open second `oc` session
41
41
( # Open subshell
42
- set +e
42
+ if [ -n " ${PULL_NUMBER:- } " ]; then
43
+ set +e
44
+ fi
43
45
export KUBECONFIG=" $temp_kubeconfig "
44
46
local droute_version=" 1.2.2"
45
47
local release_name=$1
@@ -93,26 +95,42 @@ droute_send() {
93
95
.targets.reportportal.processing.tfa.auto_finalization_threshold = ($auto_finalization_treshold | tonumber)
94
96
' data_router/data_router_metadata_template.json > " ${ARTIFACT_DIR} /${project} /${metadata_output} "
95
97
96
- oc rsync --progress=true --include=" ${metadata_output} " --include=" ${JUNIT_RESULTS} " --exclude=" *" -n " ${droute_project} " " ${ARTIFACT_DIR} /${project} /" " ${droute_project} /${droute_pod_name} :${temp_droute} /"
98
+ # Send test by rsync to bastion pod.
99
+ local max_attempts=5
100
+ local wait_seconds=4
101
+ for (( i = 1 ; i <= max_attempts; i++ )) ; do
102
+ echo " Attempt ${i} of ${max_attempts} to rsync test resuls to bastion pod."
103
+ if output=$( oc rsync --progress=true --include=" ${metadata_output} " --include=" ${JUNIT_RESULTS} " --exclude=" *" -n " ${droute_project} " " ${ARTIFACT_DIR} /${project} /" " ${droute_project} /${droute_pod_name} :${temp_droute} /" 2>&1 ) ; then
104
+ echo " $output "
105
+ break
106
+ fi
107
+ if (( i == max_attempts)) ; then
108
+ echo " Failed to rsync test results after ${max_attempts} attempts."
109
+ echo " Last rsync error details:"
110
+ echo " ${output} "
111
+ echo " Troubleshooting steps:"
112
+ echo " 1. Restart $droute_pod_name in $droute_project project/namespace"
113
+ fi
114
+ done
97
115
98
116
# "Install" Data Router
99
117
oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c "
100
- curl -fsSLk -o /tmp /droute-linux-amd64 'https://${DATA_ROUTER_NEXUS_HOSTNAME} /nexus/repository/dno-raw/droute-client/${droute_version} /droute-linux-amd64' \
101
- && chmod +x /tmp /droute-linux-amd64 \
102
- && /tmp /droute-linux-amd64 version"
118
+ curl -fsSLk -o ${temp_droute} /droute-linux-amd64 'https://${DATA_ROUTER_NEXUS_HOSTNAME} /nexus/repository/dno-raw/droute-client/${droute_version} /droute-linux-amd64' \
119
+ && chmod +x ${temp_droute} /droute-linux-amd64 \
120
+ && ${temp_droute} /droute-linux-amd64 version"
103
121
104
122
# Send test results through DataRouter and save the request ID.
105
123
local max_attempts=5
106
124
local wait_seconds=1
107
125
for (( i = 1 ; i <= max_attempts; i++ )) ; do
108
126
echo " Attempt ${i} of ${max_attempts} to send test results through Data Router."
109
127
if output=$( oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c "
110
- /tmp /droute-linux-amd64 send --metadata ${temp_droute} /${metadata_output} \
111
- --url '${DATA_ROUTER_URL} ' \
112
- --username '${DATA_ROUTER_USERNAME} ' \
113
- --password '${DATA_ROUTER_PASSWORD} ' \
114
- --results '${temp_droute} /${JUNIT_RESULTS} ' \
115
- --verbose" 2>&1 ) ; then
128
+ ${temp_droute} /droute-linux-amd64 send --metadata ${temp_droute} /${metadata_output} \
129
+ --url '${DATA_ROUTER_URL} ' \
130
+ --username '${DATA_ROUTER_USERNAME} ' \
131
+ --password '${DATA_ROUTER_PASSWORD} ' \
132
+ --results '${temp_droute} /${JUNIT_RESULTS} ' \
133
+ --verbose" 2>&1 ) ; then
116
134
if DATA_ROUTER_REQUEST_ID=$( echo " $output " | grep " request:" | awk ' {print $2}' ) &&
117
135
[ -n " $DATA_ROUTER_REQUEST_ID " ]; then
118
136
echo " Test results successfully sent through Data Router."
@@ -140,40 +158,15 @@ droute_send() {
140
158
for (( i = 1 ; i <= max_attempts; i++ )) ; do
141
159
# Get DataRouter request information.
142
160
DATA_ROUTER_REQUEST_OUTPUT=$( oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c "
143
- /tmp /droute-linux-amd64 request get \
161
+ ${temp_droute} /droute-linux-amd64 request get \
144
162
--url ${DATA_ROUTER_URL} \
145
163
--username ${DATA_ROUTER_USERNAME} \
146
164
--password ${DATA_ROUTER_PASSWORD} \
147
165
${DATA_ROUTER_REQUEST_ID} " )
148
166
# Try to extract the ReportPortal launch URL from the request. This fails if it doesn't contain the launch URL.
149
167
REPORTPORTAL_LAUNCH_URL=$( echo " $DATA_ROUTER_REQUEST_OUTPUT " | yq e ' .targets[0].events[] | select(.component == "reportportal-connector") | .message | fromjson | .[0].launch_url' -)
150
- if [[ $? -eq 0 ]]; then
151
- if [[ " $release_name " == * rbac* ]]; then
152
- RUN_TYPE=" rbac-nightly"
153
- else
154
- RUN_TYPE=" nightly"
155
- fi
156
- if [[ ${PIPESTATUS[0]} -eq 0 ]]; then
157
- RUN_STATUS_EMOJI=" :done-circle-check:"
158
- RUN_STATUS=" passed"
159
- else
160
- RUN_STATUS_EMOJI=" :failed:"
161
- RUN_STATUS=" failed"
162
- fi
163
- jq -n \
164
- --arg run_status " $RUN_STATUS " \
165
- --arg run_type " $RUN_TYPE " \
166
- --arg reportportal_launch_url " $REPORTPORTAL_LAUNCH_URL " \
167
- --arg job_name " $JOB_NAME " \
168
- --arg run_status_emoji " $RUN_STATUS_EMOJI " \
169
- ' {
170
- "RUN_STATUS": $run_status,
171
- "RUN_TYPE": $run_type,
172
- "REPORTPORTAL_LAUNCH_URL": $reportportal_launch_url,
173
- "JOB_NAME": $job_name,
174
- "RUN_STATUS_EMOJI": $run_status_emoji
175
- }' > /tmp/data_router_slack_message.json
176
- curl -X POST -H ' Content-type: application/json' --data @/tmp/data_router_slack_message.json $SLACK_DATA_ROUTER_WEBHOOK_URL
168
+ if [[ -n " $REPORTPORTAL_LAUNCH_URL " ]]; then
169
+ reportportal_slack_alert $release_name $REPORTPORTAL_LAUNCH_URL
177
170
return 0
178
171
else
179
172
echo " Attempt ${i} of ${max_attempts} : ReportPortal launch URL not ready yet."
@@ -183,12 +176,46 @@ droute_send() {
183
176
set -e
184
177
fi
185
178
oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c " rm -rf ${temp_droute} /*"
186
- set -e
179
+ if [ -n " ${PULL_NUMBER:- } " ]; then
180
+ set -e
181
+ fi
187
182
) # Close subshell
188
183
rm -f " $temp_kubeconfig " # Destroy temporary KUBECONFIG
189
184
oc whoami --show-server
190
185
}
191
186
187
+ reportportal_slack_alert () {
188
+ local release_name=$1
189
+ local reportportal_launch_url=$2
190
+
191
+ if [[ " $release_name " == * rbac* ]]; then
192
+ RUN_TYPE=" rbac-nightly"
193
+ else
194
+ RUN_TYPE=" nightly"
195
+ fi
196
+ if [[ ${RESULT} -eq 0 ]]; then
197
+ RUN_STATUS_EMOJI=" :done-circle-check:"
198
+ RUN_STATUS=" passed"
199
+ else
200
+ RUN_STATUS_EMOJI=" :failed:"
201
+ RUN_STATUS=" failed"
202
+ fi
203
+ jq -n \
204
+ --arg run_status " $RUN_STATUS " \
205
+ --arg run_type " $RUN_TYPE " \
206
+ --arg reportportal_launch_url " $reportportal_launch_url " \
207
+ --arg job_name " $JOB_NAME " \
208
+ --arg run_status_emoji " $RUN_STATUS_EMOJI " \
209
+ ' {
210
+ "RUN_STATUS": $run_status,
211
+ "RUN_TYPE": $run_type,
212
+ "REPORTPORTAL_LAUNCH_URL": $reportportal_launch_url,
213
+ "JOB_NAME": $job_name,
214
+ "RUN_STATUS_EMOJI": $run_status_emoji
215
+ }' > /tmp/data_router_slack_message.json
216
+ curl -X POST -H ' Content-type: application/json' --data @/tmp/data_router_slack_message.json $SLACK_DATA_ROUTER_WEBHOOK_URL
217
+ }
218
+
192
219
# Merge the base YAML value file with the differences file for Kubernetes
193
220
yq_merge_value_files () {
194
221
local base_file=$1
0 commit comments