run.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
  3. options="--set global.image.version=someversion --set global.image.pullPolicy=Always"
  4. hpccchart=$scriptdir/../../helm/hpcc
  5. failed=0
  6. helm version
  7. echo Testing unmodified values file
  8. helm lint $hpccchart ${options} > results.txt 2> errors.txt
  9. if [ $? -ne 0 ]
  10. then
  11. echo Unmodified failed
  12. cat errors.txt
  13. cat results.txt
  14. failed=1
  15. fi
  16. echo Running valid tests...
  17. for file in $scriptdir/tests/*.yaml
  18. do
  19. helm lint $hpccchart ${options} --values $file > results.txt 2> errors.txt
  20. if [ $? -ne 0 ]
  21. then
  22. echo $file failed
  23. cat errors.txt
  24. cat results.txt
  25. failed=1
  26. fi
  27. done
  28. echo Running invalid tests...
  29. for file in $scriptdir/errtests/*.yaml
  30. do
  31. helm lint $hpccchart ${options} --values $file > results.txt 2> errors.txt
  32. if [ $? -eq 0 ]
  33. then
  34. echo $file should have failed
  35. failed=1
  36. else
  37. echo "$file failed - correctly"
  38. cat results.txt
  39. fi
  40. done
  41. if type kubeval >/dev/null 2> /dev/null; then
  42. echo Running kubeval...
  43. helm template $hpccchart ${options} | kubeval --strict - >results.txt 2>errors.txt
  44. if [ $? -ne 0 ]
  45. then
  46. echo $file failed
  47. cat errors.txt
  48. cat results.txt
  49. failed=1
  50. fi
  51. fi
  52. if type kube-score >/dev/null 2> /dev/null; then
  53. echo Running kube-score...
  54. # Note we force all replicas to be > 1 as some checks are not done on replicas=1 cases e.g. antiaffinity
  55. helm template $hpccchart ${options} | sed "s/replicas: 1/replicas: 2/" | kube-score score --output-format ci - >results.txt 2>errors.txt
  56. if [ $? -ne 0 ]
  57. then
  58. echo $file failed
  59. cat errors.txt
  60. cat results.txt
  61. failed=1
  62. fi
  63. fi
  64. exit $failed