فهرست منبع

:wrench: ci: Add services test

Ettore Di Giacinto 3 سال پیش
والد
کامیت
90a6c2ed59
2فایلهای تغییر یافته به همراه80 افزوده شده و 0 حذف شده
  1. 52 0
      .github/servicestest.sh
  2. 28 0
      .github/workflows/test.yml

+ 52 - 0
.github/servicestest.sh

@@ -0,0 +1,52 @@
+#!/bin/bash
+./edgevpn api &
+
+if [ $1 == "expose" ]; then
+    ./edgevpn service-add --name "testservice" --remoteaddress "127.0.0.1:8080" &
+
+    ((count = 100))                        
+    while [[ $count -ne 0 ]] ; do
+        sleep 2
+        curl http://localhost:8080/api/ledger/tests/services | grep "doneservice"
+        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 service-connect --name "testservice" --srcaddress ":9090" &
+
+    ((count = 100))                        
+    while [[ $count -ne 0 ]] ; do
+        sleep 2
+        curl http://localhost:9090/ | grep "EdgeVPN"
+        rc=$?
+        if [[ $rc -eq 0 ]] ; then
+            ((count = 1))
+        fi
+        ((count = count - 1))
+    done
+
+    if [[ $rc -eq 0 ]] ; then
+        echo "Alright"
+        curl -X PUT http://localhost:8080/api/ledger/tests/services/doneservice
+        sleep 20
+        exit 0
+    else
+        echo "Test failed"
+        exit 1
+    fi
+fi
+
+

+ 28 - 0
.github/workflows/test.yml

@@ -69,6 +69,34 @@ jobs:
               sudo EDGEVPNCONFIG=config.yaml IFACE=edgevpn0 ADDRESS=${{ matrix.ip }} ./edgevpn &
               bash ./.github/vpntest.sh ${{ matrix.target_ip }}
 
+  servicestest:
+    runs-on: ubuntu-latest
+    needs: build
+    strategy:
+      matrix:
+        include:
+          - role: "expose"
+          - role: "connect"
+    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: Services test
+        run: |
+              chmod +x edgevpn
+              export EDGEVPNCONFIG=config.yaml
+              bash ./.github/servicestest.sh ${{ matrix.role }}
 
   filestest:
     runs-on: ubuntu-latest