-
Notifications
You must be signed in to change notification settings - Fork 226
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
Open
tmckayus
wants to merge
2
commits into
NVIDIA:main
Choose a base branch
from
tmckayus:smokeimages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+150
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| #!/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="" | ||
|
|
||
| smoke_fail() { | ||
| printf 'FAIL %s\n' "$*" >&2 | ||
| } | ||
|
|
||
| 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. | ||
| if ! cid="$(docker run -d --name "${name}" "${GPU_ARGS[@]}" "$@" "${IMAGE}")"; then | ||
| smoke_fail "${label}: docker run failed" | ||
| return 1 | ||
| fi | ||
|
|
||
| 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}" | ||
| smoke_fail "${label}: loader/crypto failure while starting" | ||
| return 1 | ||
| 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}" | ||
| smoke_fail "${label}: container exited before becoming ready" | ||
| return 1 | ||
| fi | ||
|
|
||
| sleep 1 | ||
| done | ||
|
|
||
| echo "----- ${label} logs -----" | ||
| cat "${log}" | ||
| smoke_fail "${label}: timed out after ${TIMEOUT_SECS}s waiting for /${expect_re}/" | ||
| return 1 | ||
| } | ||
|
|
||
| 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}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.