-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts to validate a release package (#626)
* Add scripts to validate a release package Signed-off-by: Alessandro Passaro <[email protected]> * Set executable bit Signed-off-by: Alessandro Passaro <[email protected]> * Add minimal readme Signed-off-by: Alessandro Passaro <[email protected]> --------- Signed-off-by: Alessandro Passaro <[email protected]>
- Loading branch information
Showing
6 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,9 @@ | ||
# Validation of a Release Package | ||
|
||
The scripts in this directory can be used to validate the artifacts for a released version of Mountpoint. | ||
|
||
The `validate.py` python script validates the RPM and DEB packages and the gzip archive for the given Mountpoint release. The script runs a docker container for the specified OS, downloads the Mountpoint package, verifies its signature, and proceeds to installs it. Then, it will use the installed binary to mount the specified bucket and list its content. | ||
|
||
To see the available options, run: | ||
|
||
python3 validate.py --help |
This file contains 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,12 @@ | ||
#! /bin/sh | ||
set -e | ||
|
||
echo | ||
echo "Show installed version:" | ||
mount-s3 --version | ||
|
||
echo | ||
echo "Mount and list top-level content of bucket: $BUCKET" | ||
mkdir ~/mnt | ||
mount-s3 "$BUCKET" ~/mnt --no-sign-request | ||
ls ~/mnt |
This file contains 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,16 @@ | ||
#! /bin/sh | ||
set -e | ||
|
||
apt-get -qq update -y && apt-get -qq install -y wget gpg | ||
cd /tmp | ||
|
||
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.deb | ||
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.deb.asc | ||
|
||
wget https://s3.amazonaws.com/mountpoint-s3-release/public_keys/KEYS | ||
gpg --import KEYS | ||
gpg --verify mount-s3-$VERSION-$ARCH.deb.asc mount-s3-$VERSION-$ARCH.deb | ||
|
||
apt-get install -y ./mount-s3-$VERSION-$ARCH.deb | ||
|
||
. $(dirname "$0")/test-mount-s3.sh |
This file contains 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,19 @@ | ||
#! /bin/sh | ||
set -e | ||
|
||
yum update -y && yum install -y wget gpg tar gzip | ||
cd /tmp | ||
|
||
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.tar.gz | ||
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.tar.gz.asc | ||
|
||
wget https://s3.amazonaws.com/mountpoint-s3-release/public_keys/KEYS | ||
gpg --import KEYS | ||
gpg --verify mount-s3-$VERSION-$ARCH.tar.gz.asc mount-s3-$VERSION-$ARCH.tar.gz | ||
|
||
tar -zxvf mount-s3-$VERSION-$ARCH.tar.gz | ||
cp bin/mount-s3 /usr/bin/ | ||
# install Mountpoint dependencies manually | ||
yum install -y fuse fuse-devel | ||
|
||
. $(dirname "$0")/test-mount-s3.sh |
This file contains 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,16 @@ | ||
#! /bin/sh | ||
set -e | ||
|
||
yum update -y && yum install -y wget gpg | ||
cd /tmp | ||
|
||
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.rpm | ||
wget https://s3.amazonaws.com/mountpoint-s3-release/$VERSION/$ARCH/mount-s3-$VERSION-$ARCH.rpm.asc | ||
|
||
wget https://s3.amazonaws.com/mountpoint-s3-release/public_keys/KEYS | ||
gpg --import KEYS | ||
gpg --verify mount-s3-$VERSION-$ARCH.rpm.asc mount-s3-$VERSION-$ARCH.rpm | ||
|
||
yum install -y mount-s3-$VERSION-$ARCH.rpm | ||
|
||
. $(dirname "$0")/test-mount-s3.sh |
This file contains 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,60 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
Script for validating a Mountpoint release package. | ||
This script validates the RPM and DEB packages and the gzip archive built for a Mountpoint release. | ||
""" | ||
|
||
import argparse | ||
import os | ||
import subprocess | ||
|
||
def validate(args: argparse.Namespace) -> str: | ||
"""Top-level driver.""" | ||
|
||
package=f"{args.artifact}-{args.os}" | ||
if package == "deb-ubuntu": | ||
image = "ubuntu/ubuntu:20.04" | ||
elif package == "rpm-al2" or package == "gzip-al2": | ||
image = "amazonlinux/amazonlinux:2" | ||
else: | ||
raise Exception(f"unsupported OS {args.os} for {args.artifact}. Supported combinations are: deb-ubuntu, rpm-al2, gzip-al2") | ||
|
||
print("Validating Mountpoint Release Package") | ||
print(f"\tVersion: {args.version}") | ||
print(f"\tArch: {args.arch}") | ||
print(f"\tOS: {args.os}") | ||
print(f"\tArtifact: {args.artifact}") | ||
print(f"\tBucket: {args.bucket}") | ||
print("\n") | ||
|
||
full_image = f"public.ecr.aws/{image}" | ||
validate_script = f"validate-{package}.sh" | ||
scripts_dir = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
subprocess.run(["docker", "pull", full_image]) | ||
subprocess.run(["docker", | ||
"run", | ||
"--rm", | ||
"--cap-add=SYS_ADMIN", | ||
"--device=/dev/fuse", | ||
f"-v={scripts_dir}:/scripts", | ||
f"--env=ARCH={args.arch}", | ||
f"--env=VERSION={args.version}", | ||
f"--env=BUCKET={args.bucket}", | ||
full_image, | ||
"/bin/bash", | ||
f"/scripts/{validate_script}"]) | ||
|
||
if __name__ == "__main__": | ||
p = argparse.ArgumentParser() | ||
p.add_argument("--version", help="the version number for the Mountpoint release", required=True) | ||
p.add_argument("--arch", help="the architecture to validate", required=True, choices=["x86_64", "arm64"]) | ||
p.add_argument("--artifact", help="the artifact to validate", required=True, choices=["deb", "rpm", "gzip"]) | ||
p.add_argument("--os", help="the OS to validate on", required=True, choices=["ubuntu", "al2"]) | ||
p.add_argument("--bucket", help="the public bucket to mount", required=True) | ||
|
||
args = p.parse_args() | ||
|
||
validate(args) |