diff options
| author | jrwren@xmtp.net <> | 2015-11-18 23:09:47 -0500 |
|---|---|---|
| committer | jrwren@xmtp.net <> | 2015-11-18 23:09:47 -0500 |
| commit | d24fcdd584faf6d609292c9e5c832342d55af72c (patch) | |
| tree | 4d9b02fcda398e5249f0ca1305383026b6f61b3e /tests | |
| parent | 0cf9c3401e6f2c6727efe5234b3d705497ab60e8 (diff) | |
fix broken amulet tests
we do not know which is master, cannot assume it is /0, so try 0 and if it fails try /1. enable ipv6 in mongodb. We cannot know which provider is being used and if the public-address may be ipv6, so we must enable ipv6
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/02_deploy_shard_test.py | 22 | ||||
| -rwxr-xr-x | tests/03_deploy_replicaset.py | 20 | ||||
| -rwxr-xr-x | tests/04_deploy_with_storage.py | 9 |
3 files changed, 39 insertions, 12 deletions
diff --git a/tests/02_deploy_shard_test.py b/tests/02_deploy_shard_test.py index 5d311b4..c93ea2d 100755 --- a/tests/02_deploy_shard_test.py +++ b/tests/02_deploy_shard_test.py @@ -85,7 +85,10 @@ def validate_running_services(): # Validate connectivity from $WORLD ############################################################# def validate_world_connectivity(): - client = MongoClient(d.sentry['mongos'][0].info['public-address']) + pubaddy = d.sentry['mongos'][0].info['public-address'] + if ":" in pubaddy: + pubaddy = "[{}]".format(pubaddy) + client = MongoClient(pubaddy) db = client['test'] # Can we successfully insert? @@ -110,16 +113,21 @@ def validate_relationships(): def validate_manual_connection(): - output, code = d.sentry['shard1'][0].run("mongo {}".format( - d.sentry['mongos'][0].info['public-address'])) + fmt = "mongo {}" + addy = d.sentry['mongos'][0].info['public-address'] + if ":" in addy: + fmt = "mongo --ipv6 {}:27017" + jujuruncmd = fmt.format(addy) + output, code = d.sentry['shard1'][0].run(jujuruncmd) if code != 0: - message = "Manual Connection failed for unit shard1" + message = ("Manual Connection failed for unit shard1:{} code:{} cmd:{}". + format( output, code, jujuruncmd)) amulet.raise_status(amulet.SKIP, msg=message) - output, code = d.sentry['shard2'][0].run("mongo {}".format( - d.sentry['mongos'][0].info['public-address'])) + output, code = d.sentry['shard2'][0].run(jujuruncmd) if code != 0: - message = "Manual Connection failed for unit shard2" + message = ("Manual Connection failed for unit shard2:{} code:{} cmd:{}". + format( output, code, jujuruncmd)) amulet.raise_status(amulet.SKIP, msg=message) diff --git a/tests/03_deploy_replicaset.py b/tests/03_deploy_replicaset.py index 2be0d79..147ca83 100755 --- a/tests/03_deploy_replicaset.py +++ b/tests/03_deploy_replicaset.py @@ -77,7 +77,10 @@ def validate_replicaset_setup(): unit_status = [] for service in sentry_dict: - client = MongoClient(sentry_dict[service].info['public-address']) + addy = sentry_dict[service].info['public-address'] + if ":" in addy: + addy = "[{}]".format(addy) + client = MongoClient(addy) r = client.admin.command('replSetGetStatus') unit_status.append(r['myState']) client.close() @@ -98,11 +101,22 @@ def validate_replicaset_setup(): ############################################################# def validate_world_connectivity(): print(d.sentry['mongodb']) - client = MongoClient(d.sentry['mongodb'][1].info['public-address']) + addy = d.sentry['mongodb'][0].info['public-address'] + if ":" in addy: + addy = "[{}]".format(addy) + client = MongoClient(addy) db = client['test'] # Can we successfully insert? - insert_id = db.amulet.insert({'assert': True}) + try: + insert_id = db.amulet.insert({'assert': True}) + except: + print("could not insert to unit 0, trying unit 1") + addy = d.sentry['mongodb'][0].info['public-address'] + if ":" in addy: + addy = "[{}]".format(addy) + client = MongoClient(addy) + insert_id = client['test'].amulet.insert({'assert': True}) if insert_id is None: amulet.raise_status(amulet.FAIL, msg="Failed to insert test data") # Can we delete from a shard using the Mongos hub? diff --git a/tests/04_deploy_with_storage.py b/tests/04_deploy_with_storage.py index 9fbaa5d..8013641 100755 --- a/tests/04_deploy_with_storage.py +++ b/tests/04_deploy_with_storage.py @@ -14,7 +14,7 @@ seconds = 1800 # amount of time to wait before testing for replicaset # status -wait_for_replicaset = 30 +wait_for_replicaset = 60*5 # amount of time to wait for the data relation wait_for_relation = 60*2 @@ -57,12 +57,17 @@ def validate_status(): ############################################################# def validate_replicaset_setup(): + print("sleeping ot wait for replicatset") time.sleep(wait_for_replicaset) + print("waking") unit_status = [] for service in sentry_dict: - client = MongoClient(sentry_dict[service].info['public-address']) + addy = sentry_dict[service].info['public-address'] + if ":" in addy: + addy = "[{}]".format(addy) + client = MongoClient(addy) r = client.admin.command('replSetGetStatus') unit_status.append(r['myState']) client.close() |
