updater_checks.bats 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env bats
  2. #
  3. # This script is responsible for validating
  4. # updater capabilities after a change
  5. #
  6. # Copyright: SPDX-License-Identifier: GPL-3.0-or-later
  7. #
  8. # Author : Pavlos Emm. Katsoulakis <paul@netdata.cloud)
  9. #
  10. INSTALLATION="$BATS_TMPDIR/installation"
  11. ENV="${INSTALLATION}/netdata/etc/netdata/.environment"
  12. # list of files which need to be checked. Path cannot start from '/'
  13. FILES="usr/libexec/netdata/plugins.d/go.d.plugin
  14. usr/libexec/netdata/plugins.d/charts.d.plugin
  15. usr/libexec/netdata/plugins.d/python.d.plugin
  16. usr/libexec/netdata/plugins.d/node.d.plugin"
  17. DIRS="usr/sbin/netdata
  18. etc/netdata
  19. usr/share/netdata
  20. usr/libexec/netdata
  21. var/cache/netdata
  22. var/lib/netdata
  23. var/log/netdata"
  24. setup() {
  25. # If we are not in netdata git repo, at the top level directory, fail
  26. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  27. CWD=$(git rev-parse --show-cdup || echo "")
  28. if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
  29. echo "Run as ./tests/$(basename "$0") from top level directory of git repository"
  30. exit 1
  31. fi
  32. }
  33. @test "install stable netdata using kickstart" {
  34. ./packaging/installer/kickstart.sh --dont-wait --dont-start-it --auto-update --install ${INSTALLATION}
  35. # Validate particular files
  36. for file in $FILES; do
  37. [ ! -f "$BATS_TMPDIR/$file" ]
  38. done
  39. # Validate particular directories
  40. for a_dir in $DIRS; do
  41. [ ! -d "$BATS_TMPDIR/$a_dir" ]
  42. done
  43. # Cleanup
  44. rm -rf ${kickstart_file}
  45. }
  46. @test "update netdata using the new updater" {
  47. export ENVIRONMENT_FILE="${ENV}"
  48. # Run the updater, with the override so that it uses the local repo we have at hand
  49. export NETDATA_LOCAL_TARBALL_OVERRIDE="${PWD}"
  50. ${INSTALLATION}/netdata/usr/libexec/netdata/netdata-updater.sh --not-running-from-cron
  51. ! grep "new_installation" "${ENV}"
  52. }
  53. @test "uninstall netdata using latest uninstaller" {
  54. ./packaging/installer/netdata-uninstaller.sh --yes --force --env "${ENV}"
  55. [ ! -f "${INSTALLATION}/netdata/usr/sbin/netdata" ]
  56. [ ! -f "/etc/cron.daily/netdata-updater" ]
  57. }