~michael.nelson/charms/trusty/logstash/trunk

« back to all changes in this revision

Viewing changes to tests/10-deploy

  • Committer: Charles Butler
  • Date: 2014-07-24 13:26:45 UTC
  • Revision ID: chuck@dasroot.net-20140724132645-zg5ftylvawun1iue
Validated the rabbit install. tests fail due to the sentinels being dumb. no idea what to do here for now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import amulet
4
4
import requests
5
5
 
6
 
d = amulet.Deployment()
 
6
d = amulet.Deployment(series='trusty')
7
7
 
 
8
d.add('elasticsearch', 'cs:trusty/elasticsearch')
 
9
d.add('rabbitmq-server', 'cs:trusty/rabbitmq-server')
8
10
d.add('logstash')
 
11
 
9
12
d.expose('logstash')
10
13
 
 
14
# declare empty configurations to force amulet to recognize the deployment
 
15
d.configure('logstash', {})
 
16
d.configure('elasticsearch', {})
 
17
d.configure('rabbitmq-server', {})
 
18
 
 
19
d.relate('logstash:client', 'elasticsearch:client')
 
20
 
11
21
try:
12
22
    d.setup(timeout=900)
13
23
    d.sentry.wait()
16
26
except:
17
27
    raise
18
28
 
19
 
unit = d.sentry.unit['logstash/0']
 
29
esunit = d.sentry.unit['elasticsearch/0']
20
30
 
21
 
# test we can access over http
22
 
page = requests.get('http://{}'.format(unit.info['public-address']))
 
31
# test we can access ES Status Port
 
32
page = requests.get('http://{}:9200'.format(esunit.info['public-address']))
23
33
page.raise_for_status()
24
34
 
25
35
 
 
36
# get LogStash output config
 
37
lsunit = d.sentry.unit['logstash/0']
 
38
esconf = lsunit.file_contents('/opt/logstash/conf.d/output-elasticsearch.conf')
 
39
print(esconf)
 
40
if esunit.info['public-address'] not in esconf:
 
41
    amulet.raise_status(amulet.FAIL, "Unable to validate ES as backend")
 
42
 
 
43
rabunit = d.sentry.unit['rabbitmq-server/0']
 
44
rabconf = lsunit.file_contents('/opt/logstash/conf.d/input_rabbit.conf')
 
45
print(rabconf)
 
46
if rabunit.info['public-address'] not in rabconf:
 
47
    amulet.raise_status(amulet.FAIL, "Unable to validate RabbitMQ integration")
 
48
 
26
49
# Now you can use d.sentry.unit[UNIT] to address each of the units and perform
27
50
# more in-depth steps. There are three test statuses: amulet.PASS, amulet.FAIL,
28
51
# and amulet.SKIP - these can be triggered with amulet.raise_status(). Each