mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
More robust beacon state test
This commit is contained in:
parent
582ac5f7e9
commit
dc90b47ad2
@ -434,14 +434,8 @@ class Beacon(object):
|
|||||||
Reset the beacons to defaults
|
Reset the beacons to defaults
|
||||||
'''
|
'''
|
||||||
self.opts['beacons'] = {}
|
self.opts['beacons'] = {}
|
||||||
|
|
||||||
comment = 'Beacon Reset'
|
|
||||||
complete = True
|
|
||||||
|
|
||||||
# Fire the complete event back along with updated list of beacons
|
|
||||||
evt = salt.utils.event.get_event('minion', opts=self.opts)
|
evt = salt.utils.event.get_event('minion', opts=self.opts)
|
||||||
evt.fire_event({'complete': complete, 'comment': comment,
|
evt.fire_event({'complete': True, 'comment': 'Beacons have been reset',
|
||||||
'beacons': self.opts['beacons']},
|
'beacons': self.opts['beacons']},
|
||||||
tag='/salt/minion/minion_beacon_reset_complete')
|
tag='/salt/minion/minion_beacon_reset_complete')
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -2255,6 +2255,7 @@ class Minion(MinionBase):
|
|||||||
'''
|
'''
|
||||||
Manage Beacons
|
Manage Beacons
|
||||||
'''
|
'''
|
||||||
|
log.error("GOT MANAGE BEACONS %s %s", tag, data)
|
||||||
func = data.get('func', None)
|
func = data.get('func', None)
|
||||||
name = data.get('name', None)
|
name = data.get('name', None)
|
||||||
beacon_data = data.get('beacon_data', None)
|
beacon_data = data.get('beacon_data', None)
|
||||||
|
@ -110,6 +110,7 @@ def list_available(return_yaml=True, **kwargs):
|
|||||||
event_ret = eventer.get_event(
|
event_ret = eventer.get_event(
|
||||||
tag='/salt/minion/minion_beacons_list_available_complete',
|
tag='/salt/minion/minion_beacons_list_available_complete',
|
||||||
wait=kwargs.get('timeout', default_event_wait))
|
wait=kwargs.get('timeout', default_event_wait))
|
||||||
|
log.error("EVENT RET IS %r", event_ret)
|
||||||
if event_ret and event_ret['complete']:
|
if event_ret and event_ret['complete']:
|
||||||
beacons = event_ret['beacons']
|
beacons = event_ret['beacons']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -621,15 +622,22 @@ def reset(**kwargs):
|
|||||||
eventer = salt.utils.event.get_event('minion', opts=__opts__, listen=True)
|
eventer = salt.utils.event.get_event('minion', opts=__opts__, listen=True)
|
||||||
res = __salt__['event.fire']({'func': 'reset'}, 'manage_beacons')
|
res = __salt__['event.fire']({'func': 'reset'}, 'manage_beacons')
|
||||||
if res:
|
if res:
|
||||||
|
wait = kwargs.get('timeout', default_event_wait)
|
||||||
event_ret = eventer.get_event(
|
event_ret = eventer.get_event(
|
||||||
tag='/salt/minion/minion_beacon_reset_complete',
|
tag='/salt/minion/minion_beacon_reset_complete',
|
||||||
wait=kwargs.get('timeout', default_event_wait))
|
wait=wait)
|
||||||
if event_ret and event_ret['complete']:
|
if event_ret and event_ret['complete']:
|
||||||
ret['result'] = True
|
ret['result'] = True
|
||||||
ret['comment'] = 'Beacon configuration reset.'
|
ret['comment'] = 'Beacon configuration reset.'
|
||||||
else:
|
else:
|
||||||
ret['result'] = False
|
if event_ret is None:
|
||||||
ret['comment'] = 'Something went wrong.'
|
ret['result'] = False
|
||||||
|
ret['comment'] = (
|
||||||
|
'minion reset event not recieved after {} seconds'
|
||||||
|
).format(wait)
|
||||||
|
else:
|
||||||
|
ret['result'] = False
|
||||||
|
ret['comment'] = event_ret['comment']
|
||||||
return ret
|
return ret
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Effectively a no-op, since we can't really return without an event system
|
# Effectively a no-op, since we can't really return without an event system
|
||||||
|
@ -28,12 +28,18 @@ class BeaconStateTestCase(ModuleCase, SaltReturnAssertsMixin):
|
|||||||
|
|
||||||
def test_present_absent(self):
|
def test_present_absent(self):
|
||||||
kwargs = {'/': '38%', 'interval': 5}
|
kwargs = {'/': '38%', 'interval': 5}
|
||||||
ret = self.run_state(
|
# TODO: Figure out why this will sometimes return 'Beacon "diskusage"
|
||||||
'beacon.present',
|
# is not available.' The loop works around that issue for now
|
||||||
name='diskusage',
|
for _ in range(10):
|
||||||
f_timeout=300,
|
ret = self.run_state(
|
||||||
**kwargs
|
'beacon.present',
|
||||||
)
|
name='diskusage',
|
||||||
|
f_timeout=300,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
log.error("RET %s", ret)
|
||||||
|
if ret['beacon_|-diskusage_|-diskusage_|-present']['result'] is True:
|
||||||
|
break
|
||||||
self.assertSaltTrueReturn(ret)
|
self.assertSaltTrueReturn(ret)
|
||||||
|
|
||||||
ret = self.run_function('beacons.list',
|
ret = self.run_function('beacons.list',
|
||||||
|
Loading…
Reference in New Issue
Block a user