updater_checks.bats 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. DIRS="usr/sbin/netdata
  17. etc/netdata
  18. usr/share/netdata
  19. usr/libexec/netdata
  20. var/cache/netdata
  21. var/lib/netdata
  22. var/log/netdata"
  23. setup() {
  24. # If we are not in netdata git repo, at the top level directory, fail
  25. TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
  26. CWD=$(git rev-parse --show-cdup || echo "")
  27. if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
  28. echo "Run as ./tests/$(basename "$0") from top level directory of git repository"
  29. exit 1
  30. fi
  31. }
  32. @test "install stable netdata using kickstart" {
  33. ./packaging/installer/kickstart.sh --dont-wait --dont-start-it --auto-update --install ${INSTALLATION}
  34. # Validate particular files
  35. for file in $FILES; do
  36. [ ! -f "$BATS_TMPDIR/$file" ]
  37. done
  38. # Validate particular directories
  39. for a_dir in $DIRS; do
  40. [ ! -d "$BATS_TMPDIR/$a_dir" ]
  41. done
  42. # Cleanup
  43. rm -rf ${kickstart_file}
  44. }
  45. @test "update netdata using the new updater" {
  46. export ENVIRONMENT_FILE="${ENV}"
  47. # Run the updater, with the override so that it uses the local repo we have at hand
  48. export NETDATA_LOCAL_TARBALL_OVERRIDE="${PWD}"
  49. ${INSTALLATION}/netdata/usr/libexec/netdata/netdata-updater.sh --not-running-from-cron
  50. ! grep "new_installation" "${ENV}"
  51. }
  52. @test "uninstall netdata using latest uninstaller" {
  53. ./packaging/installer/netdata-uninstaller.sh --yes --force --env "${ENV}"
  54. [ ! -f "${INSTALLATION}/netdata/usr/sbin/netdata" ]
  55. [ ! -f "/etc/cron.daily/netdata-updater" ]
  56. }