Skip to content

Commit

Permalink
Fix bug blocking healthcheck test in strict mode (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbdcos authored Feb 15, 2017
1 parent 2612216 commit 96ffe36
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions integration/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import time
import sys
import collections
from functools import wraps

import dcos
Expand Down Expand Up @@ -181,7 +182,10 @@ def spin(fn, success_predicate, *args, **kwargs):

# to be consistent with other upgrade tests i.e. cassandra
def install(additional_options={}, package_version=None, wait=True):
merged_options = _nested_dict_merge(DEFAULT_OPTIONS_DICT, additional_options)
print ('Default_options {} \n'.format(DEFAULT_OPTIONS_DICT))
print ('Additional_options {} \n'.format(additional_options))
merged_options = _merge_dictionary(DEFAULT_OPTIONS_DICT, additional_options)
print ('Merged_options {} \n'.format(merged_options))
print('Installing {} with options: {}, package_version: {}'.format(PACKAGE_NAME, merged_options, package_version))
shakedown.install_package_and_wait(
PACKAGE_NAME,
Expand Down Expand Up @@ -229,18 +233,16 @@ def success_predicate(result):
return spin(fn, success_predicate).json()


def _nested_dict_merge(a, b, path=None):
"ripped from http://stackoverflow.com/questions/7204805/dictionaries-of-dictionaries-merge"
if path is None: path = []
a = a.copy()
for key in b:
if key in a:
if isinstance(a[key], dict) and isinstance(b[key], dict):
_nested_dict_merge(a[key], b[key], path + [str(key)])
elif a[key] == b[key]:
pass # same leaf value
else:
raise Exception('Conflict at %s' % '.'.join(path + [str(key)]))
def _merge_dictionary(dict1, dict2):
if (not isinstance(dict2, dict)):
return dict1
ret = {}
for k, v in dict1.items():
ret[k] = v
for k, v in dict2.items():
if (k in dict1 and isinstance(dict1[k], dict)
and isinstance(dict2[k], collections.Mapping)):
ret[k] = _merge_dictionary(dict1[k], dict2[k])
else:
a[key] = b[key]
return a
ret[k] = dict2[k]
return ret

0 comments on commit 96ffe36

Please sign in to comment.