@@ -96,26 +96,42 @@ droute_send() {
9696 .targets.reportportal.processing.tfa.auto_finalization_threshold = ($auto_finalization_treshold | tonumber)
9797 ' data_router/data_router_metadata_template.json > " ${ARTIFACT_DIR} /${project} /${metadata_output} "
9898
99- oc rsync --progress=true --include=" ${metadata_output} " --include=" ${JUNIT_RESULTS} " --exclude=" *" -n " ${droute_project} " " ${ARTIFACT_DIR} /${project} /" " ${droute_project} /${droute_pod_name} :${temp_droute} /"
99+ # Send test by rsync to bastion pod.
100+ local max_attempts=5
101+ local wait_seconds=4
102+ for (( i = 1 ; i <= max_attempts; i++ )) ; do
103+ echo " Attempt ${i} of ${max_attempts} to rsync test resuls to bastion pod."
104+ 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
105+ echo " $output "
106+ break
107+ fi
108+ if (( i == max_attempts)) ; then
109+ echo " Failed to rsync test results after ${max_attempts} attempts."
110+ echo " Last rsync error details:"
111+ echo " ${output} "
112+ echo " Troubleshooting steps:"
113+ echo " 1. Restart $droute_pod_name in $droute_project project/namespace"
114+ fi
115+ done
100116
101117 # "Install" Data Router
102118 oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c "
103- curl -fsSLk -o /tmp /droute-linux-amd64 'https://${DATA_ROUTER_NEXUS_HOSTNAME} /nexus/repository/dno-raw/droute-client/${droute_version} /droute-linux-amd64' \
104- && chmod +x /tmp /droute-linux-amd64 \
105- && /tmp /droute-linux-amd64 version"
119+ curl -fsSLk -o ${temp_droute} /droute-linux-amd64 'https://${DATA_ROUTER_NEXUS_HOSTNAME} /nexus/repository/dno-raw/droute-client/${droute_version} /droute-linux-amd64' \
120+ && chmod +x ${temp_droute} /droute-linux-amd64 \
121+ && ${temp_droute} /droute-linux-amd64 version"
106122
107123 # Send test results through DataRouter and save the request ID.
108124 local max_attempts=5
109125 local wait_seconds=1
110126 for (( i = 1 ; i <= max_attempts; i++ )) ; do
111127 echo " Attempt ${i} of ${max_attempts} to send test results through Data Router."
112128 if output=$( oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c "
113- /tmp /droute-linux-amd64 send --metadata ${temp_droute} /${metadata_output} \
114- --url '${DATA_ROUTER_URL} ' \
115- --username '${DATA_ROUTER_USERNAME} ' \
116- --password '${DATA_ROUTER_PASSWORD} ' \
117- --results '${temp_droute} /${JUNIT_RESULTS} ' \
118- --verbose" 2>&1 ) ; then
129+ ${temp_droute} /droute-linux-amd64 send --metadata ${temp_droute} /${metadata_output} \
130+ --url '${DATA_ROUTER_URL} ' \
131+ --username '${DATA_ROUTER_USERNAME} ' \
132+ --password '${DATA_ROUTER_PASSWORD} ' \
133+ --results '${temp_droute} /${JUNIT_RESULTS} ' \
134+ --verbose" 2>&1 ) ; then
119135 if DATA_ROUTER_REQUEST_ID=$( echo " $output " | grep " request:" | awk ' {print $2}' ) &&
120136 [ -n " $DATA_ROUTER_REQUEST_ID " ]; then
121137 echo " Test results successfully sent through Data Router."
@@ -143,40 +159,15 @@ droute_send() {
143159 for (( i = 1 ; i <= max_attempts; i++ )) ; do
144160 # Get DataRouter request information.
145161 DATA_ROUTER_REQUEST_OUTPUT=$( oc exec -n " ${droute_project} " " ${droute_pod_name} " -- /bin/bash -c "
146- /tmp /droute-linux-amd64 request get \
162+ ${temp_droute} /droute-linux-amd64 request get \
147163 --url ${DATA_ROUTER_URL} \
148164 --username ${DATA_ROUTER_USERNAME} \
149165 --password ${DATA_ROUTER_PASSWORD} \
150166 ${DATA_ROUTER_REQUEST_ID} " )
151167 # Try to extract the ReportPortal launch URL from the request. This fails if it doesn't contain the launch URL.
152168 REPORTPORTAL_LAUNCH_URL=$( echo " $DATA_ROUTER_REQUEST_OUTPUT " | yq e ' .targets[0].events[] | select(.component == "reportportal-connector") | .message | fromjson | .[0].launch_url' -)
153- if [[ $? -eq 0 ]]; then
154- if [[ " $release_name " == * rbac* ]]; then
155- RUN_TYPE=" rbac-nightly"
156- else
157- RUN_TYPE=" nightly"
158- fi
159- if [[ ${PIPESTATUS[0]} -eq 0 ]]; then
160- RUN_STATUS_EMOJI=" :done-circle-check:"
161- RUN_STATUS=" passed"
162- else
163- RUN_STATUS_EMOJI=" :failed:"
164- RUN_STATUS=" failed"
165- fi
166- jq -n \
167- --arg run_status " $RUN_STATUS " \
168- --arg run_type " $RUN_TYPE " \
169- --arg reportportal_launch_url " $REPORTPORTAL_LAUNCH_URL " \
170- --arg job_name " $JOB_NAME " \
171- --arg run_status_emoji " $RUN_STATUS_EMOJI " \
172- ' {
173- "RUN_STATUS": $run_status,
174- "RUN_TYPE": $run_type,
175- "REPORTPORTAL_LAUNCH_URL": $reportportal_launch_url,
176- "JOB_NAME": $job_name,
177- "RUN_STATUS_EMOJI": $run_status_emoji
178- }' > /tmp/data_router_slack_message.json
179- curl -X POST -H ' Content-type: application/json' --data @/tmp/data_router_slack_message.json $SLACK_DATA_ROUTER_WEBHOOK_URL
169+ if [[ -n " $REPORTPORTAL_LAUNCH_URL " ]]; then
170+ reportportal_slack_alert $release_name $REPORTPORTAL_LAUNCH_URL
180171 return 0
181172 else
182173 echo " Attempt ${i} of ${max_attempts} : ReportPortal launch URL not ready yet."
@@ -194,6 +185,38 @@ droute_send() {
194185 oc whoami --show-server
195186}
196187
188+ reportportal_slack_alert () {
189+ local release_name=$1
190+ local reportportal_launch_url=$2
191+
192+ if [[ " $release_name " == * rbac* ]]; then
193+ RUN_TYPE=" rbac-nightly"
194+ else
195+ RUN_TYPE=" nightly"
196+ fi
197+ if [[ ${RESULT} -eq 0 ]]; then
198+ RUN_STATUS_EMOJI=" :done-circle-check:"
199+ RUN_STATUS=" passed"
200+ else
201+ RUN_STATUS_EMOJI=" :failed:"
202+ RUN_STATUS=" failed"
203+ fi
204+ jq -n \
205+ --arg run_status " $RUN_STATUS " \
206+ --arg run_type " $RUN_TYPE " \
207+ --arg reportportal_launch_url " $reportportal_launch_url " \
208+ --arg job_name " $JOB_NAME " \
209+ --arg run_status_emoji " $RUN_STATUS_EMOJI " \
210+ ' {
211+ "RUN_STATUS": $run_status,
212+ "RUN_TYPE": $run_type,
213+ "REPORTPORTAL_LAUNCH_URL": $reportportal_launch_url,
214+ "JOB_NAME": $job_name,
215+ "RUN_STATUS_EMOJI": $run_status_emoji
216+ }' > /tmp/data_router_slack_message.json
217+ curl -X POST -H ' Content-type: application/json' --data @/tmp/data_router_slack_message.json $SLACK_DATA_ROUTER_WEBHOOK_URL
218+ }
219+
197220# Merge the base YAML value file with the differences file for Kubernetes
198221yq_merge_value_files () {
199222 local base_file=$1
0 commit comments