Skip to content
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

OCPBUGS-19853: improve support for multiarch #813

Merged
merged 3 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ARG DNF_LIST="\
libassuan-devel \
wget \
pigz \
procps-ng \
"

#################################################################################
Expand Down
Binary file added test/e2e/artifacts/oc-mirror-ppc64le-dev.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions test/e2e/configs/imageset-config-oci-mirror-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ mirror:
type: okd
graph: false
operators:
- catalog: oci://DATA_TMP/mirror_oci/oc-mirror-dev
- catalog: oci://DATA_TMP/mirror_oci/OCI_CTLG
packages:
- name: baz
minVersion: 1.0.1
maxVersion: 1.0.1
additionalImages:
- name: quay.io/redhatgov/oc-mirror-dev:bar-v0.1.0
- name: quay.io/OCI_REGISTRY_NAMESPACE/oc-mirror-dev:bar-v0.1.0
4 changes: 2 additions & 2 deletions test/e2e/configs/imageset-config-oci-mirror.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ storageConfig:
path: DATA_TMP
mirror:
operators:
- catalog: oci://DATA_TMP/mirror_oci/oc-mirror-dev
targetCatalog: redhatgov/oc-mirror-dev:test-catalog-latest
- catalog: oci://DATA_TMP/mirror_oci/OCI_CTLG
targetCatalog: OCI_REGISTRY_NAMESPACE/oc-mirror-dev:test-catalog-latest
packages:
- name: baz
minVersion: 1.0.1
Expand Down
21 changes: 18 additions & 3 deletions test/e2e/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,26 @@ PUBLISH_DIFF_DIR="${DATA_TMP}/publish_diff"
REGISTRY_CONN_DIR="${DATA_TMP}/conn"
REGISTRY_DISCONN_DIR="${DATA_TMP}/disconn"
MIRROR_OCI_DIR="${DATA_TMP}/mirror_oci"
OCI_CTLG_PATH="oc-mirror-dev.tgz"

# Enables overriding for specific architecture payloads (arm64,ppc64le,s390x,x86_64)
CATALOGORG="${ENV_CATALOGORG:-skhoury}"
CATALOGNAMESPACE="${ENV_CATALOGNAMESPACE:-skhoury/oc-mirror-dev}"
# The default is the amd64 catalog, otherwise. Architecture specific tests can pass in the correct value.
CATALOG_ID="${ENV_CATALOG_ID:-86fa1b12}"
OCI_REGISTRY_NAMESPACE="${ENV_OCI_REGISTRY_NAMESPACE:-redhatgov}"
# CATALOG_ARCH is used in subsequent tests to check architecture specific images.
CATALOG_ARCH="$(arch | sed 's|aarch64|arm64|g')"
if [ "${CATALOG_ARCH}" == "x86_64" ]
then
OCI_CTLG="oc-mirror-dev"
OCI_CTLG_PATH="oc-mirror-dev.tgz"
else
OCI_CTLG="oc-mirror-${CATALOG_ARCH}-dev"
OCI_CTLG_PATH="oc-mirror-${CATALOG_ARCH}-dev.tgz"
fi

WORKSPACE="oc-mirror-workspace"
CATALOGREGISTRY="quay.io"
CATALOGORG="skhoury"
CATALOGNAMESPACE="skhoury/oc-mirror-dev"
REGISTRY_CONN_PORT=5000
REGISTRY_DISCONN_PORT=5001
METADATA_REGISTRY="localhost.localdomain:$REGISTRY_CONN_PORT"
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/lib/catalog-extract/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"net/http"
"os"
"runtime"
"time"

"github.com/google/go-containerregistry/pkg/authn"
Expand Down Expand Up @@ -47,6 +48,12 @@ func getCraneOpts(ctx context.Context, insecure bool) []crane.Option {
if insecure {
opts = append(opts, crane.Insecure)
}
// The test catalogs are multi-arch capable
platform := v1.Platform{
Architecture: runtime.GOARCH,
OS: runtime.GOOS,
}
opts = append(opts, crane.WithPlatform(&platform))
return opts
}

