mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 15:31:15 +00:00
scripts: Improve AArch64 CI for parallel executors
Lock "work_loads" folder when one job is syncing files. If another job arrives, wait until the lock is released. Signed-off-by: Michael Zhao <michael.zhao@arm.com>
This commit is contained in:
parent
12c5b7668a
commit
7e3cbf04de
@ -6,74 +6,77 @@ source $HOME/.cargo/env
|
|||||||
export BUILD_TARGET=${BUILD_TARGET-aarch64-unknown-linux-gnu}
|
export BUILD_TARGET=${BUILD_TARGET-aarch64-unknown-linux-gnu}
|
||||||
|
|
||||||
WORKLOADS_DIR="$HOME/workloads"
|
WORKLOADS_DIR="$HOME/workloads"
|
||||||
|
WORKLOADS_LOCK="$WORKLOADS_DIR/integration_test.lock"
|
||||||
|
|
||||||
mkdir -p "$WORKLOADS_DIR"
|
mkdir -p "$WORKLOADS_DIR"
|
||||||
|
|
||||||
cp scripts/sha1sums-aarch64 $WORKLOADS_DIR
|
update_workloads() {
|
||||||
|
cp scripts/sha1sums-aarch64 $WORKLOADS_DIR
|
||||||
|
|
||||||
BIONIC_OS_IMAGE_DOWNLOAD_NAME="bionic-server-cloudimg-arm64.img" \
|
BIONIC_OS_IMAGE_DOWNLOAD_NAME="bionic-server-cloudimg-arm64.img"
|
||||||
BIONIC_OS_IMAGE_DOWNLOAD_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$BIONIC_OS_IMAGE_DOWNLOAD_NAME"
|
BIONIC_OS_IMAGE_DOWNLOAD_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$BIONIC_OS_IMAGE_DOWNLOAD_NAME"
|
||||||
BIONIC_OS_DOWNLOAD_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_IMAGE_DOWNLOAD_NAME"
|
BIONIC_OS_DOWNLOAD_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_IMAGE_DOWNLOAD_NAME"
|
||||||
if [ ! -f "$BIONIC_OS_DOWNLOAD_IMAGE" ]; then
|
if [ ! -f "$BIONIC_OS_DOWNLOAD_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
time wget --quiet $BIONIC_OS_IMAGE_DOWNLOAD_URL || exit 1
|
time wget --quiet $BIONIC_OS_IMAGE_DOWNLOAD_URL || exit 1
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BIONIC_OS_RAW_IMAGE_NAME="bionic-server-cloudimg-arm64.raw" \
|
BIONIC_OS_RAW_IMAGE_NAME="bionic-server-cloudimg-arm64.raw"
|
||||||
BIONIC_OS_RAW_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_RAW_IMAGE_NAME"
|
BIONIC_OS_RAW_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_RAW_IMAGE_NAME"
|
||||||
if [ ! -f "$BIONIC_OS_RAW_IMAGE" ]; then
|
if [ ! -f "$BIONIC_OS_RAW_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
time qemu-img convert -p -f qcow2 -O raw $BIONIC_OS_IMAGE_DOWNLOAD_NAME $BIONIC_OS_RAW_IMAGE_NAME || exit 1
|
time qemu-img convert -p -f qcow2 -O raw $BIONIC_OS_IMAGE_DOWNLOAD_NAME $BIONIC_OS_RAW_IMAGE_NAME || exit 1
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Convert the raw image to qcow2 image to remove compressed blocks from the disk. Therefore letting the
|
# Convert the raw image to qcow2 image to remove compressed blocks from the disk. Therefore letting the
|
||||||
# qcow2 format image can be directly used in the integration test.
|
# qcow2 format image can be directly used in the integration test.
|
||||||
BIONIC_OS_QCOW2_IMAGE_UNCOMPRESSED_NAME="bionic-server-cloudimg-arm64.qcow2" \
|
BIONIC_OS_QCOW2_IMAGE_UNCOMPRESSED_NAME="bionic-server-cloudimg-arm64.qcow2"
|
||||||
BIONIC_OS_QCOW2_UNCOMPRESSED_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_QCOW2_IMAGE_UNCOMPRESSED_NAME"
|
BIONIC_OS_QCOW2_UNCOMPRESSED_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_QCOW2_IMAGE_UNCOMPRESSED_NAME"
|
||||||
if [ ! -f "$BIONIC_OS_QCOW2_UNCOMPRESSED_IMAGE" ]; then
|
if [ ! -f "$BIONIC_OS_QCOW2_UNCOMPRESSED_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
time qemu-img convert -p -f raw -O qcow2 $BIONIC_OS_RAW_IMAGE_NAME $BIONIC_OS_QCOW2_UNCOMPRESSED_IMAGE || exit 1
|
time qemu-img convert -p -f raw -O qcow2 $BIONIC_OS_RAW_IMAGE_NAME $BIONIC_OS_QCOW2_UNCOMPRESSED_IMAGE || exit 1
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FOCAL_OS_IMAGE_DOWNLOAD_NAME="focal-server-cloudimg-arm64.img" \
|
FOCAL_OS_IMAGE_DOWNLOAD_NAME="focal-server-cloudimg-arm64.img"
|
||||||
FOCAL_OS_IMAGE_DOWNLOAD_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$FOCAL_OS_IMAGE_DOWNLOAD_NAME"
|
FOCAL_OS_IMAGE_DOWNLOAD_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$FOCAL_OS_IMAGE_DOWNLOAD_NAME"
|
||||||
FOCAL_OS_DOWNLOAD_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_DOWNLOAD_NAME"
|
FOCAL_OS_DOWNLOAD_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_DOWNLOAD_NAME"
|
||||||
if [ ! -f "$FOCAL_OS_DOWNLOAD_IMAGE" ]; then
|
if [ ! -f "$FOCAL_OS_DOWNLOAD_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
time wget --quiet $FOCAL_OS_IMAGE_DOWNLOAD_URL || exit 1
|
time wget --quiet $FOCAL_OS_IMAGE_DOWNLOAD_URL || exit 1
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-arm64.raw" \
|
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-arm64.raw"
|
||||||
FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
|
FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
|
||||||
if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then
|
if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_DOWNLOAD_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1
|
time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_DOWNLOAD_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Convert the raw image to qcow2 image to remove compressed blocks from the disk. Therefore letting the
|
# Convert the raw image to qcow2 image to remove compressed blocks from the disk. Therefore letting the
|
||||||
# qcow2 format image can be directly used in the integration test.
|
# qcow2 format image can be directly used in the integration test.
|
||||||
FOCAL_OS_QCOW2_IMAGE_UNCOMPRESSED_NAME="focal-server-cloudimg-arm64.qcow2" \
|
FOCAL_OS_QCOW2_IMAGE_UNCOMPRESSED_NAME="focal-server-cloudimg-arm64.qcow2"
|
||||||
FOCAL_OS_QCOW2_UNCOMPRESSED_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_QCOW2_IMAGE_UNCOMPRESSED_NAME"
|
FOCAL_OS_QCOW2_UNCOMPRESSED_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_QCOW2_IMAGE_UNCOMPRESSED_NAME"
|
||||||
if [ ! -f "$FOCAL_OS_QCOW2_UNCOMPRESSED_IMAGE" ]; then
|
if [ ! -f "$FOCAL_OS_QCOW2_UNCOMPRESSED_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
time qemu-img convert -p -f raw -O qcow2 $FOCAL_OS_RAW_IMAGE_NAME $FOCAL_OS_QCOW2_UNCOMPRESSED_IMAGE || exit 1
|
time qemu-img convert -p -f raw -O qcow2 $FOCAL_OS_RAW_IMAGE_NAME $FOCAL_OS_QCOW2_UNCOMPRESSED_IMAGE || exit 1
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ALPINE_MINIROOTFS_URL="http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/aarch64/alpine-minirootfs-3.11.3-aarch64.tar.gz"
|
ALPINE_MINIROOTFS_URL="http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/aarch64/alpine-minirootfs-3.11.3-aarch64.tar.gz"
|
||||||
ALPINE_MINIROOTFS_TARBALL="$WORKLOADS_DIR/alpine-minirootfs-aarch64.tar.gz"
|
ALPINE_MINIROOTFS_TARBALL="$WORKLOADS_DIR/alpine-minirootfs-aarch64.tar.gz"
|
||||||
if [ ! -f "$ALPINE_MINIROOTFS_TARBALL" ]; then
|
if [ ! -f "$ALPINE_MINIROOTFS_TARBALL" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
time wget --quiet $ALPINE_MINIROOTFS_URL -O $ALPINE_MINIROOTFS_TARBALL || exit 1
|
time wget --quiet $ALPINE_MINIROOTFS_URL -O $ALPINE_MINIROOTFS_TARBALL || exit 1
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ALPINE_INITRAMFS_IMAGE="$WORKLOADS_DIR/alpine_initramfs.img"
|
ALPINE_INITRAMFS_IMAGE="$WORKLOADS_DIR/alpine_initramfs.img"
|
||||||
if [ ! -f "$ALPINE_INITRAMFS_IMAGE" ]; then
|
if [ ! -f "$ALPINE_INITRAMFS_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
mkdir alpine-minirootfs
|
mkdir alpine-minirootfs
|
||||||
tar xf "$ALPINE_MINIROOTFS_TARBALL" -C alpine-minirootfs
|
tar xf "$ALPINE_MINIROOTFS_TARBALL" -C alpine-minirootfs
|
||||||
@ -88,48 +91,46 @@ if [ ! -f "$ALPINE_INITRAMFS_IMAGE" ]; then
|
|||||||
find . -print0 |
|
find . -print0 |
|
||||||
cpio --null --create --verbose --owner root:root --format=newc > "$ALPINE_INITRAMFS_IMAGE"
|
cpio --null --create --verbose --owner root:root --format=newc > "$ALPINE_INITRAMFS_IMAGE"
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
sha1sum sha1sums-aarch64 --check
|
sha1sum sha1sums-aarch64 --check
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "sha1sum validation of images failed, remove invalid images to fix the issue."
|
echo "sha1sum validation of images failed, remove invalid images to fix the issue."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Build custom kernel based on virtio-pmem and virtio-fs upstream patches
|
# Build custom kernel based on virtio-pmem and virtio-fs upstream patches
|
||||||
PE_IMAGE="$WORKLOADS_DIR/Image"
|
PE_IMAGE="$WORKLOADS_DIR/Image"
|
||||||
|
LINUX_CUSTOM_DIR="$WORKLOADS_DIR/linux-custom"
|
||||||
|
|
||||||
LINUX_CUSTOM_DIR="$WORKLOADS_DIR/linux-custom"
|
build_custom_linux_kernel() {
|
||||||
|
|
||||||
build_custom_linux_kernel() {
|
|
||||||
pushd $LINUX_CUSTOM_DIR
|
pushd $LINUX_CUSTOM_DIR
|
||||||
time make -j `nproc`
|
time make -j `nproc`
|
||||||
cp arch/arm64/boot/Image $WORKLOADS_DIR/Image || exit 1
|
cp arch/arm64/boot/Image $WORKLOADS_DIR/Image || exit 1
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -d "$LINUX_CUSTOM_DIR" ]; then
|
if [ ! -d "$LINUX_CUSTOM_DIR" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
time git clone --depth 1 "https://github.com/cloud-hypervisor/linux.git" -b "virtio-fs-virtio-iommu-virtio-mem-5.6-rc4" $LINUX_CUSTOM_DIR
|
time git clone --depth 1 "https://github.com/cloud-hypervisor/linux.git" -b "virtio-fs-virtio-iommu-virtio-mem-5.6-rc4" $LINUX_CUSTOM_DIR
|
||||||
popd
|
popd
|
||||||
|
else
|
||||||
else
|
|
||||||
pushd $LINUX_CUSTOM_DIR
|
pushd $LINUX_CUSTOM_DIR
|
||||||
git fetch
|
git fetch
|
||||||
git checkout -f
|
git checkout -f
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SRCDIR=$PWD
|
SRCDIR=$PWD
|
||||||
cp $SRCDIR/resources/linux-config-aarch64 $LINUX_CUSTOM_DIR/.config
|
cp $SRCDIR/resources/linux-config-aarch64 $LINUX_CUSTOM_DIR/.config
|
||||||
build_custom_linux_kernel
|
build_custom_linux_kernel
|
||||||
|
|
||||||
VIRTIOFSD="$WORKLOADS_DIR/virtiofsd"
|
VIRTIOFSD="$WORKLOADS_DIR/virtiofsd"
|
||||||
QEMU_DIR="qemu_build"
|
QEMU_DIR="qemu_build"
|
||||||
|
|
||||||
if [ ! -f "$VIRTIOFSD" ]; then
|
if [ ! -f "$VIRTIOFSD" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
git clone --depth 1 "https://gitlab.com/virtio-fs/qemu.git" -b "virtio-fs-dev" $QEMU_DIR
|
git clone --depth 1 "https://gitlab.com/virtio-fs/qemu.git" -b "virtio-fs-dev" $QEMU_DIR
|
||||||
pushd $QEMU_DIR
|
pushd $QEMU_DIR
|
||||||
@ -140,11 +141,11 @@ if [ ! -f "$VIRTIOFSD" ]; then
|
|||||||
rm -rf $QEMU_DIR
|
rm -rf $QEMU_DIR
|
||||||
sudo setcap cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_setgid,cap_setuid,cap_mknod,cap_setfcap,cap_sys_admin+epi "virtiofsd" || exit 1
|
sudo setcap cap_chown,cap_dac_override,cap_dac_read_search,cap_fowner,cap_fsetid,cap_setgid,cap_setuid,cap_mknod,cap_setfcap,cap_sys_admin+epi "virtiofsd" || exit 1
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
BLK_IMAGE="$WORKLOADS_DIR/blk.img"
|
BLK_IMAGE="$WORKLOADS_DIR/blk.img"
|
||||||
MNT_DIR="mount_image"
|
MNT_DIR="mount_image"
|
||||||
if [ ! -f "$BLK_IMAGE" ]; then
|
if [ ! -f "$BLK_IMAGE" ]; then
|
||||||
pushd $WORKLOADS_DIR
|
pushd $WORKLOADS_DIR
|
||||||
fallocate -l 16M $BLK_IMAGE
|
fallocate -l 16M $BLK_IMAGE
|
||||||
mkfs.ext4 -j $BLK_IMAGE
|
mkfs.ext4 -j $BLK_IMAGE
|
||||||
@ -154,14 +155,26 @@ if [ ! -f "$BLK_IMAGE" ]; then
|
|||||||
sudo umount $BLK_IMAGE
|
sudo umount $BLK_IMAGE
|
||||||
rm -r $MNT_DIR
|
rm -r $MNT_DIR
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SHARED_DIR="$WORKLOADS_DIR/shared_dir"
|
SHARED_DIR="$WORKLOADS_DIR/shared_dir"
|
||||||
if [ ! -d "$SHARED_DIR" ]; then
|
if [ ! -d "$SHARED_DIR" ]; then
|
||||||
mkdir -p $SHARED_DIR
|
mkdir -p $SHARED_DIR
|
||||||
echo "foo" > "$SHARED_DIR/file1"
|
echo "foo" > "$SHARED_DIR/file1"
|
||||||
echo "bar" > "$SHARED_DIR/file3" || exit 1
|
echo "bar" > "$SHARED_DIR/file3" || exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# lock the workloads folder to avoid parallel updating by different containers
|
||||||
|
(
|
||||||
|
echo "try to lock $WORKLOADS_DIR folder and update"
|
||||||
|
flock -x 12 && update_workloads
|
||||||
|
) 12>$WORKLOADS_LOCK
|
||||||
|
|
||||||
|
# Create tap interface without multipe queues support for vhost_user_net test.
|
||||||
|
sudo ip tuntap add name vunet-tap0 mode tap
|
||||||
|
# Create tap interface with multipe queues support for vhost_user_net test.
|
||||||
|
sudo ip tuntap add name vunet-tap1 mode tap multi_queue
|
||||||
|
|
||||||
BUILD_TARGET="aarch64-unknown-linux-${CH_LIBC}"
|
BUILD_TARGET="aarch64-unknown-linux-${CH_LIBC}"
|
||||||
CFLAGS=""
|
CFLAGS=""
|
||||||
@ -176,7 +189,7 @@ sed -i 's/"with-serde",\ //g' hypervisor/Cargo.toml
|
|||||||
cargo_args=("$@")
|
cargo_args=("$@")
|
||||||
cargo_args+=("--no-default-features")
|
cargo_args+=("--no-default-features")
|
||||||
cargo_args+=("--features mmio,kvm")
|
cargo_args+=("--features mmio,kvm")
|
||||||
cargo build --release --target $BUILD_TARGET ${cargo_args[@]}
|
cargo build --all --release --target $BUILD_TARGET ${cargo_args[@]}
|
||||||
strip target/$BUILD_TARGET/release/cloud-hypervisor
|
strip target/$BUILD_TARGET/release/cloud-hypervisor
|
||||||
strip target/$BUILD_TARGET/release/vhost_user_net
|
strip target/$BUILD_TARGET/release/vhost_user_net
|
||||||
strip target/$BUILD_TARGET/release/ch-remote
|
strip target/$BUILD_TARGET/release/ch-remote
|
||||||
@ -221,4 +234,8 @@ EOF
|
|||||||
RES=$?
|
RES=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Tear vhost_user_net test network down
|
||||||
|
sudo ip link del vunet-tap0
|
||||||
|
sudo ip link del vunet-tap1
|
||||||
|
|
||||||
exit $RES
|
exit $RES
|
||||||
|
Loading…
Reference in New Issue
Block a user