Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1150)

Side by Side Diff: tests/100_deploy.test

Issue 56170043: uncomments open-port in start hook
Patch Set: Created 10 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« tests/00_setup.sh ('K') | « tests/00_setup.sh ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python3
2
3
4 # Author: Charles Butler <charles.butler@canonical.com>
5 # Deploys elasticsearch and logstash-indexer
6 # Validates relationship presence, issues HTTPS request against
7 # elasticsearch cluster to validate scale, cluster name
8
9
10
11
12
13 import amulet
14 import requests
15 import json
16
17 ##########################################
18 # Config Options
19 ##########################################
20 scale = 1
21 seconds = 900
22
23
24
25 ################################################################################ ###
26 #Deployment Setup
27 ################################################################################ ###
28
29
30
31 d = amulet.Deployment()
32
33 d.add('elasticsearch', units=scale)
34 d.add('logstash-indexer')
35 d.configure('elasticsearch', { 'cluster-name' : 'amulet-test' })
36 d.relate('elasticsearch:cluster', 'logstash-indexer:rest')
37 d.expose('elasticsearch')
38
39 print(json.dumps(d.schema(), indent=2))··
Marco Ceppi 2014/01/31 11:44:53 This is pretty much debugging, probably don't need
40
41 #perform deployment
42 try:·
43 d.setup(timeout=seconds)
44 except amulet.helpers.TimeoutError:
45 message = 'The environment did not setup in %d seconds.', seconds·
46 amulet.raise_status(amulet.SKIP, msg=message)
47 except:
48 raise
49
50
51
52
53
54 ################################################################################ ###
55 # Service Health Checks
56 ################################################################################ ###
57
58
59 # Elastic Search exposes a status RPC call, fetch the JSON and match against·
60 # the following example template for nodes, cluster_name and status:
61 #{
62 # "cluster_name" : "elasticsearch",
63 # "status" : "green",
64 # "timed_out" : false,
65 # "number_of_nodes" : 1,
66 # "number_of_data_nodes" : 1,
67 # "active_primary_shards" : 0,
68 # "active_shards" : 0,
69 # "relocating_shards" : 0,
70 # "initializing_shards" : 0,
71 # "unassigned_shards" : 0
72 #}
73
74
75 def healthcheck():
Marco Ceppi 2014/01/31 11:44:53 to avoid ambiguity with global variables, it might
76 es_unit = d.sentry.unit['elasticsearch/0']
77 es_address = es_unit.info['public-address']
78 ····
79 health = requests.get("http://{}:9200/_cluster/health".format(es_address), v erify=False)
80 # Must return 200OK to pass
81 health.raise_for_status
Marco Ceppi 2014/01/31 11:44:53 This is a function, not a key. health.raise_for_st
82 json_output = json.loads(health.content.decode())
Marco Ceppi 2014/01/31 11:44:53 json_output = health.json() would be better here
83
84
85
86 # Validate cluster name from config was set
87 if json_output['cluster_name'] != 'amulet-test':
88 amulet.raise_status(amulet.SKIP, msg="Configured cluster-name failed che ck")
Marco Ceppi 2014/01/31 11:44:53 This seems like a FAIL condition, not a SKIP
89 ····
90 # validate unit scale
91 if json_output['number_of_nodes'] != scale :
92 amulet.raise_status(amulet.SKIP, msg="Scale check failed, expected: {}, got: {}".format(scale, json_output['number_of_nodes']))
Marco Ceppi 2014/01/31 11:44:53 Again, seems like a FAIL if it didn't configure pr
93
94
95
96
97 ################################################################################ ###
98 # Relationship Checks·
99 ################################################################################ ###
100
101 def relationships():
102 #Raises an error if the relationship is not set·
103 d.sentry.unit['elasticsearch/0'].relation('cluster', 'logstash-indexer:rest' )
104
105
106 # Execute healthchecks before relationship check
107 healthcheck()
108 relationships()
109
110
OLDNEW
« tests/00_setup.sh ('K') | « tests/00_setup.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b