-
Notifications
You must be signed in to change notification settings - Fork 218
add a smoke test to ensure server images start correctly #1646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/usr/bin/env bash | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Smoke-test that a published cuOpt image starts its default REST server and | ||
| # the gRPC server via CUOPT_SERVER_TYPE=grpc. Runs on the host with docker so | ||
| # the real ENTRYPOINT/CMD path is exercised (unlike test_image.sh, which runs | ||
| # inside a GHA job container and never launches the servers). | ||
| # | ||
| # Usage (any published or locally built tag): | ||
| # ./ci/docker/smoke_image.sh nvidia/cuopt:[TAG] | ||
| # ./ci/docker/smoke_image.sh nvidia/cuopt:[TAG]-ubi10 | ||
| # | ||
| # Env: | ||
| # SMOKE_TIMEOUT_SECS Max seconds to wait for listen (default: 90) | ||
| # SMOKE_GPU_ARGS Docker GPU flags (default: --gpus all) | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| IMAGE="${1:?usage: $0 <image>}" | ||
| TIMEOUT_SECS="${SMOKE_TIMEOUT_SECS:-90}" | ||
| # shellcheck disable=SC2206 | ||
| GPU_ARGS=(${SMOKE_GPU_ARGS:---gpus all}) | ||
|
|
||
| pass() { printf 'PASS %s\n' "$*"; } | ||
| fail() { printf 'FAIL %s\n' "$*" >&2; exit 1; } | ||
| info() { printf 'INFO %s\n' "$*"; } | ||
|
|
||
| smoke_one() { | ||
| local label="$1" | ||
| local expect_re="$2" | ||
| shift 2 | ||
| # Remaining args are extra docker run flags (e.g. -e CUOPT_SERVER_TYPE=grpc). | ||
|
|
||
| local name log cid i | ||
| name="cuopt-smoke-${label}-$$" | ||
| log="$(mktemp)" | ||
| cid="" | ||
|
|
||
| cleanup() { | ||
| if [[ -n "${cid}" ]]; then | ||
| docker rm -f "${cid}" >/dev/null 2>&1 || true | ||
| fi | ||
| rm -f "${log}" | ||
| } | ||
| trap cleanup RETURN | ||
|
|
||
| info "Starting ${label} server from ${IMAGE}" | ||
| # Do not use --rm: a fast crash (e.g. missing libnccl.so.2) would delete the | ||
| # container before we can collect logs. | ||
| cid="$(docker run -d --name "${name}" "${GPU_ARGS[@]}" "$@" "${IMAGE}")" | ||
|
|
||
| for ((i = 1; i <= TIMEOUT_SECS; i++)); do | ||
| docker logs "${cid}" >"${log}" 2>&1 || true | ||
|
|
||
| if grep -qiE 'error while loading shared libraries|libnccl\.so|FATAL FIPS SELFTEST|OpenSSL internal error' "${log}"; then | ||
| echo "----- ${label} logs -----" | ||
| cat "${log}" | ||
| fail "${label}: loader/crypto failure while starting" | ||
| fi | ||
|
|
||
| if grep -qE "${expect_re}" "${log}"; then | ||
| pass "${label}: matched /${expect_re}/" | ||
| return 0 | ||
| fi | ||
|
|
||
| # Container exited before listen — dump logs and fail. | ||
| if ! docker inspect -f '{{.State.Running}}' "${cid}" 2>/dev/null | grep -qx true; then | ||
| echo "----- ${label} logs -----" | ||
| cat "${log}" | ||
| fail "${label}: container exited before becoming ready" | ||
| fi | ||
|
|
||
| sleep 1 | ||
| done | ||
|
|
||
| echo "----- ${label} logs -----" | ||
| cat "${log}" | ||
| fail "${label}: timed out after ${TIMEOUT_SECS}s waiting for /${expect_re}/" | ||
|
Comment on lines
+40
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Run cleanup when a smoke test fails.
Return a nonzero status from 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| info "Pulling ${IMAGE}" | ||
| if ! docker pull "${IMAGE}"; then | ||
| if docker image inspect "${IMAGE}" >/dev/null 2>&1; then | ||
| info "Pull failed; using local image ${IMAGE}" | ||
| else | ||
| fail "Pull failed and no local image named ${IMAGE}" | ||
| fi | ||
| fi | ||
|
|
||
| smoke_one rest 'Uvicorn running on' | ||
| smoke_one grpc 'Listening on' -e CUOPT_SERVER_TYPE=grpc | ||
|
|
||
| pass "Smoke OK for ${IMAGE}" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we add the test script as part of test_image.sh ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't put this in test_image.sh as wired today — that job runs inside the image as a GHA container, so it never exercises ENTRYPOINT/CMD, and it already patches LD_LIBRARY_PATH for the nvidia wheels (which is what masked the UBI10 NCCL packaging bug). The smoke test has to be host-side docker run.
The bug we hit was invoking the ubi10 image with just a docker command, as a user would.