4
from pymongo import MongoClient
8
d = amulet.Deployment(series='trusty')
9
d.add('mongodb', charm='mongodb')
12
# Perform the setup for the deployment.
15
d.sentry.wait(seconds)
16
except amulet.helpers.TimeoutError:
17
message = 'The environment did not setup in %d seconds.', seconds
18
amulet.raise_status(amulet.SKIP, msg=message)
23
############################################################
24
# Validate connectivity from $WORLD
25
#############################################################
26
def validate_world_connectivity():
27
client = MongoClient(d.sentry.unit['mongodb/0'].info['public-address'])
30
# Can we successfully insert?
31
insert_id = db.amulet.insert({'assert': True})
33
amulet.raise_status(amulet.FAIL, msg="Failed to insert test data")
34
# Can we delete from a shard using the Mongos hub?
35
result = db.amulet.remove(insert_id)
36
if result['err'] is not None:
37
amulet.raise_status(amulet.FAIL, msg="Failed to remove test data")
40
validate_world_connectivity()