Jelajahi Sumber

:robot: Add file transfer to vpntest

Ettore Di Giacinto 3 tahun lalu
induk
melakukan
22276ad047
2 mengubah file dengan 46 tambahan dan 4 penghapusan
  1. 37 2
      .github/vpntest.sh
  2. 9 2
      .github/workflows/test.yml

+ 37 - 2
.github/vpntest.sh

@@ -1,5 +1,9 @@
 #!/bin/bash
 
+echo "Creating big file to send over"
+dd if=/dev/urandom of=big_file bs=1G count=2 iflag=fullblock
+sha256sum big_file > big_file.sha256
+
 ((count = 100))                        
 while [[ $count -ne 0 ]] ; do
     ping -c 1 $1                   
@@ -12,9 +16,40 @@ done
 
 if [[ $rc -eq 0 ]] ; then
     echo "Alright"
-    sleep 20
-    exit 0
 else
     echo "Test failed"
     exit 1
+fi
+
+host=$1
+
+if [ "$3" == "download" ]; then
+    set -e
+    echo "Downloading big file"
+    curl -v -L $host/big_file -O big_file
+    curl -v -L $host/big_file.sha256 -O big_file.sha256
+
+    echo "Verifying checksum"
+    sha256sum -c "big_file.sha256"
+
+    curl -X PUT http://localhost:8080/api/ledger/tests/vpn$2
+    sleep 30
+    curl -X PUT http://localhost:8080/api/ledger/tests/vpn$2
+
+    sleep 30
+
+else
+
+    set +e
+    ((count = 640))                        
+    while [[ $count -ne 0 ]] ; do
+        sleep 5
+        curl http://localhost:8080/api/ledger/tests/vpn$1 | grep "24"
+        rc=$?
+        if [[ $rc -eq 0 ]] ; then
+            ((count = 1))
+        fi
+        ((count = count - 1))
+    done
+
 fi

+ 9 - 2
.github/workflows/test.yml

@@ -79,8 +79,10 @@ jobs:
         include:
           - ip: "10.1.0.13/24"
             target_ip: "10.1.0.11"
+            role: "download"
           - ip: "10.1.0.11/24"
             target_ip: "10.1.0.13"
+            role: ""
     steps:
       - name: Checkout
         uses: actions/checkout@v2
@@ -98,10 +100,15 @@ jobs:
           path: ./
       - name: Ping test
         run: |
+              # Start caddy server to share file across nodes
+              docker run -d -p 80:80 \
+                -v $PWD/:/usr/share/caddy/ \
+                -v caddy_data:/data \
+                caddy
               chmod +x edgevpn
               sudo sysctl -w net.core.rmem_max=2500000
-              sudo EDGEVPNCONFIG=config.yaml IFACE=edgevpn0 ADDRESS=${{ matrix.ip }} ./edgevpn --api --log-level debug &
-              bash ./.github/vpntest.sh ${{ matrix.target_ip }}
+              sudo EDGEVPNCONFIG=config.yaml IFACE=edgevpn0 ADDRESS=${{ matrix.ip }} ./edgevpn --api --log-level debug --libp2p-log-level debug &
+              bash ./.github/vpntest.sh ${{ matrix.target_ip }} ${{ matrix.ip }} ${{ matrix.role }}
 
   servicestest:
     runs-on: ubuntu-latest