-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #708 from AkihiroSuda/test-upgrade
CI: add upgrade test
- Loading branch information
Showing
6 changed files
with
166 additions
and
37 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
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 @@ | ||
source-path=SCRIPTDIR |
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,24 @@ | ||
# shellcheck shell=bash | ||
cleanup_cmd="" | ||
trap 'eval ${cleanup_cmd}' EXIT | ||
function defer { | ||
[ -n "${cleanup_cmd}" ] && cleanup_cmd="${cleanup_cmd}; " | ||
cleanup_cmd="${cleanup_cmd}$1" | ||
} | ||
|
||
function INFO() { | ||
echo "TEST| [INFO] $*" | ||
} | ||
|
||
function WARNING() { | ||
echo >&2 "TEST| [WARNING] $*" | ||
} | ||
|
||
function ERROR() { | ||
echo >&2 "TEST| [ERROR] $*" | ||
} | ||
|
||
if [[ ${BASH_VERSINFO:-0} -lt 4 ]]; then | ||
ERROR "Bash version is too old: ${BASH_VERSION}" | ||
exit 1 | ||
fi |
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
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,26 @@ | ||
#!/usr/bin/env bash | ||
set -eu -o pipefail | ||
|
||
scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
# shellcheck source=common.inc.sh | ||
source "${scriptdir}/common.inc.sh" | ||
|
||
if [ "$#" -ne 1 ]; then | ||
ERROR "Usage: $0 NAME" | ||
exit 1 | ||
fi | ||
|
||
NAME="$1" | ||
hometmp="$HOME/lima-test-tmp" | ||
INFO "Testing home access (\"$hometmp\")" | ||
rm -rf "$hometmp" | ||
mkdir -p "$hometmp" | ||
defer "rm -rf \"$hometmp\"" | ||
echo "random-content-${RANDOM}" >"$hometmp/random" | ||
expected="$(cat "$hometmp/random")" | ||
got="$(limactl shell "$NAME" cat "$hometmp/random")" | ||
INFO "$hometmp/random: expected=${expected}, got=${got}" | ||
if [ "$got" != "$expected" ]; then | ||
ERROR "Home directory is not shared?" | ||
exit 1 | ||
fi |
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,83 @@ | ||
#!/usr/bin/env bash | ||
set -eu -o pipefail | ||
|
||
scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
# shellcheck source=common.inc.sh | ||
source "${scriptdir}/common.inc.sh" | ||
cd "${scriptdir}/.." | ||
|
||
if [ "$#" -ne 2 ]; then | ||
ERROR "Usage: $0 OLDVER NEWVER" | ||
exit 1 | ||
fi | ||
|
||
OLDVER="$1" | ||
NEWVER="$2" | ||
|
||
PREFIX="/usr/local" | ||
function install_lima() { | ||
ver="$1" | ||
git checkout "${ver}" | ||
make clean | ||
make | ||
if [ -w "${PREFIX}/bin" ] && [ -w "${PREFIX}/share" ]; then | ||
make install | ||
else | ||
sudo make install | ||
fi | ||
} | ||
|
||
function uninstall_lima() { | ||
files="${PREFIX}/bin/lima ${PREFIX}/bin/limactl ${PREFIX}/share/lima ${PREFIX}/share/doc/lima" | ||
if [ -w "${PREFIX}/bin" ] && [ -w "${PREFIX}/share" ]; then | ||
# shellcheck disable=SC2086 | ||
rm -rf $files | ||
else | ||
# shellcheck disable=SC2086 | ||
sudo rm -rf $files | ||
fi | ||
} | ||
|
||
INFO "Uninstalling lima" | ||
uninstall_lima | ||
|
||
INFO "Installing the old Lima ${OLDVER}" | ||
install_lima "${OLDVER}" | ||
|
||
export LIMA_INSTANCE="test-upgrade" | ||
|
||
INFO "Creating an instance \"${LIMA_INSTANCE}\" with the old Lima" | ||
defer "limactl delete -f \"${LIMA_INSTANCE}\"" | ||
limactl start --tty=false "${LIMA_INSTANCE}" | ||
lima nerdctl info | ||
|
||
image_name="lima-test-upgrade-containerd-${RANDOM}" | ||
image_context="${HOME}/${image_name}" | ||
INFO "Building containerd image \"${image_name}\" from \"${image_context}\"" | ||
defer "rm -rf \"${image_context}\"" | ||
mkdir -p "${image_context}" | ||
cat <<EOF >"${image_context}"/Dockerfile | ||
# Use GHCR to avoid hitting Docker Hub rate limit | ||
FROM ghcr.io/containerd/alpine:3.14.0 | ||
CMD ["echo", "Built with Lima ${OLDVER}"] | ||
EOF | ||
lima nerdctl build -t "${image_name}" "${image_context}" | ||
lima nerdctl run --rm "${image_name}" | ||
|
||
INFO "Stopping the instance" | ||
limactl stop "${LIMA_INSTANCE}" | ||
|
||
INFO "==============================================================================" | ||
|
||
INFO "Installing the new Lima ${NEWVER}" | ||
install_lima "${NEWVER}" | ||
|
||
INFO "Restarting the instance" | ||
limactl start --tty=false "${LIMA_INSTANCE}" | ||
lima nerdctl info | ||
|
||
INFO "Confirming that the host filesystem is still mounted" | ||
"${scriptdir}"/test-mount-home.sh "${LIMA_INSTANCE}" | ||
|
||
INFO "Confirming that the image \"${image_name}\" still exists" | ||
lima nerdctl run --rm "${image_name}" |