From 62a88a47c71ebdcc97af5c693c60dc5ac552f04a Mon Sep 17 00:00:00 2001 From: Ermine Jose Date: Mon, 28 Oct 2024 23:43:14 +0530 Subject: [PATCH 1/3] test: add vault CLI testcases --- .github/workflows/merge.yml | 134 +++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index db89c867be..007218429a 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -16,6 +16,16 @@ env: GENESIS_SK: 5ec88891c1098a0fede5b98b07f8abc931d7247b7aa310d21ab430cc957f9f02 jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Display Python version + run: python --version + cargo-udeps: if: "!startsWith(github.event.head_commit.message, 'chore(release):')" name: Unused dependency check @@ -142,7 +152,6 @@ jobs: # of proptesting # we do many more runs on the nightly run PROPTEST_CASES: 50 - e2e: if: "!startsWith(github.event.head_commit.message, 'chore(release):')" name: E2E tests @@ -340,6 +349,129 @@ jobs: SN_LOG: "v" timeout-minutes: 2 + - name: Estimate cost to create a vault + run: | + echo "test-file" > upload-test.txt + ./target/release/autonomi --log-output-dest=data-dir file upload ./upload-test.txt + ./target/release/autonomi --log-output-dest=data-dir register create sample_new_register 1234 + ./target/release/autonomi --log-output-dest=data-dir vault cost + ./target/release/autonomi --log-output-dest=data-dir file list 2>&1 | tee file_list.txt + ./target/release/autonomi --log-output-dest=data-dir register list 2>&1 | tee register_list.txt + env: + SN_LOG: "v" + timeout-minutes: 2 + + - name: create a vault with existing user data as above + run: | + ./target/release/autonomi --log-output-dest=data-dir vault create + ./target/release/autonomi --log-output-dest=data-dir vault load 2>&1 | tee vault_data.txt + env: + SN_LOG: "v" + timeout-minutes: 2 + + - name: vault create validation + run: | + NUM_OF_PUBLIC_FILES=`cat file_list.txt | grep "public" | grep -o '[0-9]\+'` + NUM_OF_PRIVATE_FILES=`cat file_list.txt | grep "private" | grep -o '[0-9]\+'` + NUM_OF_REGISTERS=`cat register_list.txt | grep "register" | grep -o '[0-9]\+'` + + NUM_OF_PUBLIC_FILES_IN_VAULT=`cat vault_data.txt | grep "public" | grep -o '[0-9]\+'` + NUM_OF_PRIVATE_FILES_IN_VAULT=`cat vault_data.txt| grep "private" | grep -o '[0-9]\+'` + NUM_OF_REGISTERS_IN_VAULT=`cat vault_data.txt| grep "register" | grep -o '[0-9]\+'` + + rm -rf file_list.txt register_list.txt vault_data.txt + + + python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT + + python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_PRIVATE_FILES $NUM_OF_PRIVATE_FILES_IN_VAULT + + python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_REGISTERS $NUM_OF_REGISTERS_IN_VAULT + + echo "vault created successfully!" + env: + SN_LOG: "v" + timeout-minutes: 4 + + - name: add more files and registers + run: | + echo "testing-file2" > sync-test.txt + ./target/release/autonomi --log-output-dest=data-dir file upload ./sync-test.txt + ./target/release/autonomi --log-output-dest=data-dir register create sample_new_register_2 12345 + env: + SN_LOG: "v" + timeout-minutes: 2 + + - name: sync the vault + run: ./target/release/autonomi --log-output-dest=data-dir vault sync + env: + SN_LOG: "v" + timeout-minutes: 2 + + - name: vault sync validation + run: | + NUM_OF_PUBLIC_FILES="" + NUM_OF_PRIVATE_FILES="" + NUM_OF_REGISTERS="" + NUM_OF_PUBLIC_FILES_IN_VAULT="" + NUM_OF_PRIVATE_FILES_IN_VAULT="" + NUM_OF_REGISTERS_IN_VAULT="" + + ./target/release/autonomi --log-output-dest=data-dir file list 2>&1 | tee file_list.txt + ./target/release/autonomi --log-output-dest=data-dir register list 2>&1 | tee register_list.txt + + NUM_OF_PUBLIC_FILES=`cat file_list.txt | grep "public" | grep -o '[0-9]\+'` + NUM_OF_PRIVATE_FILES=`cat file_list.txt | grep "private" | grep -o '[0-9]\+'` + NUM_OF_REGISTERS=`cat register_list.txt | grep "register" | grep -o '[0-9]\+'` + + ./target/release/autonomi --log-output-dest=data-dir vault load 2>&1 | tee vault_data.txt + + NUM_OF_PUBLIC_FILES_IN_VAULT=`cat vault_data.txt | grep "public" | grep -o '[0-9]\+'` + NUM_OF_PRIVATE_FILES_IN_VAULT=`cat vault_data.txt| grep "private" | grep -o '[0-9]\+'` + NUM_OF_REGISTERS_IN_VAULT=`cat vault_data.txt| grep "register" | grep -o '[0-9]\+'` + + rm -rf file_list.txt register_list.txt vault_data.txt + + python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT + + python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_PRIVATE_FILES $NUM_OF_PRIVATE_FILES_IN_VAULT + + python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_REGISTERS $NUM_OF_REGISTERS_IN_VAULT + + echo "vault synced successfully!" + env: + SN_LOG: "v" + timeout-minutes: 2 + + - name: load an existing vault from the network + run: ./target/release/autonomi --log-output-dest=data-dir vault load + env: + SN_LOG: "v" + timeout-minutes: 2 + + - name: Time profiling for Different files + run: | + # 1 MB + python3 -c "with open('random_1MB.bin', 'wb') as f: f.write(bytearray([0xff] * 1 * 1024 * 1024))" + # 10 MB + python3 -c "with open('random_10MB.bin', 'wb') as f: f.write(bytearray([0xff] * 10 * 1024 * 1024))" + # 100 MB + python3 -c "with open('random_100MB.bin', 'wb') as f: f.write(bytearray([0xff] * 100 * 1024 * 1024))" + # 1 GB + python3 -c "with open('random_1GB.bin', 'wb') as f: f.write(bytearray([0xff] * 1000 * 1024 * 1024))" + + ./target/release/autonomi --log-output-dest=data-dir file list + time ./target/release/autonomi --log-output-dest=data-dir file upload random_1MB.bin + time ./target/release/autonomi --log-output-dest=data-dir file upload random_10MB.bin + time ./target/release/autonomi --log-output-dest=data-dir file upload random_100MB.bin + time ./target/release/autonomi --log-output-dest=data-dir file upload random_1GB.bin + + rm -rf random*.bin + + env: + SN_LOG: "v" + timeout-minutes: 10 + - name: Stop the local network and upload logs if: always() uses: maidsafe/sn-local-testnet-action@main From 561656a77980e0c91efc27c2efd4e622cc3925bd Mon Sep 17 00:00:00 2001 From: Ermine Jose Date: Wed, 30 Oct 2024 16:32:46 +0530 Subject: [PATCH 2/3] test: fix conditional checks --- .github/workflows/merge.yml | 52 ++++++++++++------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 007218429a..1a81143b41 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -350,6 +350,7 @@ jobs: timeout-minutes: 2 - name: Estimate cost to create a vault + if: matrix.os != 'windows-latest' run: | echo "test-file" > upload-test.txt ./target/release/autonomi --log-output-dest=data-dir file upload ./upload-test.txt @@ -362,6 +363,7 @@ jobs: timeout-minutes: 2 - name: create a vault with existing user data as above + if: matrix.os != 'windows-latest' run: | ./target/release/autonomi --log-output-dest=data-dir vault create ./target/release/autonomi --log-output-dest=data-dir vault load 2>&1 | tee vault_data.txt @@ -369,40 +371,21 @@ jobs: SN_LOG: "v" timeout-minutes: 2 - - name: vault create validation - run: | - NUM_OF_PUBLIC_FILES=`cat file_list.txt | grep "public" | grep -o '[0-9]\+'` - NUM_OF_PRIVATE_FILES=`cat file_list.txt | grep "private" | grep -o '[0-9]\+'` - NUM_OF_REGISTERS=`cat register_list.txt | grep "register" | grep -o '[0-9]\+'` - - NUM_OF_PUBLIC_FILES_IN_VAULT=`cat vault_data.txt | grep "public" | grep -o '[0-9]\+'` - NUM_OF_PRIVATE_FILES_IN_VAULT=`cat vault_data.txt| grep "private" | grep -o '[0-9]\+'` - NUM_OF_REGISTERS_IN_VAULT=`cat vault_data.txt| grep "register" | grep -o '[0-9]\+'` - - rm -rf file_list.txt register_list.txt vault_data.txt - - - python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT - - python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_PRIVATE_FILES $NUM_OF_PRIVATE_FILES_IN_VAULT - - python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_REGISTERS $NUM_OF_REGISTERS_IN_VAULT - - echo "vault created successfully!" - env: - SN_LOG: "v" - timeout-minutes: 4 - - - name: add more files and registers + - name: add more files + if: matrix.os != 'windows-latest' run: | - echo "testing-file2" > sync-test.txt - ./target/release/autonomi --log-output-dest=data-dir file upload ./sync-test.txt - ./target/release/autonomi --log-output-dest=data-dir register create sample_new_register_2 12345 + for i in {1..100}; do + dd if=/dev/urandom of=random_file_$i.bin bs=1M count=1 status=none + ./target/release/autonomi --log-output-dest=data-dir file upload random_file_$i.bin --public + ./target/release/autonomi --log-output-dest=data-dir file upload random_file_$i.bin + ./target/release/autonomi --log-output-dest=data-dir register create $i random_file_$i.bin + done env: SN_LOG: "v" timeout-minutes: 2 - name: sync the vault + if: matrix.os != 'windows-latest' run: ./target/release/autonomi --log-output-dest=data-dir vault sync env: SN_LOG: "v" @@ -432,18 +415,16 @@ jobs: rm -rf file_list.txt register_list.txt vault_data.txt - python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT - - python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_PRIVATE_FILES $NUM_OF_PRIVATE_FILES_IN_VAULT - - python3 -c 'import sys; print("Equal" if sys.argv[1] == sys.argv[2] else "Not Equal")' $NUM_OF_REGISTERS $NUM_OF_REGISTERS_IN_VAULT - + python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: {sys.argv[1]} and {sys.argv[2]} are Not Equal"' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT + python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: {sys.argv[1]} and {sys.argv[2]} are Not Equal"' $NUM_OF_PRIVATE_FILES $NUM_OF_PRIVATE_FILES_IN_VAULT + python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: {sys.argv[1]} and {sys.argv[2]} are Not Equal"' $NUM_OF_REGISTERS $NUM_OF_REGISTERS_IN_VAULT echo "vault synced successfully!" env: SN_LOG: "v" timeout-minutes: 2 - name: load an existing vault from the network + if: matrix.os != 'windows-latest' run: ./target/release/autonomi --log-output-dest=data-dir vault load env: SN_LOG: "v" @@ -465,8 +446,9 @@ jobs: time ./target/release/autonomi --log-output-dest=data-dir file upload random_10MB.bin time ./target/release/autonomi --log-output-dest=data-dir file upload random_100MB.bin time ./target/release/autonomi --log-output-dest=data-dir file upload random_1GB.bin - + ./target/release/autonomi --log-output-dest=data-dir vault sync rm -rf random*.bin + rm -rf ${{ matrix.safe_path }}/autonomi env: SN_LOG: "v" From 5fb5a0dc460c73be1c8e133270216b189afe1f7a Mon Sep 17 00:00:00 2001 From: Ermine Jose Date: Thu, 31 Oct 2024 16:59:47 +0530 Subject: [PATCH 3/3] test: increase timeout --- .github/workflows/merge.yml | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 1a81143b41..47ddd0dc5b 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -152,6 +152,7 @@ jobs: # of proptesting # we do many more runs on the nightly run PROPTEST_CASES: 50 + e2e: if: "!startsWith(github.event.head_commit.message, 'chore(release):')" name: E2E tests @@ -364,9 +365,7 @@ jobs: - name: create a vault with existing user data as above if: matrix.os != 'windows-latest' - run: | - ./target/release/autonomi --log-output-dest=data-dir vault create - ./target/release/autonomi --log-output-dest=data-dir vault load 2>&1 | tee vault_data.txt + run: ./target/release/autonomi --log-output-dest=data-dir vault create env: SN_LOG: "v" timeout-minutes: 2 @@ -382,7 +381,7 @@ jobs: done env: SN_LOG: "v" - timeout-minutes: 2 + timeout-minutes: 25 - name: sync the vault if: matrix.os != 'windows-latest' @@ -392,6 +391,7 @@ jobs: timeout-minutes: 2 - name: vault sync validation + if: matrix.os != 'windows-latest' run: | NUM_OF_PUBLIC_FILES="" NUM_OF_PRIVATE_FILES="" @@ -400,28 +400,33 @@ jobs: NUM_OF_PRIVATE_FILES_IN_VAULT="" NUM_OF_REGISTERS_IN_VAULT="" - ./target/release/autonomi --log-output-dest=data-dir file list 2>&1 | tee file_list.txt - ./target/release/autonomi --log-output-dest=data-dir register list 2>&1 | tee register_list.txt - + ./target/release/autonomi --log-output-dest=data-dir file list 2>&1 > file_list.txt + + # ./target/release/autonomi --log-output-dest=data-dir register list | grep archives > register_list.txt + NUM_OF_PUBLIC_FILES=`cat file_list.txt | grep "public" | grep -o '[0-9]\+'` NUM_OF_PRIVATE_FILES=`cat file_list.txt | grep "private" | grep -o '[0-9]\+'` NUM_OF_REGISTERS=`cat register_list.txt | grep "register" | grep -o '[0-9]\+'` - ./target/release/autonomi --log-output-dest=data-dir vault load 2>&1 | tee vault_data.txt + ./target/release/autonomi --log-output-dest=data-dir vault load 2>&1 > vault_data.txt NUM_OF_PUBLIC_FILES_IN_VAULT=`cat vault_data.txt | grep "public" | grep -o '[0-9]\+'` NUM_OF_PRIVATE_FILES_IN_VAULT=`cat vault_data.txt| grep "private" | grep -o '[0-9]\+'` - NUM_OF_REGISTERS_IN_VAULT=`cat vault_data.txt| grep "register" | grep -o '[0-9]\+'` + # NUM_OF_REGISTERS_IN_VAULT=`cat vault_data.txt | grep "register" | grep -o '[0-9]\+'` + echo "Total Num of local public files is $NUM_OF_PUBLIC_FILES and in vault is $NUM_OF_PUBLIC_FILES_IN_VAULT" + echo "Total Num of local private files is $NUM_OF_PRIVATE_FILES and in vault is $NUM_OF_PRIVATE_FILES_IN_VAULT" + # echo "Total Num of local registers is $NUM_OF_REGISTERS and in vault is $NUM_OF_REGISTERS_IN_VAULT" + rm -rf file_list.txt register_list.txt vault_data.txt - python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: {sys.argv[1]} and {sys.argv[2]} are Not Equal"' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT - python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: {sys.argv[1]} and {sys.argv[2]} are Not Equal"' $NUM_OF_PRIVATE_FILES $NUM_OF_PRIVATE_FILES_IN_VAULT - python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: {sys.argv[1]} and {sys.argv[2]} are Not Equal"' $NUM_OF_REGISTERS $NUM_OF_REGISTERS_IN_VAULT + python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: Local public Files: {sys.argv[1]} and vault public files: {sys.argv[2]} are Not Equal"' $NUM_OF_PUBLIC_FILES $NUM_OF_PUBLIC_FILES_IN_VAULT + python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: Local private Files: {sys.argv[1]} and vault private files: {sys.argv[2]} are Not Equal"' $NUM_OF_PRIVATE_FILES $NUM_OF_PRIVATE_FILES_IN_VAULT + # python3 -c 'import sys; assert sys.argv[1] == sys.argv[2], f"Error: Local registers: {sys.argv[1]} and vault registers: {sys.argv[2]} are Not Equal"' $NUM_OF_REGISTERS $NUM_OF_REGISTERS_IN_VAULT echo "vault synced successfully!" env: SN_LOG: "v" - timeout-minutes: 2 + timeout-minutes: 15 - name: load an existing vault from the network if: matrix.os != 'windows-latest' @@ -431,6 +436,7 @@ jobs: timeout-minutes: 2 - name: Time profiling for Different files + if: matrix.os != 'windows-latest' run: | # 1 MB python3 -c "with open('random_1MB.bin', 'wb') as f: f.write(bytearray([0xff] * 1 * 1024 * 1024))" @@ -448,11 +454,10 @@ jobs: time ./target/release/autonomi --log-output-dest=data-dir file upload random_1GB.bin ./target/release/autonomi --log-output-dest=data-dir vault sync rm -rf random*.bin - rm -rf ${{ matrix.safe_path }}/autonomi - + rm -rf ${{ matrix.safe_path }}/autonomi env: SN_LOG: "v" - timeout-minutes: 10 + timeout-minutes: 15 - name: Stop the local network and upload logs if: always()