Browse Source

:wrench: ci: Add file send/receive test

Ettore Di Giacinto 3 years ago
parent
commit
6d0bb46184
3 changed files with 74 additions and 2 deletions
  1. 42 0
      .github/filetest.sh
  2. 0 0
      .github/vpntest.sh
  3. 32 2
      .github/workflows/test.yml

+ 42 - 0
.github/filetest.sh

@@ -0,0 +1,42 @@
+#!/bin/bash
+./edgevpn api &
+
+if [ $1 == "sender" ]; then
+    echo "test" > $PWD/test
+
+    ./edgevpn file-send --name "test" --path $PWD/test &
+
+    ((count = 100))                        
+    while [[ $count -ne 0 ]] ; do
+        sleep 2
+        curl http://localhost:8080/api/ledger/tests/test | grep "done"
+        rc=$?
+        if [[ $rc -eq 0 ]] ; then
+            ((count = 1))
+        fi
+        ((count = count - 1))
+    done
+
+    if [[ $rc -eq 0 ]] ; then
+        echo "Alright"
+        sleep 20
+        exit 0
+    else
+        echo "Test failed"
+        exit 1
+    fi
+    
+else
+    ./edgevpn file-receive --name "test" --path $PWD/test
+
+    curl -X PUT http://localhost:8080/api/ledger/tests/test/done
+
+    t=$(cat $PWD/test)
+
+    if [ $t != "test" ]; then
+        echo "Failed test, returned $t"
+        exit 1
+    fi
+fi
+
+

+ 0 - 0
.github/test.sh → .github/vpntest.sh


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

@@ -38,7 +38,7 @@ jobs:
           path: edgevpn
           if-no-files-found: error
   
-  test:
+  vpntest:
     runs-on: ubuntu-latest
     needs: build
     strategy:
@@ -67,4 +67,34 @@ jobs:
         run: |
               chmod +x edgevpn
               sudo EDGEVPNCONFIG=config.yaml IFACE=edgevpn0 ADDRESS=${{ matrix.ip }} ./edgevpn &
-              bash ./.github/test.sh ${{ matrix.target_ip }}
+              bash ./.github/vpntest.sh ${{ matrix.target_ip }}
+
+
+  filestest:
+    runs-on: ubuntu-latest
+    needs: build
+    strategy:
+      matrix:
+        include:
+          - role: "sender"
+          - role: "receiver"
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+        with:
+          fetch-depth: 0
+      - name: Download result for build
+        uses: actions/download-artifact@v2
+        with:
+          name: connection
+          path: ./
+      - name: Download result for build
+        uses: actions/download-artifact@v2
+        with:
+          name: edgevpn
+          path: ./
+      - name: File test
+        run: |
+              chmod +x edgevpn
+              export EDGEVPNCONFIG=config.yaml
+              bash ./.github/filetest.sh ${{ matrix.role }}