Skip to content

Commit 84c4294

Browse files
author
Derik Evangelista
committed
Add smoke_tests job
[#115143117] Signed-off-by: David Laing <[email protected]>
1 parent f2863ff commit 84c4294

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

jobs/smoke_tests/monit

Whitespace-only changes.

jobs/smoke_tests/spec

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: smoke-tests
3+
4+
packages: []
5+
templates:
6+
run.sh: bin/run
7+
8+
properties:
9+
smoke_tests.syslog_ingestor.host:
10+
description: 'IP of the syslog ingestor'
11+
smoke_tests.syslog_ingestor.port:
12+
description: 'Port of the syslog ingestor'
13+
default: 5514
14+
smoke_tests.elasticsearch_master.host:
15+
description: 'IP of the elasticsearch master node'
16+
smoke_tests.elasticsearch_master.port:
17+
description: 'Port of the elasticsearch master node'
18+
default: 9200

jobs/smoke_tests/templates/run.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
MASTER_URL="http://<%= p('smoke_tests.elasticsearch_master.host')%>:<%= p('smoke_tests.elasticsearch_master.port')%>"
4+
INGESTOR_HOST="<%= p('smoke_tests.syslog_ingestor.host')%>"
5+
INGESTOR_PORT="<%= p('smoke_tests.syslog_ingestor.port')%>"
6+
7+
SMOKE_ID=$(LC_ALL=C; cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
8+
LOG="<13>$(date -u +"%Y-%m-%dT%H:%M:%SZ") 0.0.0.0 smoke-test-errand [job=smoke_tests index=0] {\"smoke-id\":\"$SMOKE_ID\"}"
9+
10+
echo "SENDING $LOG"
11+
echo "$LOG" | nc $INGESTOR_HOST $INGESTOR_PORT
12+
13+
TRIES=${1:-60}
14+
15+
echo -n "Polling for $TRIES seconds"
16+
while [ $TRIES -gt 0 ]; do
17+
result=$(curl -s $MASTER_URL/_search?q=$SMOKE_ID)
18+
if [[ $result == *"$SMOKE_ID"* ]]; then
19+
echo -e "\nSUCCESS: Found log containing $SMOKE_ID"
20+
echo $result
21+
exit 0
22+
else
23+
sleep 1
24+
echo -n "."
25+
TRIES=$((TRIES-1))
26+
fi
27+
done
28+
29+
echo -e "\nERROR: Couldn't find log containing: $SMOKE_ID"
30+
echo "Last search result: $result"
31+
exit 1

templates/logsearch-jobs.yml

+16
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,22 @@ jobs:
221221
elasticsearch:
222222
master_node: (( grab jobs.elasticsearch_master.networks.default.static_ips.[0] ))
223223

224+
- name: smoke-tests
225+
instances: 1
226+
release: logsearch
227+
templates:
228+
- {name: smoke-tests, release: logsearch}
229+
resource_pool: errand
230+
networks:
231+
- name: default
232+
lifecycle: errand
233+
properties:
234+
smoke_tests:
235+
syslog_ingestor:
236+
host: (( grab jobs.haproxy.networks.default.static_ips.[0] ))
237+
elasticsearch_master:
238+
host: (( grab jobs.elasticsearch_master.networks.default.static_ips.[0] ))
239+
224240
properties:
225241
curator:
226242
elasticsearch_host: (( grab jobs.elasticsearch_master.networks.default.static_ips.[0] ))

0 commit comments

Comments
 (0)