Expand Down
5 changes: 3 additions & 2 deletions test/e2e/lib/check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ function check_bundles() {
# check_images_exists ensures the image(s) is found and pullable.
function check_image_exists() {
local expected_image="${1:?expected image required}"
if ! crane digest --insecure $expected_image; then
local exists_arch="${2:-${CATALOG_ARCH}}"
if ! crane digest --insecure --platform linux/${exists_arch} $expected_image; then
echo "image $expected_image not pushed to registry"
return 1
fi
Expand All @@ -110,7 +111,7 @@ function check_sequence_number() {
function check_image_removed() {
local removed_image="${1:?removed image required}"
set -e
output=$(crane digest --insecure $removed_image 2>&1) && returncode=$? || returncode=$?
output=$(crane digest --platform linux/${CATALOG_ARCH} --insecure $removed_image 2>&1) && returncode=$? || returncode=$?
if [[ $returncode != 1 ]]; then
echo "image $removed_image still exists in registry"
return 1
Expand Down
22 changes: 15 additions & 7 deletions test/e2e/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,15 @@ function setup_reg() {
# prep_registry will copy the needed catalog image
# to the connected registry
function prep_registry() {
local CATALOGTAG="${1:?CATALOGTAG required}"
local CATALOGTAG="${1:?CATALOGTAG required}"
# Copy target catalog to connected registry
crane copy --insecure ${CATALOGREGISTRY}/${CATALOGNAMESPACE}:${CATALOGTAG} \
crane copy --insecure ${CATALOGREGISTRY}/${CATALOGNAMESPACE}:${CATALOGTAG} \
--platform linux/${CATALOG_ARCH} \
localhost.localdomain:${REGISTRY_CONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest

CATALOGDIGEST=$(crane digest --insecure localhost.localdomain:${REGISTRY_CONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest)
CATALOGDIGEST=$(crane digest --insecure --platform linux/${CATALOG_ARCH} localhost.localdomain:${REGISTRY_CONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest)
}



# parse_args will parse common arguments
# for each workflow function
function parse_args() {
Expand Down Expand Up @@ -186,6 +185,8 @@ function setup_operator_testdata() {
find "$DATA_DIR" -type f -exec sed -i -E 's@TARGET_CATALOG_TAG@'"$TARGET_CATALOG_TAG"'@g' {} \;
find "$DATA_DIR" -type f -exec sed -i -E 's@DATA_TMP@'"$DATA_DIR"'@g' {} \;
find "$DATA_DIR" -type f -exec sed -i -E 's@MIRROR_OCI_DIR@'"$MIRROR_OCI_DIR"'@g' {} \;
find "$DATA_DIR" -type f -exec sed -i -E 's@OCI_REGISTRY_NAMESPACE@'"$OCI_REGISTRY_NAMESPACE"'@g' {} \;
find "$DATA_DIR" -type f -exec sed -i -E 's@CATALOG_ARCH@'"$CATALOG_ARCH"'@g' {} \;
}

# setup_helm_testdata will move required
Expand Down Expand Up @@ -215,7 +216,12 @@ function setup_helm_repository_testdata() {
export HELM_REPOSITORY_CACHE=$DATA_DIR
echo -e "\nSetting up test directory in $DATA_DIR"
mkdir -p "$OUTPUT_DIR"
curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest/helm-linux-amd64 -o ./helm
if [ "${CATALOG_ARCH}" == "x86_64" ]
then
curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest/helm-linux-amd64 -o ./helm
else
curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest/helm-linux-${CATALOG_ARCH} -o ./helm
fi
chmod +x ./helm
./helm repo add sbo https://redhat-developer.github.io/service-binding-operator-helm-chart/
cp "${DIR}/configs/${CONFIG_PATH}" "${OUTPUT_DIR}/"
Expand All @@ -241,6 +247,8 @@ function prepare_mirror_testdata() {
find "$DATA_DIR" -type f -exec sed -i -E 's@TARGET_CATALOG_TAG@'"$TARGET_CATALOG_TAG"'@g' {} \;
find "$DATA_DIR" -type f -exec sed -i -E 's@DATA_TMP@'"$DATA_DIR"'@g' {} \;
find "$DATA_DIR" -type f -exec sed -i -E 's@MIRROR_OCI_DIR@'"$MIRROR_OCI_DIR"'@g' {} \;
find "$DATA_DIR" -type f -exec sed -i -E 's@OCI_REGISTRY_NAMESPACE@'"$OCI_REGISTRY_NAMESPACE"'@g' {} \;
find "$DATA_DIR" -type f -exec sed -i -E 's@OCI_CTLG@'"$OCI_CTLG"'@g' {} \;
}

function prepare_oci_testdata() {
Expand All @@ -249,4 +257,4 @@ function prepare_oci_testdata() {
tar xfz "${DIR}/artifacts/${OCI_CTLG_PATH}" -C "${DATA_DIR}/mirror_oci"
mkdir -p "olm_artifacts/oc-mirror-dev"
cp -r "${DIR}/artifacts/configs" "olm_artifacts/oc-mirror-dev/"
}
}
26 changes: 13 additions & 13 deletions test/e2e/testcases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ function pruned_catalogs() {
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest \
"bar.v0.1.0 foo.v0.1.1" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:86fa1b12"
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:${CATALOG_ID}"

workflow_diff imageset-config-headsonly.yaml "test-catalog-prune-diff" -c="--source-use-http --source-skip-tls"
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest \
"bar.v0.1.0 foo.v0.2.0" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
check_image_removed "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:86fa1b12"
check_image_removed "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:${CATALOG_ID}"
}

# Test heads-only mode with catalogs that prune with a custom target
Expand All @@ -96,13 +96,13 @@ function pruned_catalogs_with_target() {
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGORG}/${TARGET_CATALOG_NAME}:${TARGET_CATALOG_TAG} \
"bar.v0.1.0 foo.v0.1.1" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:86fa1b12"
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:${CATALOG_ID}"

workflow_diff imageset-config-headsonly-newtarget.yaml "test-catalog-prune-diff" -c="--source-use-http --source-skip-tls"
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGORG}/${TARGET_CATALOG_NAME}:${TARGET_CATALOG_TAG} \
"bar.v0.1.0 foo.v0.2.0" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
check_image_removed "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:86fa1b12"
check_image_removed "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:${CATALOG_ID}"
}

# Test heads-only mode with catalogs that prune bundles
Expand All @@ -111,13 +111,13 @@ function pruned_catalogs_with_include() {
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest \
"bar.v0.1.0 foo.v0.1.1" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:86fa1b12"
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:${CATALOG_ID}"

workflow_diff imageset-config-filter-multi-prune.yaml "test-catalog-prune-diff" -c="--source-use-http --source-skip-tls"
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest \
"bar.v0.1.0 foo.v0.2.0" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
check_image_removed "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:86fa1b12"
check_image_removed "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:${CATALOG_ID}"
}

# Test heads-only mode with catalogs that prune bundles
Expand All @@ -126,13 +126,13 @@ function pruned_catalogs_mirror_to_mirror() {
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest \
"bar.v0.1.0 foo.v0.1.1" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:86fa1b12"
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:${CATALOG_ID}"

workflow_mirror2mirror imageset-config-headsonly.yaml "test-catalog-prune-diff" -c="--source-use-http --source-skip-tls"
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:test-catalog-latest \
"bar.v0.1.0 foo.v0.2.0" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
check_image_removed "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:86fa1b12"
check_image_removed "localhost.localdomain:${REGISTRY_DISCONN_PORT}/${CATALOGNAMESPACE}:${CATALOG_ID}"
}

# Test registry backend
Expand Down Expand Up @@ -228,7 +228,7 @@ function skip_deps {
# Test local helm chart
function helm_local {
workflow_helm imageset-config-helm.yaml podinfo-6.0.0.tgz
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/stefanprodan/podinfo:6.0.0"
check_image_exists "localhost.localdomain:${REGISTRY_DISCONN_PORT}/stefanprodan/podinfo:6.0.0" "amd64"
}


Expand Down Expand Up @@ -256,7 +256,7 @@ function no_updates_exist {
function m2m_oci_catalog {
rm -fr olm_artifacts
workflow_m2m_oci_catalog imageset-config-oci-mirror.yaml "docker://localhost.localdomain:${REGISTRY_DISCONN_PORT}" -c="--dest-skip-tls --oci-insecure-signature-policy"
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/redhatgov/oc-mirror-dev:test-catalog-latest \
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${OCI_REGISTRY_NAMESPACE}/oc-mirror-dev:test-catalog-latest \
"baz.v1.0.1" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
}
Expand All @@ -279,7 +279,7 @@ function m2m_release_with_oci_catalog {
workflow_oci_mirror_all imageset-config-oci-mirror-all.yaml "docker://localhost.localdomain:${REGISTRY_DISCONN_PORT}/test-catalog-latest" -c="--dest-skip-tls --oci-insecure-signature-policy"

# use crane digest to verify
crane digest --insecure localhost.localdomain:${REGISTRY_DISCONN_PORT}/test-catalog-latest/redhatgov/oc-mirror-dev:bar-v0.1.0
crane digest --insecure localhost.localdomain:${REGISTRY_DISCONN_PORT}/test-catalog-latest/${OCI_REGISTRY_NAMESPACE}/oc-mirror-dev:bar-v0.1.0
crane digest --insecure localhost.localdomain:${REGISTRY_DISCONN_PORT}/test-catalog-latest/openshift/release-images:alpine-x86_64
crane digest --insecure localhost.localdomain:${REGISTRY_DISCONN_PORT}/test-catalog-latest/openshift/release:alpine-x86_64-alpime

Expand All @@ -294,7 +294,7 @@ function m2m_release_with_oci_catalog {
function m2d2m_oci_catalog() {
rm -fr olm_artifacts
workflow_m2d2m_oci_catalog imageset-config-oci-mirror.yaml "localhost.localdomain:${REGISTRY_DISCONN_PORT}" -c="--source-use-http --source-skip-tls"
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/redhatgov/oc-mirror-dev:test-catalog-latest \
check_bundles localhost.localdomain:${REGISTRY_DISCONN_PORT}/${OCI_REGISTRY_NAMESPACE}/oc-mirror-dev:test-catalog-latest \
"baz.v1.0.1" \
localhost.localdomain:${REGISTRY_DISCONN_PORT}
}
}