Skip to content

Commit 6806919

Browse files
varunj-msftTest
authored andcommitted
MAINT Publish the backend log from the shared test jobs
The end-to-end tests launch pyrit_backend through ServerLauncher, which writes the server log to a file in the system temp directory and then discards it when the agent is torn down. A failing job therefore reports only the client side of the failure, so a backend that is alive but unresponsive is indistinguishable from one that never started. Collect that log and publish it as a pipeline artifact, following the pattern already used by adversarial-benchmark.yml. The collection step tolerates a missing file so the jobs that do not launch a backend are unaffected, and the publish step is skipped entirely when no log was found.
1 parent 2369bc9 commit 6806919

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

.azuredevops/test-job-template.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,39 @@ jobs:
129129
else
130130
make ${{ parameters.makeTarget }}
131131
fi
132+
- bash: |
133+
set -uo pipefail
134+
artifact_dir="$(Build.ArtifactStagingDirectory)/backend-logs"
135+
mkdir -p "$artifact_dir"
136+
137+
# ServerLauncher writes the backend log to tempfile.gettempdir(), which honours
138+
# TMPDIR/TEMP/TMP before falling back to /tmp, so check the agent temp directory too.
139+
for candidate in "${TMPDIR:-}" "${AGENT_TEMPDIRECTORY:-}" /tmp; do
140+
[ -n "$candidate" ] || continue
141+
if [ -f "$candidate/pyrit_backend.log" ]; then
142+
# Only claim success, and only ask for a publish, if the copy actually landed;
143+
# publishing an empty directory would report a log that isn't there.
144+
if cp "$candidate/pyrit_backend.log" "$artifact_dir/pyrit_backend.log"; then
145+
echo "Collected backend log from $candidate"
146+
echo "##vso[task.setvariable variable=backendLogFound]true"
147+
fi
148+
break
149+
fi
150+
done
151+
152+
if [ ! -f "$artifact_dir/pyrit_backend.log" ]; then
153+
echo "No pyrit_backend.log found; this job does not launch a backend."
154+
fi
155+
displayName: "Collect pyrit_backend log"
156+
name: collect_backend_log
157+
condition: always()
158+
- task: PublishPipelineArtifact@1
159+
displayName: "Publish pyrit_backend log"
160+
condition: and(always(), eq(variables['backendLogFound'], 'true'))
161+
inputs:
162+
targetPath: $(Build.ArtifactStagingDirectory)/backend-logs
163+
artifactName: backend-logs-${{ parameters.jobName }}-$(Build.BuildId)
164+
publishLocation: pipeline
132165
- bash: |
133166
rm -f ~/.pyrit/.env ~/.pyrit/.env.local
134167
name: clean_up_env_files

0 commit comments

Comments
 (0)