diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash index 84aab2ad5..f2f527d17 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash @@ -31,8 +31,12 @@ readonly ROOTLESS_PODMAN_RUNROOT_DIR="$BATS_SUITE_TMPDIR/runroot" readonly DOCKER_REG_ROOT="$BATS_SUITE_TMPDIR/docker-registry-root" readonly DOCKER_REG_CERTS_DIR="$BATS_SUITE_TMPDIR/certs" readonly DOCKER_REG_AUTH_DIR="$BATS_SUITE_TMPDIR/auth" -readonly DOCKER_REG_URI="localhost:50000" readonly DOCKER_REG_NAME="docker-registry" +# Store the registry URI in a file so that loading this script from different +# test processes will still use the same URI for the same test suite run. The +# contents of the file are set when setting up the local Docker registry. +readonly DOCKER_REG_URI_FILE="$BATS_SUITE_TMPDIR/docker-reg-uri" +DOCKER_REG_URI="$(cat "$DOCKER_REG_URI_FILE" 2>/dev/null || true)" # Podman and Toolbx commands to run readonly TOOLBX="${TOOLBX:-$(command -v toolbox)}" @@ -163,10 +167,6 @@ function _setup_docker_registry() { -subj '/' \ -out "${DOCKER_REG_CERTS_DIR}"/domain.crt - # Add certificate to Podman's trusted certificates (rootless) - mkdir --parents "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}" - cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt - # Create a registry user # username: user; password: user mkdir --parents "${DOCKER_REG_AUTH_DIR}" @@ -188,18 +188,28 @@ function _setup_docker_registry() { --env REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ --name "${DOCKER_REG_NAME}" \ --privileged \ - --publish 50000:5000 \ + --publish 5000 \ --rm \ --volume "${DOCKER_REG_AUTH_DIR}":/auth \ --volume "${DOCKER_REG_CERTS_DIR}":/certs \ "${IMAGES[docker-reg]}" + # Determine the randomly assigned host port and persist the DOCKER_REG_URI to a file + local docker_reg_port + docker_reg_port="$(podman --root "${DOCKER_REG_ROOT}" port "${DOCKER_REG_NAME}" 5000)" + DOCKER_REG_URI="localhost:${docker_reg_port##*:}" + echo "$DOCKER_REG_URI" > "$DOCKER_REG_URI_FILE" + + # Add certificate to Podman's trusted certificates (rootless) + mkdir --parents "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}" + cp "${DOCKER_REG_CERTS_DIR}"/domain.crt "$HOME"/.config/containers/certs.d/"${DOCKER_REG_URI}"/domain.crt + _wait_for_docker_registry podman login --authfile "${BATS_SUITE_TMPDIR}/authfile.json" --username user --password user "${DOCKER_REG_URI}" # Add fedora-toolbox:34 image to the registry - skopeo --command-timeout 60s copy \ + skopeo --command-timeout 120s copy \ --dest-authfile "${BATS_SUITE_TMPDIR}/authfile.json" \ dir:"${IMAGE_CACHE_DIR}"/fedora-toolbox-34 \ docker://"${DOCKER_REG_URI}"/fedora-toolbox:34 @@ -371,7 +381,7 @@ function pull_distro_image() { fi # https://github.com/containers/skopeo/issues/547 for the options for containers-storage - run skopeo --command-timeout 60s copy \ + run skopeo --command-timeout 120s copy \ "dir:${IMAGE_CACHE_DIR}/${image_archive}" \ "containers-storage:[overlay@$TOOLBX_ROOTLESS_STORAGE_PATH+$TOOLBX_ROOTLESS_STORAGE_PATH]${image}" @@ -405,7 +415,7 @@ function pull_default_image_and_copy() { image="${IMAGES[$distro]}:$version" # https://github.com/containers/skopeo/issues/547 for the options for containers-storage - run skopeo --command-timeout 60s copy \ + run skopeo --command-timeout 120s copy \ "containers-storage:[overlay@$TOOLBX_ROOTLESS_STORAGE_PATH+$TOOLBX_ROOTLESS_STORAGE_PATH]$image" \ "containers-storage:[overlay@$TOOLBX_ROOTLESS_STORAGE_PATH+$TOOLBX_ROOTLESS_STORAGE_PATH]$image-copy"