From 9285b7c9fea97de5c0a8463bbc19d89f15eaf0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Wed, 14 Sep 2022 17:52:15 +0200 Subject: [PATCH] test/cases/api/aws.s3.sh: delete duplicate functions The `verifyEdgeCommit()` and `verifyDisk()` functions are already defined in the `test/cases/api/common/s3.sh` file sourced by `test/cases/api/aws.s3.sh`. --- test/cases/api/aws.s3.sh | 71 ------------------------------------- test/cases/api/common/s3.sh | 3 ++ 2 files changed, 3 insertions(+), 71 deletions(-) diff --git a/test/cases/api/aws.s3.sh b/test/cases/api/aws.s3.sh index bb8205656..922820c2d 100644 --- a/test/cases/api/aws.s3.sh +++ b/test/cases/api/aws.s3.sh @@ -13,9 +13,6 @@ function checkEnv() { fi } -# Global var for ostree ref -OSTREE_REF="test/rhel/8/edge" - function cleanup() { local S3_URL S3_URL=$(echo "$UPLOAD_OPTIONS" | jq -r '.url') @@ -62,74 +59,6 @@ function checkUploadStatusOptions() { echo "$S3_URL" | grep -F "$AWS_REGION" - } - -# verify edge commit content -function verifyEdgeCommit() { - filename="$1" - greenprint "Verifying contents of ${filename}" - - # extract tarball and save file list to artifacts directroy - local COMMIT_DIR - COMMIT_DIR="${WORKDIR}/edge-commit" - mkdir -p "${COMMIT_DIR}" - tar xvf "${filename}" -C "${COMMIT_DIR}" > "${ARTIFACTS}/edge-commit-filelist.txt" - - # Verify that the commit contains the ref we defined in the request - sudo dnf install -y ostree - local COMMIT_REF - COMMIT_REF=$(ostree refs --repo "${COMMIT_DIR}/repo") - if [[ "${COMMIT_REF}" != "${OSTREE_REF}" ]]; then - echo "Commit ref in archive does not match request 😠" - exit 1 - fi - - local TAR_COMMIT_ID - TAR_COMMIT_ID=$(ostree rev-parse --repo "${COMMIT_DIR}/repo" "${OSTREE_REF}") - API_COMMIT_ID_V2=$(curl \ - --silent \ - --show-error \ - --cacert /etc/osbuild-composer/ca-crt.pem \ - --key /etc/osbuild-composer/client-key.pem \ - --cert /etc/osbuild-composer/client-crt.pem \ - https://localhost/api/image-builder-composer/v2/composes/"$COMPOSE_ID"/metadata | jq -r '.ostree_commit') - - if [[ "${API_COMMIT_ID_V2}" != "${TAR_COMMIT_ID}" ]]; then - echo "Commit ID returned from API does not match Commit ID in archive 😠" - exit 1 - fi - -} - -# Verify image blobs from s3 -function verifyDisk() { - filename="$1" - greenprint "Verifying contents of ${filename}" - - infofile="${filename}-info.json" - sudo /usr/libexec/osbuild-composer-test/image-info "${filename}" | tee "${infofile}" > /dev/null - - # save image info to artifacts - cp -v "${infofile}" "${ARTIFACTS}/image-info.json" - - # check compose request users in passwd - if ! jq .passwd "${infofile}" | grep -q "user1"; then - greenprint "❌ user1 not found in passwd file" - exit 1 - fi - if ! jq .passwd "${infofile}" | grep -q "user2"; then - greenprint "❌ user2 not found in passwd file" - exit 1 - fi - # check packages for postgresql - if ! jq .packages "${infofile}" | grep -q "postgresql"; then - greenprint "❌ postgresql not found in packages" - exit 1 - fi - - greenprint "✅ ${filename} image info verified" -} - - # Verify s3 blobs function verify() { local S3_URL diff --git a/test/cases/api/common/s3.sh b/test/cases/api/common/s3.sh index d37f6fda3..575ae7c43 100644 --- a/test/cases/api/common/s3.sh +++ b/test/cases/api/common/s3.sh @@ -2,6 +2,9 @@ source /usr/libexec/tests/osbuild-composer/shared_lib.sh +# Global var for ostree ref +OSTREE_REF="test/rhel/8/edge" + function createReqFileEdge() { cat > "$REQUEST_FILE" << EOF {