servicestest.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. ./edgevpn api &
  3. if [ $1 == "expose" ]; then
  4. ./edgevpn service-add testservice 127.0.0.1:8080 &
  5. ((count = 240))
  6. while [[ $count -ne 0 ]] ; do
  7. sleep 2
  8. curl http://localhost:8080/api/ledger/tests/services | grep "doneservice"
  9. rc=$?
  10. if [[ $rc -eq 0 ]] ; then
  11. ((count = 1))
  12. fi
  13. ((count = count - 1))
  14. done
  15. if [[ $rc -eq 0 ]] ; then
  16. echo "Alright"
  17. sleep 20
  18. exit 0
  19. else
  20. echo "Test failed"
  21. exit 1
  22. fi
  23. else
  24. ./edgevpn service-connect testservice :9090 &
  25. ((count = 240))
  26. while [[ $count -ne 0 ]] ; do
  27. sleep 2
  28. curl http://localhost:9090/ | grep "EdgeVPN"
  29. rc=$?
  30. if [[ $rc -eq 0 ]] ; then
  31. ((count = 1))
  32. fi
  33. ((count = count - 1))
  34. done
  35. if [[ $rc -eq 0 ]] ; then
  36. echo "Alright"
  37. curl -X PUT http://localhost:8080/api/ledger/tests/services/doneservice
  38. sleep 80
  39. exit 0
  40. else
  41. echo "Test failed"
  42. exit 1
  43. fi
  44. fi