Skip to content

test/system: Ensure that the local temporary Docker registry is ready#1817

Open
debarshiray wants to merge 1 commit into
containers:mainfrom
debarshiray:wip/rishi/test-system-libs-helpers-ensure-docker-registry-is-ready
Open

test/system: Ensure that the local temporary Docker registry is ready#1817
debarshiray wants to merge 1 commit into
containers:mainfrom
debarshiray:wip/rishi/test-system-libs-helpers-ensure-docker-registry-is-ready

Conversation

@debarshiray

Copy link
Copy Markdown
Member

... before proceeding to avoid potential races.

Some changes by Debarshi Ray.

#1811

... before proceeding to avoid potential races.

Some changes by Debarshi Ray.

containers#1811
containers#1817

Signed-off-by: Rolv Apneseth <rolv.apneseth@gmail.com>
@debarshiray debarshiray force-pushed the wip/rishi/test-system-libs-helpers-ensure-docker-registry-is-ready branch from d484a38 to fd7a49d Compare July 6, 2026 00:32

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new helper function _wait_for_docker_registry to wait for the local Docker registry to become ready before attempting to log in. The review feedback suggests executing this helper function using BATS' run and assert_success for consistent error handling, and simplifying the double subshell redirection used to capture stderr from the openssl command.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

"${IMAGES[docker-reg]}"
assert_success

_wait_for_docker_registry

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To ensure robust error handling and maintain consistency with the rest of the _setup_docker_registry function (where all commands are executed using BATS' run and verified with assert_success), we should execute _wait_for_docker_registry using run and assert its success. This guarantees that if the registry fails to reach a ready state, the test suite setup will fail immediately and cleanly with a clear error report.

  run _wait_for_docker_registry
  assert_success

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional.

First, using only run and assert_success is an anti-pattern. We shouldn't be doing that.

Second, until recently run --separate-stderr didn't work or had undefined behaviour inside setup_suite() because BATS_TEST_TMPDIR isn't defined. Using run in this function used in setup_suite() takes us closer to using some feature of run that doesn't work.

Comment on lines +237 to +239
error_details="$( (timeout 5s openssl s_client \
-CAfile "$DOCKER_REG_CERTS_DIR/domain.crt" \
-connect "$DOCKER_REG_URI" </dev/null >/dev/null) 2>&1)" || ret_val="$?"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The double subshell ( ... ) used to capture only stderr can be simplified by using standard redirection order 2>&1 >/dev/null. This avoids spawning an extra subshell process while achieving the exact same result.

    error_details="$(timeout 5s openssl s_client \
                                    -CAfile "$DOCKER_REG_CERTS_DIR/domain.crt" \
                                    -connect "$DOCKER_REG_URI" </dev/null 2>&1 >/dev/null)" || ret_val="$?"

@Rolv-Apneseth Rolv-Apneseth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very minor suggestions but LGTM

-CAfile "$DOCKER_REG_CERTS_DIR/domain.crt" \
-connect "$DOCKER_REG_URI" </dev/null >/dev/null) 2>&1)" || ret_val="$?"

if [ "$ret_val" -eq 0 ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this is a little easier to read as a case statement? Something like

case "$ret_val" in
  0)
    break
    ;;
  125)
    error_message="timeout(1) failed"
    break
    ;;
  126)
    error_message="Failed to invoke openssl(1) or timeout(1)"
    break
    ;;
  127)
    error_message="openssl(1) not found"
    break
    ;;
  137)
    error_message="SIGKILL received by openssl(1) or timeout(1)"
    break
    ;;
esac

WDYT?

local error_details
local error_message
local -i j
local -i num_of_retries=30

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be max_retries, and j could be just retries or num_retries?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants