Skip to content

Commit a15376e

Browse files
author
Davide Schiera
authored
Consolidate and simplify tests using Sysdig agent (#79)
1. Use a single command line to launch Sysdig agent container 2. Wait longer after the launch, to make data is made available via Sysdig API 3. Simplify test for policy events (wait longer instead of polling)
1 parent 82f89ad commit a15376e

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ install:
77
- sudo apt-get install linux-headers-$(uname -r) dkms gcc-multilib g++-multilib
88
- pip install pyyaml requests
99
script:
10+
- bash test/start_agent.sh
1011
- bash test/test_monitor_apis.sh
1112
- bash test/test_secure_apis.sh
13+
- bash test/stop_agent.sh
1214
notifications:
1315
slack:
1416
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=

test/start_agent.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
# Start an agent using the testing account API key to send some data
6+
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
7+
8+
# make sure the agent starts sending data and the backend makes it available via API
9+
sleep 60

test/stop_agent.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
docker logs sysdig-agent
6+
docker stop sysdig-agent

test/test_monitor_apis.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ SCRIPTDIR=$(dirname $SCRIPT)
77

88
export SDC_URL=https://app-staging.sysdigcloud.com
99

10-
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
11-
12-
sleep 20
13-
1410
AGENT_HOSTNAME=$(hostname -s)
1511
SESSION_UUID=$(head -c 32 /dev/urandom | tr -dc 'a-zA-Z0-9')
1612
ALERT_NAME=python-test-alert-$SESSION_UUID
@@ -49,6 +45,3 @@ date; $SCRIPTDIR/../examples/create_sysdig_capture.py $PYTHON_SDC_TEST_MONITOR_A
4945
date; $SCRIPTDIR/../examples/notification_channels.py -c $CHANNEL_NAME $PYTHON_SDC_TEST_MONITOR_API_TOKEN
5046
date; $SCRIPTDIR/../examples/user_team_mgmt.py $PYTHON_SDC_TEST_MONITOR_API_TOKEN $TEAM_NAME [email protected]
5147
date; $SCRIPTDIR/../examples/user_team_mgmt_extended.py $PYTHON_SDC_TEST_MONITOR_API_TOKEN $TEAM_NAME [email protected]
52-
53-
docker stop sysdig-agent
54-

test/test_secure_apis.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,12 @@ fi
131131

132132
echo $OUT
133133

134-
# Start an agent using this account's api key and trigger some events
135-
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
136-
134+
# Trigger some events
137135
FOUND=0
138136

139137
for i in $(seq 10); do
140-
sleep 10
141138
sudo touch /bin/some-file.txt
139+
sleep 10
142140

143141
EVTS=`$SCRIPTDIR/../examples/get_secure_policy_events.py $PYTHON_SDC_TEST_API_TOKEN 60`
144142

@@ -147,8 +145,6 @@ for i in $(seq 10); do
147145
break;
148146
fi
149147
done
150-
docker logs sysdig-agent
151-
docker stop sysdig-agent
152148

153149
if [[ $FOUND == 0 ]]; then
154150
echo "Did not find any policy events after 10 attempts..."

0 commit comments

Comments
 (0)