Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions testing/bats/helpers/test-helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ function skipIfNotLinux() {
fi
}

function skipIfPackageNotInstalled() {
if [[ "${FLUENTDO_AGENT_PACKAGE_INSTALLED:-}" != "true" ]]; then
skip 'Skipping test: package not installed'
fi
}

function skipIfCentos6() {
if [[ -f /etc/redhat-release ]] && grep -qi "centos.*6" /etc/redhat-release; then
skip 'Skipping test: detected CentOS 6'
Expand Down
1 change: 1 addition & 0 deletions testing/bats/run-package-functional-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ echo "INFO: running test container 'bats/test/$DISTRO'"
"${CONTAINER_RUNTIME}" run --rm -t \
-v "$DOWNLOAD_DIR:/downloads:ro" \
-e FLUENT_BIT_BINARY="$FLUENT_BIT_BINARY" \
-e FLUENTDO_AGENT_PACKAGE_INSTALLED=true \
"bats/test/$DISTRO"

echo "INFO: All tests complete"
7 changes: 4 additions & 3 deletions testing/bats/tests/functional/linux/verify-deb.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@ load "$BATS_FILE_ROOT/load.bash"

setup() {
skipIfNotLinux
skipIfPackageNotInstalled
if ! command -v dpkg &> /dev/null; then
skip "Skipping test: no dpkg command"
fi

export PACKAGE_NAME="fluentdo-agent"
if ! dpkg -s "$PACKAGE_NAME" ; then
skip "Skipping test: $PACKAGE_NAME DEB not installed"
fi
}

teardown() {
if [[ -n "${SKIP_TEARDOWN:-}" ]]; then
echo "Skipping teardown"
fi
if command -v dpkg &> /dev/null; then
run dpkg -l
fi
}

@test "DEB package is installed" {
Expand Down
16 changes: 7 additions & 9 deletions testing/bats/tests/functional/linux/verify-files.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ setup() {
export PACKAGE_NAME="fluentdo-agent"

# Ensure we skip tests in the container
if command -v rpm &>/dev/null; then
if ! rpm -qa | grep -q "$PACKAGE_NAME" ; then
skip "Skipping test: $PACKAGE_NAME RPM not installed"
fi
elif command -v dpkg &>/dev/null; then
if ! dpkg -s "$PACKAGE_NAME" ; then
skip "Skipping test: $PACKAGE_NAME DEB not installed"
fi
fi
skipIfPackageNotInstalled
}

teardown() {
if [[ -n "${SKIP_TEARDOWN:-}" ]]; then
echo "Skipping teardown"
fi
if command -v rpm &> /dev/null; then
run rpm -qa
fi
if command -v dpkg &> /dev/null; then
run dpkg -l
fi
}

# Packages should be structured like so:
Expand Down
6 changes: 2 additions & 4 deletions testing/bats/tests/functional/linux/verify-rpm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ load "$BATS_FILE_ROOT/load.bash"
# bats file_tags=functional,linux,package

setup() {
skipIfNotLinux
skipIfNotLinux
skipIfPackageNotInstalled
if ! command -v rpm &> /dev/null; then
skip "Skipping test: no RPM command"
fi

export PACKAGE_NAME="fluentdo-agent"
if ! rpm -qa | grep -q "$PACKAGE_NAME" ; then
skip "Skipping test: $PACKAGE_NAME RPM not installed"
fi
}

teardown() {
Expand Down
Loading