-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added first version of unit tests for the buildpack
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/sh | ||
|
||
. ${BUILDPACK_TEST_RUNNER_HOME}/lib/test_utils.sh | ||
|
||
|
||
getAvailableVersions() | ||
{ | ||
APT_DIR="$HOME/.apt" APT_CACHE_DIR="$CACHE_DIR/apt/cache" | ||
APT_STATE_DIR="$CACHE_DIR/apt/state" | ||
mkdir -p "$APT_CACHE_DIR/archives/partial" | ||
mkdir -p "$APT_STATE_DIR/lists/partial" | ||
mkdir -p "$APT_DIR" | ||
APT_REPO_FILE="${BUILDPACK_HOME}/etc/datadog.list" | ||
APT_OPTIONS="-o debug::nolocking=true -o dir::cache=$APT_CACHE_DIR -o dir::state=$APT_STATE_DIR -o Dir::Etc::SourceList=$APT_REPO_FILE" | ||
apt-get $APT_OPTIONS update | ||
AGENT_VERSIONS=$(apt-cache $APT_OPTIONS show datadog-agent | grep "Version: " | sed 's/Version: 1://g') | ||
} | ||
|
||
compileAndRunVersion() | ||
{ | ||
|
||
echo $1 > "${ENV_DIR}/DD_AGENT_VERSION" | ||
echo "Testing Datadog Agent version $1" | ||
compile | ||
assertCaptured "Installing dependencies" | ||
assertCaptured "Downloading Datadog Agent $1" | ||
assertCaptured "Installing Datadog Agent" | ||
assertCaptured "Installing Datadog runner" | ||
|
||
export HOME=${BUILD_DIR} | ||
chmod +x ${BUILDPACK_HOME}/extra/datadog.sh | ||
capture ${BUILDPACK_HOME}/extra/datadog.sh | ||
assertFileNotContains "error while loading shared libraries" ${STD_ERR} | ||
assertFileNotContains "Could not initialize Python" ${STD_ERR} | ||
assertCaptured "Starting Datadog Agent" | ||
assertCaptured "Starting Datadog Trace Agent" | ||
|
||
} | ||
|
||
testReleasedVersions() | ||
{ | ||
getAvailableVersions | ||
|
||
for VERSION in ${AGENT_VERSIONS}; do | ||
compileAndRunVersion $VERSION | ||
done | ||
} | ||
|
||
testLatestNightlyVersion() | ||
{ | ||
echo "deb [trusted=yes] http://apt.datad0g.com/ nightly main 6" > "${BUILDPACK_HOME}/etc/datadog.list" | ||
getAvailableVersions | ||
VERSION="$(echo ${AGENT_VERSIONS} | head -n1 | awk '{print $1;}')" | ||
|
||
compileAndRunVersion $VERSION | ||
|
||
} |