0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-28 06:32:30 +00:00
netdata_netdata/tests/lifecycle.bats
Paul Emm. Katsoulakis d01b2620ea
Fix lifecycle script ()
* netdata/packaging/ci: stronger validations during install, add some comments, change validation of CWD

* netdata/packaging/ci: Add a lifecycle test to validate update from stable to latest works smooth

-> Add updater BATS script that does the trick for installing stable then migrating to latest using current code and not nightly
-> Integrate with travis
-> Rename /code to /netdata in travis, scripts will eventually expect the TLD of repo to be actually named netdata, so test will start failing later
-> Introduce a flag on the updater, so that it doesn't download the tarball, but it rather works with a local pre-defined directory. If a user wants
   to override the update process, so that it runs with a different repository he just needs to export NETDATA_LOCAL_TARBAL_OVERRIDE with the desired repo directory

* netdata/packaging/ci: Add required packages for it to run
2019-04-29 18:39:22 +03:00

61 lines
1.8 KiB
Bash
Executable file

#!/usr/bin/env bats
#
# Netdata installation lifecycle testing script.
# This is to validate the install, update and uninstall of netdata
#
# Copyright: SPDX-License-Identifier: GPL-3.0-or-later
#
# Author : Pavlos Emm. Katsoulakis <paul@netdata.cloud)
#
INSTALLATION="$BATS_TMPDIR/installation"
ENV="${INSTALLATION}/netdata/etc/netdata/.environment"
# list of files which need to be checked. Path cannot start from '/'
FILES="usr/libexec/netdata/plugins.d/go.d.plugin
usr/libexec/netdata/plugins.d/charts.d.plugin
usr/libexec/netdata/plugins.d/python.d.plugin
usr/libexec/netdata/plugins.d/node.d.plugin"
DIRS="usr/sbin/netdata
etc/netdata
usr/share/netdata
usr/libexec/netdata
var/cache/netdata
var/lib/netdata
var/log/netdata"
setup() {
# If we are not in netdata git repo, at the top level directory, fail
TOP_LEVEL=$(basename "$(git rev-parse --show-toplevel)")
CWD=$(git rev-parse --show-cdup || echo "")
if [ -n "${CWD}" ] || [ ! "${TOP_LEVEL}" == "netdata" ]; then
echo "Run as ./tests/lifecycle/$(basename "$0") from top level directory of git repository"
exit 1
fi
}
@test "install netdata" {
./netdata-installer.sh --dont-wait --dont-start-it --auto-update --install "${INSTALLATION}"
# Validate particular files
for file in $FILES; do
[ ! -f "$BATS_TMPDIR/$file" ]
done
# Validate particular directories
for a_dir in $DIRS; do
[ ! -d "$BATS_TMPDIR/$a_dir" ]
done
}
@test "update netdata" {
export ENVIRONMENT_FILE="${ENV}"
/etc/cron.daily/netdata-updater
! grep "new_installation" "${ENV}"
}
@test "uninstall netdata" {
./packaging/installer/netdata-uninstaller.sh --yes --force --env "${ENV}"
[ ! -f "${INSTALLATION}/netdata/usr/sbin/netdata" ]
[ ! -f "/etc/cron.daily/netdata-updater" ]
}