diff --git a/.travis.yml b/.travis.yml index f44b4936..7df44101 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,10 @@ install: - sudo apt-get install linux-headers-$(uname -r) dkms gcc-multilib g++-multilib - pip install pyyaml requests script: +- bash test/start_agent.sh - bash test/test_monitor_apis.sh - bash test/test_secure_apis.sh +- bash test/stop_agent.sh notifications: slack: secure: GJ0H2wAaW67t3+x+cCjOVLw/b+YAZjH9rebAfluCFJklJS9u+V6/qqIyiNDAkMPIcgilFyhiyOQCZYXapgthQ1ieFbZZo//mrRtuGo2wuxCAwcOx2mXAZpZ4I5b3+Q/znVqSuqkwFRid1d138z4TW7sYSIburouDX3QUNoUOy+g7VJxCFQCcqlN8LYxGJHQYdOZa9zIGCtKrOtZ/B8C1TLgXmDMwAAVNO2WzL4GiBTLCGuMsQWMTLw2Qmv1ayZPztmeDWo1C9oa7HIH8Bg2YVjssR87el28X+EqEO533mgYjPmW2/hii30WVFOUE5hMdvKeQLBvy5N3/OCch1np0RQBd8eYEtaPv38rc5L2wAnUq9G5Zzr252z7vnwSLi6lap9jWU8tOerSTEPU+jG05PnuCnufVDXVNPyiPsH6BDP4qxHmLjooNpxfe63Df7NNyUi2I3QoroLj/UzI7zZVQjJEqsTrr5BbsH4z6NTGY91+ZqobBn62+hV3ESAam0ivQgC7s2AKko0qkKyIUGjj7ozU8ebo1UpagNvKC/J9szMqtdXJgKtG8BeonyLMeN6MEEyEvcMJbB4dCcfet+1Sb9AZWnGvYVdajhVLb1HE6OrbzZyhC3KqCe06J9O5BCY9ncy+l16i7MyIfcKTibHQlxPU+Id/VijD97JSRXxnd2i4= diff --git a/test/start_agent.sh b/test/start_agent.sh new file mode 100644 index 00000000..09cf19d5 --- /dev/null +++ b/test/start_agent.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euxo pipefail + +# Start an agent using the testing account API key to send some data +docker run -d -it --rm --name sysdig-agent --privileged --net host --pid host -e COLLECTOR=collector-staging.sysdigcloud.com -e ACCESS_KEY=$PYTHON_SDC_TEST_ACCESS_KEY -v /var/run/docker.sock:/host/var/run/docker.sock -v /dev:/host/dev -v /proc:/host/proc:ro -v /boot:/host/boot:ro -v /lib/modules:/host/lib/modules:ro -v /usr:/host/usr:ro --shm-size=350m sysdig/agent + +# make sure the agent starts sending data and the backend makes it available via API +sleep 60 diff --git a/test/stop_agent.sh b/test/stop_agent.sh new file mode 100644 index 00000000..359435fe --- /dev/null +++ b/test/stop_agent.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -euxo pipefail + +docker logs sysdig-agent +docker stop sysdig-agent diff --git a/test/test_monitor_apis.sh b/test/test_monitor_apis.sh index a9b5587e..29257c9c 100644 --- a/test/test_monitor_apis.sh +++ b/test/test_monitor_apis.sh @@ -7,10 +7,6 @@ SCRIPTDIR=$(dirname $SCRIPT) export SDC_URL=https://app-staging.sysdigcloud.com -docker run -d -it --rm --name sysdig-agent --privileged --net host --pid host -e COLLECTOR=collector-staging.sysdigcloud.com -e ACCESS_KEY=$PYTHON_SDC_TEST_ACCESS_KEY -v /var/run/docker.sock:/host/var/run/docker.sock -v /dev:/host/dev -v /proc:/host/proc:ro -v /boot:/host/boot:ro -v /lib/modules:/host/lib/modules:ro -v /usr:/host/usr:ro sysdig/agent - -sleep 20 - AGENT_HOSTNAME=$(hostname -s) SESSION_UUID=$(head -c 32 /dev/urandom | tr -dc 'a-zA-Z0-9') ALERT_NAME=python-test-alert-$SESSION_UUID @@ -49,6 +45,3 @@ date; $SCRIPTDIR/../examples/create_sysdig_capture.py $PYTHON_SDC_TEST_MONITOR_A date; $SCRIPTDIR/../examples/notification_channels.py -c $CHANNEL_NAME $PYTHON_SDC_TEST_MONITOR_API_TOKEN date; $SCRIPTDIR/../examples/user_team_mgmt.py $PYTHON_SDC_TEST_MONITOR_API_TOKEN $TEAM_NAME example-user@example-domain.com date; $SCRIPTDIR/../examples/user_team_mgmt_extended.py $PYTHON_SDC_TEST_MONITOR_API_TOKEN $TEAM_NAME example-user@example-domain.com - -docker stop sysdig-agent - diff --git a/test/test_secure_apis.sh b/test/test_secure_apis.sh index 203852b7..ba97d491 100644 --- a/test/test_secure_apis.sh +++ b/test/test_secure_apis.sh @@ -131,14 +131,12 @@ fi echo $OUT -# Start an agent using this account's api key and trigger some events -docker run -d -it --rm --name sysdig-agent --privileged --net host --pid host -e COLLECTOR=collector-staging.sysdigcloud.com -e ACCESS_KEY=$PYTHON_SDC_TEST_ACCESS_KEY -v /var/run/docker.sock:/host/var/run/docker.sock -v /dev:/host/dev -v /proc:/host/proc:ro -v /boot:/host/boot:ro -v /lib/modules:/host/lib/modules:ro -v /usr:/host/usr:ro -e ADDITIONAL_CONF="security: {enabled: true}\ncommandlines_capture: {enabled: true}\nmemdump: {enabled: true}" --shm-size=350m sysdig/agent - +# Trigger some events FOUND=0 for i in $(seq 10); do - sleep 10 sudo touch /bin/some-file.txt + sleep 10 EVTS=`$SCRIPTDIR/../examples/get_secure_policy_events.py $PYTHON_SDC_TEST_API_TOKEN 60` @@ -147,8 +145,6 @@ for i in $(seq 10); do break; fi done -docker logs sysdig-agent -docker stop sysdig-agent if [[ $FOUND == 0 ]]; then echo "Did not find any policy events after 10 attempts..."