From a739f47744ca739580d9dd3528bfa02260bdba38 Mon Sep 17 00:00:00 2001 From: Naoki MATSUMOTO Date: Tue, 19 Mar 2024 18:45:47 +0900 Subject: [PATCH] add GHA Signed-off-by: Naoki MATSUMOTO --- .github/workflows/test.yaml | 153 ++++++++++++++++++++++++++++++++++++ .gitignore | 3 + Makefile | 15 +++- tests/.gitignore | 12 +-- tests/bench.sh | 24 +++--- tests/bench_impl.sh | 69 +++++++++------- tests/bench_lxc.sh | 25 ++++++ tests/export_lxc_image.sh | 9 +++ tests/launch_test_lxc.sh | 20 +++++ tests/lxd.yaml | 38 +++++++++ tests/setup_lxd.sh | 15 ++++ tests/setup_test.sh | 43 ++++++++++ tests/sync_lxc.sh | 11 +++ tests/test_apache.sh | 8 ++ tests/test_mysql.sh | 8 ++ tests/test_nginx.sh | 8 ++ tests/test_postgres.sh | 8 ++ tests/test_redis.sh | 8 ++ 18 files changed, 425 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/test.yaml create mode 100755 tests/bench_lxc.sh create mode 100755 tests/export_lxc_image.sh create mode 100755 tests/launch_test_lxc.sh create mode 100644 tests/lxd.yaml create mode 100755 tests/setup_lxd.sh create mode 100755 tests/setup_test.sh create mode 100755 tests/sync_lxc.sh create mode 100644 tests/test_apache.sh create mode 100644 tests/test_mysql.sh create mode 100644 tests/test_nginx.sh create mode 100644 tests/test_postgres.sh create mode 100644 tests/test_redis.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..5196aab --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,153 @@ +--- +name: Test +on: + push: + branches: + - master + - main + - release/** + - dev + pull_request: null + workflow_dispatch: + +jobs: + #golangci-lint: + # runs-on: ubuntu-22.04 + # timeout-minutes: 20 + # steps: + # - uses: actions/checkout@v4.1.1 + # with: + # fetch-depth: 1 + # - uses: actions/setup-go@v3 + # with: + # go-version: 1.21.x + # - run: sudo apt-get update + # - name: golangci-lint + # uses: golangci/golangci-lint-action@v3.7.0 + # with: + # version: v1.55.2 + # args: --verbose + + create-lxc-image: + name: create-lxc-image + runs-on: ubuntu-22.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4.1.1 + + - uses: actions/cache/restore@v3 + id: cache-restore + with: + key: lxc-image-base-${{ hashFiles('go.sum', 'tests/setup_test.sh', 'tests/sync_lxc.sh') }} + path: /tmp/test-image.tar.zst + lookup-only: true + + - name: setup lxd + id: s1 + if: steps.cache-restore.outputs.cache-hit != 'true' + run: ./tests/setup_lxd.sh + + - name: launch lxc container + id: s2 + if: steps.s1.conclusion == 'success' + run: ./tests/launch_test_lxc.sh + + - name: install dependencies and build + id: s3 + if: steps.s2.conclusion == 'success' + run: sudo lxc exec test -- sudo --login --user ubuntu /host/tests/setup_test.sh + + - name: export image + id: s4 + if: steps.s3.conclusion == 'success' + run: ./tests/export_lxc_image.sh test + + - uses: actions/cache/save@v3 + id: s5 + if: steps.s4.conclusion == 'success' + with: + key: lxc-image-base-${{ hashFiles('go.sum', 'tests/setup_test.sh', 'tests/sync_lxc.sh') }} + path: /tmp/test-image.tar.zst + + sync: + runs-on: ubuntu-22.04 + needs: create-lxc-image + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4.1.1 + - name: setup lxd + run: ./tests/setup_lxd.sh + - uses: actions/cache/restore@v3 + id: cache-restore + with: + key: lxc-image-base-${{ hashFiles('go.sum', 'tests/setup_test.sh', 'tests/sync_lxc.sh') }} + path: /tmp/test-image.tar.zst + fail-on-cache-miss: true + - name: load lxc image + run: sudo lxc image import /tmp/test-image.tar.zst --alias test-export + - name: launch lxc container + run: ./tests/launch_test_lxc.sh test-export + - name: run test + run: sudo lxc exec test -- sudo --login --user ubuntu /bin/bash -c "sleep 3 && /home/ubuntu/d4c/tests/sync_lxc.sh" + # some source codes may be updated. re-export new image. + - name: export image + run: sudo lxc image alias delete test-export && rm -f /tmp/test-image.tar.zst && ./tests/export_lxc_image.sh test + - uses: actions/cache/save@v3 + with: + key: lxc-image-${{ github.sha }} + path: /tmp/test-image.tar.zst + + benchmark: + runs-on: ubuntu-22.04 + needs: sync + timeout-minutes: 20 + strategy: + matrix: + script: ["apache", "mysql", "nginx", "postgres", "redis"] + steps: + - uses: actions/checkout@v4.1.1 + - name: setup lxd + run: ./tests/setup_lxd.sh + - uses: actions/cache/restore@v3 + id: cache-restore + with: + key: lxc-image-${{ github.sha }} + path: /tmp/test-image.tar.zst + fail-on-cache-miss: true + - name: load lxc image + run: sudo lxc image import /tmp/test-image.tar.zst --alias test-export + - name: launch lxc container + run: ./tests/launch_test_lxc.sh test-export + - name: run benchmark (${{ matrix.script }}) + run: sudo lxc exec test -- sudo --login --user ubuntu /bin/bash -c "sleep 3 && sudo /home/ubuntu/d4c/tests/bench_lxc.sh ${{ matrix.script }}" + - name: get result + id: get_result + run: | + mkdir /tmp/benchmark-results + sudo lxc file pull test/home/ubuntu/d4c/tests/benchmark/${{ matrix.script }}-benchmark.log /tmp/benchmark-results/. + - uses: actions/upload-artifact@v3 + if: steps.get_result.conclusion == 'success' + with: + name: benchmark-${{ matrix.script }} + path: /tmp/benchmark-results + + benchmark-all: + runs-on: ubuntu-22.04 + needs: sync + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4.1.1 + - name: setup lxd + run: ./tests/setup_lxd.sh + - uses: actions/cache/restore@v3 + id: cache-restore + with: + key: lxc-image-${{ github.sha }} + path: /tmp/test-image.tar.zst + fail-on-cache-miss: true + - name: load lxc image + run: sudo lxc image import /tmp/test-image.tar.zst --alias test-export + - name: launch lxc container + run: ./tests/launch_test_lxc.sh test-export + - name: run benchmark (${{ matrix.script }}) + run: sudo lxc exec test -- sudo --login --user ubuntu /bin/bash -c "sleep 3 && sudo /home/ubuntu/d4c/tests/bench.sh" diff --git a/.gitignore b/.gitignore index e0155de..38a86ab 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ /diff /pack /server +/fuse-diff +/merge +/patch diff --git a/Makefile b/Makefile index 4709147..82bac05 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -.PHONY: snapshotter ctr-cli diff-tools server +.PHONY: snapshotter ctr-cli diff-tools server fuse-diff merge patch -all: snapshotter ctr-cli diff-tools server +all: snapshotter ctr-cli diff-tools server fuse-diff merge patch run: make clean @@ -20,5 +20,14 @@ diff-tools: server: go build -o server ./cmd/server +fuse-diff: + go build -o fuse-diff ./cmd/fuse-diff + +merge: + go build -o merge ./cmd/merge + +patch: + go build -o patch ./cmd/patch + clean: - rm -f snapshotter ctr-cli diff pack server + rm -f snapshotter ctr-cli diff pack server fuse-diff merge patch diff --git a/tests/.gitignore b/tests/.gitignore index 08df9cf..a34b883 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,11 +1 @@ -* -!/.gitignore -!/postgres -!/simple-dir -!/run-tests.sh -!/bench*.sh -!/bench-*.py -!/push-*.sh -!/scp*.sh -!version.sh -/server +/benchmark_* diff --git a/tests/bench.sh b/tests/bench.sh index 0e1e701..d19e3ac 100755 --- a/tests/bench.sh +++ b/tests/bench.sh @@ -7,19 +7,23 @@ if [ $EUID -ne 0 ]; then fi RUN_NUM=1 +PATH=$PATH:/usr/local/go/bin + +cd $(cd $(dirname $0); pwd) +pushd ../ +make all +popd + RESULT_DIR=benchmark_`date +%Y-%m-%d-%H%M` -mkdir -p $RESULT_DIR +IMAGE_DIR=$RESULT_DIR/images +mkdir -p $IMAGE_DIR -IMAGES=("apach-root" "mysql-root" "nginx-root" "postgres-root" "redis-root") -for IMAGE in "${IMAGES[@]}" +TESTS=("apache" "mysql" "nginx" "postgres" "redis") +for TEST in "${TESTS[@]}" do - echo "Benchmarking $IMAGE" - cd $IMAGE - rm -f benchmark.log - ln -sf ../bench_impl.sh ./bench.sh - ./bench.sh $RUN_NUM - cp benchmark.log ../$RESULT_DIR/$IMAGE-benchmark.log - cd ../ + echo "Benchmarking $TEST" + ./bench_impl.sh test_$TEST.sh $IMAGE_DIR $RUN_NUM + cp $IMAGE_DIR/$TEST/benchmark.log ./$RESULT_DIR/$TEST-benchmark.log done cd $RESULT_DIR diff --git a/tests/bench_impl.sh b/tests/bench_impl.sh index ff6c3ce..089058c 100755 --- a/tests/bench_impl.sh +++ b/tests/bench_impl.sh @@ -3,8 +3,19 @@ set -eu -source ./version.sh -RUN_NUM=$1 +ROOT_DIR=$(cd $(dirname $0)/../; pwd) +BIN_CTR_CLI="$ROOT_DIR/ctr-cli" +BIN_DIFF="$ROOT_DIR/diff" +BIN_PACK="$ROOT_DIR/pack" +BIN_PATCH="$ROOT_DIR/patch" +BIN_FUSE="$ROOT_DIR/fuse-diff" +BIN_MERGE="$ROOT_DIR/merge" + +TEST_SCRIPT=$1 +IMAGE_DIR=$2 +RUN_NUM=$3 + +source $TEST_SCRIPT mkdir -p /tmp/fuse @@ -15,24 +26,26 @@ function err() { trap err ERR - -rm -f diff patch pack fuse-diff merge -go build ../../cmd/diff -go build ../../cmd/patch -go build ../../cmd/pack -go build ../../cmd/fuse-diff -go build ../../cmd/merge +IMAGE_DIR=$IMAGE_DIR/$IMAGE_NAME +mkdir -p $IMAGE_DIR +cd $IMAGE_DIR for ((i=0; i < ${#IMAGE_VERSIONS[@]}; i++));do IMAGE=${IMAGE_VERSIONS[i]} - echo "Creating base image for $IMAGE" - ./diff "" $IMAGE $IMAGE-base $IMAGE-base.json binary-diff - ./pack $IMAGE-base $IMAGE-base.json "" $IMAGE-base.dimg - ./patch dimg "" $IMAGE-base-patched $IMAGE-base.dimg + echo "Creating base image for $IMAGE_NAME:$IMAGE" + $BIN_CTR_CLI convert --image $DOCKER_IMAGE:$IMAGE --output ./image-$IMAGE >/dev/null 2>&1 + mkdir $IMAGE + sudo tar -xf ./image-$IMAGE/layer.tar -C ./$IMAGE + + # remove '/dev' dir + sudo rm -rf ./$IMAGE/dev + + $BIN_DIFF "" $IMAGE $IMAGE-base $IMAGE-base.json binary-diff + $BIN_PACK $IMAGE-base $IMAGE-base.json "" $IMAGE-base.dimg + $BIN_PATCH dimg "" $IMAGE-base-patched $IMAGE-base.dimg diff -r $IMAGE $IMAGE-base-patched --no-dereference done - for ((i=0; i < $(expr ${#IMAGE_VERSIONS[@]} - 1); i++));do LOWER=${IMAGE_VERSIONS[i]} UPPER=${IMAGE_VERSIONS[$(expr $i + 1)]} @@ -42,18 +55,18 @@ for ((i=0; i < $(expr ${#IMAGE_VERSIONS[@]} - 1); i++));do for ((j=0; j < $RUN_NUM; j++));do NOW_COUNT=$(expr $j + 1) echo "Benchmark diff $DIFF_NAME binary-diff ($NOW_COUNT/$RUN_NUM)" - ./diff $LOWER $UPPER diff_$DIFF_NAME diff_$DIFF_NAME.json binary-diff benchmark + $BIN_DIFF $LOWER $UPPER diff_$DIFF_NAME diff_$DIFF_NAME.json binary-diff benchmark done # packing diff data - ./pack diff_$DIFF_NAME diff_$DIFF_NAME.json $LOWER-base.dimg diff_$DIFF_NAME.dimg + $BIN_PACK diff_$DIFF_NAME diff_$DIFF_NAME.json $LOWER-base.dimg diff_$DIFF_NAME.dimg ls -l diff_$DIFF_NAME.dimg # patching diff data for ((j=0; j < $RUN_NUM; j++));do NOW_COUNT=$(expr $j + 1) echo "Benchmark patch $DIFF_NAME binary-diff ($NOW_COUNT/$RUN_NUM)" - ./patch dimg $LOWER $UPPER-patched diff_$DIFF_NAME.dimg benchmark + $BIN_PATCH dimg $LOWER $UPPER-patched diff_$DIFF_NAME.dimg benchmark done diff -r $UPPER $UPPER-patched --no-dereference @@ -61,7 +74,7 @@ for ((i=0; i < $(expr ${#IMAGE_VERSIONS[@]} - 1); i++));do for ((j=0; j < $RUN_NUM; j++));do NOW_COUNT=$(expr $j + 1) echo "Benchmark di3fs $DIFF_NAME binary-diff ($NOW_COUNT/$RUN_NUM)" - ./fuse-diff --basedir=./$LOWER-base.dimg --patchdir=./diff_$DIFF_NAME.dimg --mode=dimg --benchmark=true /tmp/fuse >/dev/null 2>&1 & + $BIN_FUSE --basedir=./$LOWER-base.dimg --patchdir=./diff_$DIFF_NAME.dimg --mode=dimg --benchmark=true /tmp/fuse >/dev/null 2>&1 & sleep 1 if [ $j -eq 0 ]; then diff -r $UPPER /tmp/fuse --no-dereference @@ -73,14 +86,14 @@ for ((i=0; i < $(expr ${#IMAGE_VERSIONS[@]} - 1); i++));do for ((j=0; j < $RUN_NUM; j++));do NOW_COUNT=$(expr $j + 1) echo "Benchmark diff $DIFF_NAME file-diff ($NOW_COUNT/$RUN_NUM)" - ./diff $LOWER $UPPER diff_file_$DIFF_NAME diff_file_$DIFF_NAME.json file-diff benchmark + $BIN_DIFF $LOWER $UPPER diff_file_$DIFF_NAME diff_file_$DIFF_NAME.json file-diff benchmark done # packing diff data and test it echo "Testing packed $DIFF_NAME file-diff" - ./pack diff_file_$DIFF_NAME diff_file_$DIFF_NAME.json $LOWER-base.dimg diff_file_$DIFF_NAME.dimg + $BIN_PACK diff_file_$DIFF_NAME diff_file_$DIFF_NAME.json $LOWER-base.dimg diff_file_$DIFF_NAME.dimg ls -l diff_file_$DIFF_NAME.dimg - ./patch dimg $LOWER $UPPER-patched diff_file_$DIFF_NAME.dimg + $BIN_PATCH dimg $LOWER $UPPER-patched diff_file_$DIFF_NAME.dimg diff -r $UPPER $UPPER-patched --no-dereference done @@ -90,14 +103,14 @@ MERGED=$IMAGE_LOWER-$IMAGE_UPPER for ((j=0; j < $RUN_NUM; j++));do NOW_COUNT=$(expr $j + 1) echo "Benchmark merge $MERGE_LOWER and $MERGE_UPPER to $MERGED ($NOW_COUNT/$RUN_NUM)" - ./merge dimg diff_$MERGE_LOWER.dimg diff_$MERGE_UPPER.dimg diff_merged_$MERGED.dimg benchmark + $BIN_MERGE dimg diff_$MERGE_LOWER.dimg diff_$MERGE_UPPER.dimg diff_merged_$MERGED.dimg benchmark done echo "Testing merged $MERGED" -./patch dimg $IMAGE_LOWER $IMAGE_UPPER-merged diff_merged_$MERGED.dimg +$BIN_PATCH dimg $IMAGE_LOWER $IMAGE_UPPER-merged diff_merged_$MERGED.dimg diff -r $IMAGE_UPPER $IMAGE_UPPER-merged --no-dereference ls -l diff_merged_$MERGED.dimg -./fuse-diff --basedir=./$IMAGE_LOWER-base.dimg --patchdir=./diff_merged_$MERGED.dimg --mode=dimg /tmp/fuse >/dev/null 2>&1 & +$BIN_FUSE --basedir=./$IMAGE_LOWER-base.dimg --patchdir=./diff_merged_$MERGED.dimg --mode=dimg /tmp/fuse >/dev/null 2>&1 & sleep 1 diff -r $IMAGE_UPPER /tmp/fuse --no-dereference fusermount3 -u /tmp/fuse @@ -105,17 +118,17 @@ fusermount3 -u /tmp/fuse for ((j=0; j < $RUN_NUM; j++));do NOW_COUNT=$(expr $j + 1) echo "Benchmark regen-diff $MERGED binary-diff ($NOW_COUNT/$RUN_NUM)" - ./diff $IMAGE_LOWER $IMAGE_UPPER diff_$MERGED diff_$MERGED.json binary-diff benchmark + $BIN_DIFF $IMAGE_LOWER $IMAGE_UPPER diff_$MERGED diff_$MERGED.json binary-diff benchmark done -./pack diff_$MERGED diff_$MERGED.json $IMAGE_LOWER-base.dimg diff_$MERGED.dimg +$BIN_PACK diff_$MERGED diff_$MERGED.json $IMAGE_LOWER-base.dimg diff_$MERGED.dimg ls -l diff_$MERGED.dimg for ((j=0; j < $RUN_NUM; j++));do NOW_COUNT=$(expr $j + 1) echo "Benchmark regen-diff $MERGED file-diff ($NOW_COUNT/$RUN_NUM)" - ./diff $IMAGE_LOWER $IMAGE_UPPER diff_file_$MERGED diff_file_$MERGED.json file-diff benchmark + $BIN_DIFF $IMAGE_LOWER $IMAGE_UPPER diff_file_$MERGED diff_file_$MERGED.json file-diff benchmark done -./pack diff_file_$MERGED diff_file_$MERGED.json $IMAGE_LOWER-base.dimg diff_file_$MERGED.dimg +$BIN_PACK diff_file_$MERGED diff_file_$MERGED.json $IMAGE_LOWER-base.dimg diff_file_$MERGED.dimg ls -l diff_file_$MERGED.dimg echo "Benchmark done" diff --git a/tests/bench_lxc.sh b/tests/bench_lxc.sh new file mode 100755 index 0000000..428f84c --- /dev/null +++ b/tests/bench_lxc.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -eu +if [ $EUID -ne 0 ]; then + echo "root previlige required" + exit 1 +fi + +RUN_NUM=1 +TEST=$1 + +PATH=$PATH:/usr/local/go/bin + +cd $(cd $(dirname $0); pwd) +pushd ../ +make all +popd + +RESULT_DIR=benchmark +IMAGE_DIR=$RESULT_DIR/images +mkdir -p $IMAGE_DIR + +echo "Benchmarking $TEST" +./bench_impl.sh test_$TEST.sh $IMAGE_DIR $RUN_NUM +cp $IMAGE_DIR/$TEST/benchmark.log ./$RESULT_DIR/$TEST-benchmark.log diff --git a/tests/export_lxc_image.sh b/tests/export_lxc_image.sh new file mode 100755 index 0000000..0467b83 --- /dev/null +++ b/tests/export_lxc_image.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -eux -o pipefail + +IMAGE_NAME=$1 + +sudo lxc snapshot $IMAGE_NAME snp0 +sudo lxc publish $IMAGE_NAME/snp0 --alias $IMAGE_NAME-export --compression zstd +sudo lxc image export $IMAGE_NAME-export /tmp/$IMAGE_NAME-image diff --git a/tests/launch_test_lxc.sh b/tests/launch_test_lxc.sh new file mode 100755 index 0000000..10bac00 --- /dev/null +++ b/tests/launch_test_lxc.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +set -ux -o pipefail +IMAGE=${1:-"images:ubuntu/22.04"} + +cd $(cd $(dirname $0); pwd) + +sudo lxc launch -c security.privileged=true -c security.nesting=true $IMAGE test +sudo lxc config device add test share disk source=$(cd ../; pwd) path=/host +sudo lxc exec test -- /bin/bash -c "echo 'ubuntu ALL=NOPASSWD: ALL' | EDITOR='tee -a' visudo" + +# let user services running +# this sometimes fails, retry until success +RES=1 +while [ $RES -ne 0 ] +do + sleep 1 + sudo lxc exec test -- sudo --login --user ubuntu /bin/bash -c "sudo loginctl enable-linger" + RES=$? +done diff --git a/tests/lxd.yaml b/tests/lxd.yaml new file mode 100644 index 0000000..26fc8b0 --- /dev/null +++ b/tests/lxd.yaml @@ -0,0 +1,38 @@ +config: {} +networks: +- config: + ipv4.address: 192.168.6.1/24 + ipv4.nat: "true" + ipv6.address: none + description: "" + name: lxdbr0 + type: bridge + project: default +storage_pools: +- config: + size: 30GiB + source: /var/snap/lxd/common/lxd/disks/default.img + description: "" + name: default + driver: btrfs +profiles: +- config: {} + description: Default LXD profile + devices: + eth0: + name: eth0 + network: lxdbr0 + type: nic + root: + path: / + pool: default + type: disk + name: default +projects: +- config: + features.images: "true" + features.networks: "true" + features.profiles: "true" + features.storage.volumes: "true" + description: Default LXD project + name: default \ No newline at end of file diff --git a/tests/setup_lxd.sh b/tests/setup_lxd.sh new file mode 100755 index 0000000..3c562d9 --- /dev/null +++ b/tests/setup_lxd.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -eux -o pipefail + +cd $(cd $(dirname $0); pwd) + +sudo modprobe vxlan +cat lxd.yaml | sudo lxd init --preseed +sudo sysctl -w net.ipv4.ip_forward=1 + +#https://andreas.scherbaum.la/post/2023-01-18_fix-lxc-network-issues-in-ubuntu-22.04/ +sudo iptables -I DOCKER-USER -i lxdbr0 -o eth0 -j ACCEPT +sudo iptables -I DOCKER-USER -o lxdbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT +sudo iptables -F FORWARD +sudo iptables -P FORWARD ACCEPT \ No newline at end of file diff --git a/tests/setup_test.sh b/tests/setup_test.sh new file mode 100755 index 0000000..7be4dce --- /dev/null +++ b/tests/setup_test.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +TEST_USER=ubuntu +set -eu -o pipefail + +if [ "$(whoami)" != "$TEST_USER" ]; then + su $TEST_USER -c $0 + exit 0 +fi + +GO_VERSION="1.21.8" + +echo "===== Prepare =====" +( + set -x + + # for lxc + if [ -d /host ]; then + sudo cp -r /host ~/d4c + fi + + sudo chown -R $TEST_USER:$TEST_USER ~/d4c + + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y apt-transport-https ca-certificates curl software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y dbus-user-session docker-ce containerd.io golang-go fuse3 python3 python3-pip + sudo pip3 install docker-squash + #pip3 install matplotlib numpy + + systemctl --user start dbus + + curl -fsSL https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz | sudo tar Cxz /usr/local + + cd ~/d4c + ./install_snapshotter.sh + sudo PATH=$PATH:/usr/local/go/bin make all + + sudo systemctl enable --now containerd +) diff --git a/tests/sync_lxc.sh b/tests/sync_lxc.sh new file mode 100755 index 0000000..75c63db --- /dev/null +++ b/tests/sync_lxc.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -eu -o pipefail + +echo "updating source code" +rm -rf ~/d4c +sudo cp -r /host ~/d4c +sudo chown -R ubuntu:ubuntu ~/d4c +cd ~/d4c +sudo PATH=$PATH:/usr/local/go/bin make all +echo "source code is updated" diff --git a/tests/test_apache.sh b/tests/test_apache.sh new file mode 100644 index 0000000..77adf90 --- /dev/null +++ b/tests/test_apache.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +IMAGE_NAME="apache" +DOCKER_IMAGE="httpd" +IMAGE_VERSIONS=(2.4.52 2.4.53 2.4.54) +IMAGE_LOWER=${IMAGE_VERSIONS[0]} +IMAGE_MIDDLE=${IMAGE_VERSIONS[1]} +IMAGE_UPPER=${IMAGE_VERSIONS[2]} diff --git a/tests/test_mysql.sh b/tests/test_mysql.sh new file mode 100644 index 0000000..af5da55 --- /dev/null +++ b/tests/test_mysql.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +IMAGE_NAME="mysql" +DOCKER_IMAGE="mysql" +IMAGE_VERSIONS=(8.0.29 8.0.30 8.0.31) +IMAGE_LOWER=${IMAGE_VERSIONS[0]} +IMAGE_MIDDLE=${IMAGE_VERSIONS[1]} +IMAGE_UPPER=${IMAGE_VERSIONS[2]} diff --git a/tests/test_nginx.sh b/tests/test_nginx.sh new file mode 100644 index 0000000..18911b2 --- /dev/null +++ b/tests/test_nginx.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +IMAGE_NAME="nginx" +DOCKER_IMAGE="nginx" +IMAGE_VERSIONS=(1.23.1 1.23.2 1.23.3) +IMAGE_LOWER=${IMAGE_VERSIONS[0]} +IMAGE_MIDDLE=${IMAGE_VERSIONS[1]} +IMAGE_UPPER=${IMAGE_VERSIONS[2]} diff --git a/tests/test_postgres.sh b/tests/test_postgres.sh new file mode 100644 index 0000000..47250d5 --- /dev/null +++ b/tests/test_postgres.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +IMAGE_NAME="postgres" +DOCKER_IMAGE="postgres" +IMAGE_VERSIONS=(13.1 13.2 13.3) +IMAGE_LOWER=${IMAGE_VERSIONS[0]} +IMAGE_MIDDLE=${IMAGE_VERSIONS[1]} +IMAGE_UPPER=${IMAGE_VERSIONS[2]} diff --git a/tests/test_redis.sh b/tests/test_redis.sh new file mode 100644 index 0000000..1e3023e --- /dev/null +++ b/tests/test_redis.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +IMAGE_NAME="redis" +DOCKER_IMAGE="redis" +IMAGE_VERSIONS=(7.0.5 7.0.6 7.0.7) +IMAGE_LOWER=${IMAGE_VERSIONS[0]} +IMAGE_MIDDLE=${IMAGE_VERSIONS[1]} +IMAGE_UPPER=${IMAGE_VERSIONS[2]}