From b14220b4d01eab082ed204acdd63fe956a3f4740 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 29 Jun 2023 00:31:12 +0300 Subject: [PATCH] Add a test for snapshot chain --- .gitea/workflows/test.yml | 216 ++++++++++++++++++++--------------- tests/run_tests.sh | 21 ++-- tests/test_snapshot_chain.sh | 48 ++++++++ 3 files changed, 186 insertions(+), 99 deletions(-) create mode 100755 tests/test_snapshot_chain.sh diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 08c45fcd..74474915 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -190,24 +190,6 @@ jobs: echo "" done - test_failure_domain: - runs-on: ubuntu-latest - needs: build - container: ${{env.TEST_IMAGE}}:${{github.sha}} - steps: - - name: Run test - id: test - timeout-minutes: 3 - run: /root/vitastor/tests/test_failure_domain.sh - - name: Print logs - if: always() && steps.test.outcome == 'failure' - run: | - for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do - echo "-------- $i --------" - cat $i - echo "" - done - test_interrupted_rebalance: runs-on: ubuntu-latest needs: build @@ -280,6 +262,60 @@ jobs: echo "" done + test_failure_domain: + runs-on: ubuntu-latest + needs: build + container: ${{env.TEST_IMAGE}}:${{github.sha}} + steps: + - name: Run test + id: test + timeout-minutes: 3 + run: /root/vitastor/tests/test_failure_domain.sh + - name: Print logs + if: always() && steps.test.outcome == 'failure' + run: | + for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do + echo "-------- $i --------" + cat $i + echo "" + done + + test_snapshot: + runs-on: ubuntu-latest + needs: build + container: ${{env.TEST_IMAGE}}:${{github.sha}} + steps: + - name: Run test + id: test + timeout-minutes: 3 + run: /root/vitastor/tests/test_snapshot.sh + - name: Print logs + if: always() && steps.test.outcome == 'failure' + run: | + for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do + echo "-------- $i --------" + cat $i + echo "" + done + + test_snapshot_ec: + runs-on: ubuntu-latest + needs: build + container: ${{env.TEST_IMAGE}}:${{github.sha}} + steps: + - name: Run test + id: test + timeout-minutes: 3 + run: SCHEME=ec /root/vitastor/tests/test_snapshot.sh + - name: Print logs + if: always() && steps.test.outcome == 'failure' + run: | + for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do + echo "-------- $i --------" + cat $i + echo "" + done + test_minsize_1: runs-on: ubuntu-latest needs: build @@ -316,6 +352,78 @@ jobs: echo "" done + test_rm: + runs-on: ubuntu-latest + needs: build + container: ${{env.TEST_IMAGE}}:${{github.sha}} + steps: + - name: Run test + id: test + timeout-minutes: 3 + run: /root/vitastor/tests/test_rm.sh + - name: Print logs + if: always() && steps.test.outcome == 'failure' + run: | + for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do + echo "-------- $i --------" + cat $i + echo "" + done + + test_snapshot_chain: + runs-on: ubuntu-latest + needs: build + container: ${{env.TEST_IMAGE}}:${{github.sha}} + steps: + - name: Run test + id: test + timeout-minutes: 3 + run: /root/vitastor/tests/test_snapshot_chain.sh + - name: Print logs + if: always() && steps.test.outcome == 'failure' + run: | + for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do + echo "-------- $i --------" + cat $i + echo "" + done + + test_snapshot_chain_ec: + runs-on: ubuntu-latest + needs: build + container: ${{env.TEST_IMAGE}}:${{github.sha}} + steps: + - name: Run test + id: test + timeout-minutes: 3 + run: SCHEME=ec /root/vitastor/tests/test_snapshot_chain.sh + - name: Print logs + if: always() && steps.test.outcome == 'failure' + run: | + for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do + echo "-------- $i --------" + cat $i + echo "" + done + + test_splitbrain: + runs-on: ubuntu-latest + needs: build + container: ${{env.TEST_IMAGE}}:${{github.sha}} + steps: + - name: Run test + id: test + timeout-minutes: 3 + run: /root/vitastor/tests/test_splitbrain.sh + - name: Print logs + if: always() && steps.test.outcome == 'failure' + run: | + for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do + echo "-------- $i --------" + cat $i + echo "" + done + test_rebalance_verify: runs-on: ubuntu-latest needs: build @@ -388,78 +496,6 @@ jobs: echo "" done - test_rm: - runs-on: ubuntu-latest - needs: build - container: ${{env.TEST_IMAGE}}:${{github.sha}} - steps: - - name: Run test - id: test - timeout-minutes: 3 - run: /root/vitastor/tests/test_rm.sh - - name: Print logs - if: always() && steps.test.outcome == 'failure' - run: | - for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do - echo "-------- $i --------" - cat $i - echo "" - done - - test_snapshot: - runs-on: ubuntu-latest - needs: build - container: ${{env.TEST_IMAGE}}:${{github.sha}} - steps: - - name: Run test - id: test - timeout-minutes: 3 - run: /root/vitastor/tests/test_snapshot.sh - - name: Print logs - if: always() && steps.test.outcome == 'failure' - run: | - for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do - echo "-------- $i --------" - cat $i - echo "" - done - - test_snapshot_ec: - runs-on: ubuntu-latest - needs: build - container: ${{env.TEST_IMAGE}}:${{github.sha}} - steps: - - name: Run test - id: test - timeout-minutes: 3 - run: SCHEME=ec /root/vitastor/tests/test_snapshot.sh - - name: Print logs - if: always() && steps.test.outcome == 'failure' - run: | - for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do - echo "-------- $i --------" - cat $i - echo "" - done - - test_splitbrain: - runs-on: ubuntu-latest - needs: build - container: ${{env.TEST_IMAGE}}:${{github.sha}} - steps: - - name: Run test - id: test - timeout-minutes: 3 - run: /root/vitastor/tests/test_splitbrain.sh - - name: Print logs - if: always() && steps.test.outcome == 'failure' - run: | - for i in /root/vitastor/testdata/*.log /root/vitastor/testdata/*.txt; do - echo "-------- $i --------" - cat $i - echo "" - done - test_write: runs-on: ubuntu-latest needs: build diff --git a/tests/run_tests.sh b/tests/run_tests.sh index dc0799e5..6e1ed89f 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -16,29 +16,32 @@ SCHEME=ec ./test_change_pg_count.sh ./test_etcd_fail.sh -./test_failure_domain.sh - ./test_interrupted_rebalance.sh IMMEDIATE_COMMIT=1 ./test_interrupted_rebalance.sh SCHEME=ec ./test_interrupted_rebalance.sh SCHEME=ec IMMEDIATE_COMMIT=1 ./test_interrupted_rebalance.sh +./test_failure_domain.sh + +./test_snapshot.sh +SCHEME=ec ./test_snapshot.sh + ./test_minsize_1.sh ./test_move_reappear.sh +./test_rm.sh + +./test_snapshot_chain.sh +SCHEME=ec ./test_snapshot_chain.sh + +./test_splitbrain.sh + ./test_rebalance_verify.sh IMMEDIATE_COMMIT=1 ./test_rebalance_verify.sh SCHEME=ec ./test_rebalance_verify.sh SCHEME=ec IMMEDIATE_COMMIT=1 ./test_rebalance_verify.sh -./test_rm.sh - -./test_snapshot.sh -SCHEME=ec ./test_snapshot.sh - -./test_splitbrain.sh - ./test_write.sh SCHEME=xor ./test_write.sh diff --git a/tests/test_snapshot_chain.sh b/tests/test_snapshot_chain.sh new file mode 100755 index 00000000..b1dad973 --- /dev/null +++ b/tests/test_snapshot_chain.sh @@ -0,0 +1,48 @@ +#!/bin/bash -ex + +. `dirname $0`/run_3osds.sh +check_qemu + +# Test multiple snapshots + +build/src/vitastor-cli --etcd_address $ETCD_URL create -s 32M testchain + +LD_PRELOAD="build/src/libfio_vitastor.so" \ + fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4M -direct=1 -iodepth=1 -fsync=1 -rw=write \ + -etcd=$ETCD_URL -image=testchain -mirror_file=./testdata/mirror.bin + +for i in {1..10}; do + # Create a snapshot + build/src/vitastor-cli --etcd_address $ETCD_URL snap-create testchain@$i + # Check that the new snapshot is see-through + qemu-img convert -p \ + -f raw "vitastor:etcd_host=127.0.0.1\:$ETCD_PORT/v3:image=testchain" \ + -O raw ./testdata/check.bin + cmp ./testdata/check.bin ./testdata/mirror.bin + # Write something to it + LD_PRELOAD="build/src/libfio_vitastor.so" \ + fio -thread -name=test -ioengine=build/src/libfio_vitastor.so -bs=4k -direct=1 -iodepth=1 -fsync=32 -rw=randwrite \ + -randrepeat=$((i <= 2)) -buffer_pattern=0x$((10+i))$((10+i))$((10+i))$((10+i)) \ + -etcd=$ETCD_URL -image=testchain -number_ios=1024 -mirror_file=./testdata/mirror.bin + # Check the new content + qemu-img convert -p \ + -f raw "vitastor:etcd_host=127.0.0.1\:$ETCD_PORT/v3:image=testchain" \ + -O raw ./testdata/layer1.bin + cmp ./testdata/layer1.bin ./testdata/mirror.bin +done + +build/src/vitastor-cli --etcd_address $ETCD_URL rm testchain@1 testchain@9 + +# Check the final image +qemu-img convert -p \ + -f raw "vitastor:etcd_host=127.0.0.1\:$ETCD_PORT/v3:image=testchain" \ + -O raw ./testdata/layer1.bin +cmp ./testdata/layer1.bin ./testdata/mirror.bin + +# Check the last remaining snapshot +qemu-img convert -p \ + -f raw "vitastor:etcd_host=127.0.0.1\:$ETCD_PORT/v3:image=testchain@10" \ + -O raw ./testdata/layer0.bin +cmp ./testdata/layer0.bin ./testdata/check.bin + +format_green OK