From d8c17032f8e75659b2823eeda6a54597d910865b Mon Sep 17 00:00:00 2001 From: Naoki MATSUMOTO Date: Thu, 11 Jan 2024 14:45:29 +0900 Subject: [PATCH] cleanup --- .github/workflows/test.yaml | 42 +++++++++---------- benchmark/block/block_multinode.sh | 2 +- benchmark/etcd/etcd_multinode.sh | 2 +- benchmark/iperf3/iperf3_multinode.sh | 2 +- benchmark/memcached/memcached_multinode.sh | 2 +- benchmark/mysql/mysql.sh | 2 +- benchmark/mysql/mysql_multinode.sh | 2 +- benchmark/postgres/postgres.sh | 2 +- benchmark/postgres/postgres_multinode.sh | 2 +- benchmark/rabbitmq/rabbitmq_multinode.sh | 2 +- benchmark/redis/redis_multinode.sh | 2 +- debug.sh | 39 ----------------- enter.sh => test/enter.sh | 0 .../export_lxc_image.sh | 0 launch_test_lxc.sh => test/launch_test_lxc.sh | 0 test/multinode.sh | 2 +- setup_lxd.sh => test/setup_lxd.sh | 4 +- test/setup_vxlan.sh | 2 +- util.sh => test/util.sh | 0 19 files changed, 35 insertions(+), 74 deletions(-) delete mode 100755 debug.sh rename enter.sh => test/enter.sh (100%) rename export_lxc_image.sh => test/export_lxc_image.sh (100%) rename launch_test_lxc.sh => test/launch_test_lxc.sh (100%) rename setup_lxd.sh => test/setup_lxd.sh (77%) rename util.sh => test/util.sh (100%) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1d9517a..6b5bff1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -41,29 +41,29 @@ jobs: path: /tmp/test-image.tar.zst lookup-only: true - - name: setup lxd (v5.19) + - name: setup lxd id: s1 if: steps.cache-restore.outputs.cache-hit != 'true' - run: ./setup_lxd.sh + run: ./test/setup_lxd.sh - name: launch lxc container - id: s6 + id: s2 if: steps.s1.conclusion == 'success' - run: ./launch_test_lxc.sh + run: ./test/launch_test_lxc.sh - name: install dependencies and build - id: s7 - if: steps.s6.conclusion == 'success' + id: s3 + if: steps.s2.conclusion == 'success' run: sudo lxc exec test -- sudo --login --user ubuntu /host/test/init_test.sh - name: export image - id: s8 - if: steps.s7.conclusion == 'success' - run: ./export_lxc_image.sh test + id: s4 + if: steps.s3.conclusion == 'success' + run: ./test/export_lxc_image.sh test - uses: actions/cache/save@v3 - id: s11 - if: steps.s8.conclusion == 'success' + id: s5 + if: steps.s4.conclusion == 'success' with: key: lxc-image-base-${{ hashFiles('go.sum', 'test/init_test.sh') }} path: /tmp/test-image.tar.zst @@ -74,8 +74,8 @@ jobs: timeout-minutes: 20 steps: - uses: actions/checkout@v4.1.1 - - name: setup lxd (v5.19) - run: ./setup_lxd.sh + - name: setup lxd + run: ./test/setup_lxd.sh - uses: actions/cache/restore@v3 id: cache-restore with: @@ -85,12 +85,12 @@ jobs: - name: load lxc image run: sudo lxc image import /tmp/test-image.tar.zst --alias test-export - name: launch lxc container - run: ./launch_test_lxc.sh test-export + run: ./test/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/bypass4netns/test/run_test.sh SYNC" # 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 && ./export_lxc_image.sh test + run: sudo lxc image alias delete test-export && rm -f /tmp/test-image.tar.zst && ./test/export_lxc_image.sh test - uses: actions/cache/save@v3 with: key: lxc-image-${{ github.sha }} @@ -107,8 +107,8 @@ jobs: script: ["iperf3/iperf3_host", "iperf3/iperf3", "postgres/postgres", "redis/redis", "block/block", "memcached/memcached", "rabbitmq/rabbitmq", "etcd/etcd", "mysql/mysql"] steps: - uses: actions/checkout@v4.1.1 - - name: setup lxd (v5.19) - run: ./setup_lxd.sh + - name: setup lxd + run: ./test/setup_lxd.sh - uses: actions/cache/restore@v3 id: cache-restore with: @@ -118,7 +118,7 @@ jobs: - name: load lxc image run: sudo lxc image import /tmp/test-image.tar.zst --alias test-export - name: launch lxc container - run: ./launch_test_lxc.sh test-export + run: ./test/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 && /home/ubuntu/bypass4netns/benchmark/${{ matrix.script }}.sh" - name: upload plot @@ -147,8 +147,8 @@ jobs: script: ["iperf3/iperf3", "postgres/postgres", "redis/redis", "block/block", "memcached/memcached", "rabbitmq/rabbitmq", "etcd/etcd", "mysql/mysql"] steps: - uses: actions/checkout@v4.1.1 - - name: setup lxd (v5.19) - run: ./setup_lxd.sh + - name: setup lxd + run: ./test/setup_lxd.sh - uses: actions/cache/restore@v3 id: cache-restore with: @@ -158,7 +158,7 @@ jobs: - name: load lxc image run: sudo lxc image import /tmp/test-image.tar.zst --alias test-export - name: launch lxc container - run: ./launch_test_lxc.sh test-export + run: ./test/launch_test_lxc.sh test-export - name: run benchmark (${{ matrix.script }}) run: ./benchmark/${{ matrix.script }}_multinode.sh - name: upload plot diff --git a/benchmark/block/block_multinode.sh b/benchmark/block/block_multinode.sh index be7fe9b..b223c77 100755 --- a/benchmark/block/block_multinode.sh +++ b/benchmark/block/block_multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh set +e NAME="test" exec_lxc sudo nerdctl rm -f block-server diff --git a/benchmark/etcd/etcd_multinode.sh b/benchmark/etcd/etcd_multinode.sh index 1eb3d98..3370c0c 100755 --- a/benchmark/etcd/etcd_multinode.sh +++ b/benchmark/etcd/etcd_multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh set +e NAME="test" exec_lxc sudo nerdctl rm -f etcd-server diff --git a/benchmark/iperf3/iperf3_multinode.sh b/benchmark/iperf3/iperf3_multinode.sh index d8c5272..00a7f4d 100755 --- a/benchmark/iperf3/iperf3_multinode.sh +++ b/benchmark/iperf3/iperf3_multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh set +e NAME="test" exec_lxc sudo nerdctl rm -f iperf3-server diff --git a/benchmark/memcached/memcached_multinode.sh b/benchmark/memcached/memcached_multinode.sh index f9ac038..9f2b1ee 100755 --- a/benchmark/memcached/memcached_multinode.sh +++ b/benchmark/memcached/memcached_multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh set +e NAME="test" exec_lxc sudo nerdctl rm -f memcached-server diff --git a/benchmark/mysql/mysql.sh b/benchmark/mysql/mysql.sh index 527825c..f805714 100755 --- a/benchmark/mysql/mysql.sh +++ b/benchmark/mysql/mysql.sh @@ -8,7 +8,7 @@ BENCH_IMAGE="mysql-bench" source ~/.profile cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh . ../param.bash # sometimes fail to pull images diff --git a/benchmark/mysql/mysql_multinode.sh b/benchmark/mysql/mysql_multinode.sh index ca20dc0..b3428ff 100755 --- a/benchmark/mysql/mysql_multinode.sh +++ b/benchmark/mysql/mysql_multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh set +e NAME="test" exec_lxc sudo nerdctl rm -f mysql-server diff --git a/benchmark/postgres/postgres.sh b/benchmark/postgres/postgres.sh index be87571..6e87e81 100755 --- a/benchmark/postgres/postgres.sh +++ b/benchmark/postgres/postgres.sh @@ -7,7 +7,7 @@ POSTGRES_IMAGE="postgres:$POSTGRES_VERSION" source ~/.profile cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh . ../param.bash sudo nerdctl pull --quiet $POSTGRES_IMAGE diff --git a/benchmark/postgres/postgres_multinode.sh b/benchmark/postgres/postgres_multinode.sh index 503af07..d821d0f 100755 --- a/benchmark/postgres/postgres_multinode.sh +++ b/benchmark/postgres/postgres_multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh set +e NAME="test" exec_lxc sudo nerdctl rm -f psql-server diff --git a/benchmark/rabbitmq/rabbitmq_multinode.sh b/benchmark/rabbitmq/rabbitmq_multinode.sh index e0f146d..a1463a0 100755 --- a/benchmark/rabbitmq/rabbitmq_multinode.sh +++ b/benchmark/rabbitmq/rabbitmq_multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh set +e NAME="test" exec_lxc sudo nerdctl rm -f rabbitmq-server diff --git a/benchmark/redis/redis_multinode.sh b/benchmark/redis/redis_multinode.sh index 06ecf71..21dd291 100755 --- a/benchmark/redis/redis_multinode.sh +++ b/benchmark/redis/redis_multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../../util.sh +. ../../test/util.sh set +e NAME="test" exec_lxc sudo nerdctl rm -f redis-server diff --git a/debug.sh b/debug.sh deleted file mode 100755 index a10887b..0000000 --- a/debug.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -sudo lxc rm -f test -sudo lxc rm -f test2 - -set -eux -o pipefail - -TEST1_VXLAN_MAC="02:42:c0:a8:00:1" -TEST1_VXLAN_ADDR="192.168.2.1" -TEST2_VXLAN_MAC="02:42:c0:a8:00:2" -TEST2_VXLAN_ADDR="192.168.2.2" - -cd $(dirname $0) -. ./util.sh - -sudo lxc launch -c security.nesting=true images:ubuntu/22.04 test -sudo lxc launch -c security.nesting=true images:ubuntu/22.04 test2 - -sleep 5 - -TEST_ADDR=$(NAME="test" exec_lxc hostname -I) -TEST2_ADDR=$(NAME="test2" exec_lxc hostname -I) - -NAME="test" exec_lxc sudo apt install -y ethtool -NAME="test" exec_lxc sudo ip link add vxlan0 type vxlan id 100 noproxy nolearning remote $TEST2_ADDR dstport 4789 dev eth0 -NAME="test" exec_lxc sudo ethtool -K vxlan0 tx-checksum-ip-generic off -NAME="test" exec_lxc sudo ip a add $TEST1_VXLAN_ADDR/24 dev vxlan0 -NAME="test" exec_lxc sudo ip link set vxlan0 up - -NAME="test2" exec_lxc sudo apt install -y ethtool -NAME="test2" exec_lxc sudo ip link add vxlan0 type vxlan id 100 noproxy nolearning remote $TEST_ADDR dstport 4789 dev eth0 -NAME="test2" exec_lxc sudo ethtool -K vxlan0 tx-checksum-ip-generic off -NAME="test2" exec_lxc sudo ip a add $TEST2_VXLAN_ADDR/24 dev vxlan0 -NAME="test2" exec_lxc sudo ip link set vxlan0 up - -NAME="test" exec_lxc ping -c 5 $TEST2_VXLAN_ADDR - -sudo lxc rm -f test -sudo lxc rm -f test2 \ No newline at end of file diff --git a/enter.sh b/test/enter.sh similarity index 100% rename from enter.sh rename to test/enter.sh diff --git a/export_lxc_image.sh b/test/export_lxc_image.sh similarity index 100% rename from export_lxc_image.sh rename to test/export_lxc_image.sh diff --git a/launch_test_lxc.sh b/test/launch_test_lxc.sh similarity index 100% rename from launch_test_lxc.sh rename to test/launch_test_lxc.sh diff --git a/test/multinode.sh b/test/multinode.sh index d762b3d..dd95eb0 100755 --- a/test/multinode.sh +++ b/test/multinode.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../util.sh +. ./util.sh set +e NAME="test" exec_lxc nerdctl rm -f vxlan diff --git a/setup_lxd.sh b/test/setup_lxd.sh similarity index 77% rename from setup_lxd.sh rename to test/setup_lxd.sh index 6c77143..f619fa1 100755 --- a/setup_lxd.sh +++ b/test/setup_lxd.sh @@ -4,10 +4,10 @@ set -eux -o pipefail cd $(dirname $0) -#sudo snap remove --purge lxd && sudo snap install lxd --revision=26093 sudo modprobe vxlan -cat test/lxd.yaml | sudo lxd init --preseed +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 diff --git a/test/setup_vxlan.sh b/test/setup_vxlan.sh index 0d144e6..fd6b0ca 100755 --- a/test/setup_vxlan.sh +++ b/test/setup_vxlan.sh @@ -1,7 +1,7 @@ #!/bin/bash cd $(dirname $0) -. ../util.sh +. ./util.sh set -eux -o pipefail diff --git a/util.sh b/test/util.sh similarity index 100% rename from util.sh rename to test/util.sh