updater_checks.bats 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. kickstart_file="/tmp/kickstart.$$"
  35. curl -Ss -o ${kickstart_file} https://my-netdata.io/kickstart.sh
  36. chmod +x ${kickstart_file}
  37. ${kickstart_file} --dont-wait --dont-start-it --auto-update --install ${INSTALLATION}
  38. # Validate particular files
  39. for file in $FILES; do
  40. [ ! -f "$BATS_TMPDIR/$file" ]
  41. done
  42. # Validate particular directories
  43. for a_dir in $DIRS; do
  44. [ ! -d "$BATS_TMPDIR/$a_dir" ]
  45. done
  46. # Cleanup
  47. rm -rf ${kickstart_file}
  48. }
  49. @test "update netdata using the new updater" {
  50. export ENVIRONMENT_FILE="${ENV}"
  51. # Run the updater, with the override so that it uses the local repo we have at hand
  52. # Try to run the installed, if any, otherwise just run the one from the repo
  53. export NETDATA_LOCAL_TARBAL_OVERRIDE="${PWD}"
  54. /etc/cron.daily/netdata-updater || ./packaging/installer/netdata-updater.sh
  55. ! grep "new_installation" "${ENV}"
  56. }
  57. @test "uninstall netdata using latest uninstaller" {
  58. ./packaging/installer/netdata-uninstaller.sh --yes --force --env "${ENV}"
  59. [ ! -f "${INSTALLATION}/netdata/usr/sbin/netdata" ]
  60. [ ! -f "/etc/cron.daily/netdata-updater" ]
  61. }