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
|
||||
'''
|
||||
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.fire_event({'complete': complete, 'comment': comment,
|
||||
evt.fire_event({'complete': True, 'comment': 'Beacons have been reset',
|
||||
'beacons': self.opts['beacons']},
|
||||
tag='/salt/minion/minion_beacon_reset_complete')
|
||||
|
||||
return True
|
||||
|
@ -2255,6 +2255,7 @@ class Minion(MinionBase):
|
||||
'''
|
||||
Manage Beacons
|
||||
'''
|
||||
log.error("GOT MANAGE BEACONS %s %s", tag, data)
|
||||
func = data.get('func', None)
|
||||
name = data.get('name', None)
|
||||
beacon_data = data.get('beacon_data', None)
|
||||
|
@ -110,6 +110,7 @@ def list_available(return_yaml=True, **kwargs):
|
||||
event_ret = eventer.get_event(
|
||||
tag='/salt/minion/minion_beacons_list_available_complete',
|
||||
wait=kwargs.get('timeout', default_event_wait))
|
||||
log.error("EVENT RET IS %r", event_ret)
|
||||
if event_ret and event_ret['complete']:
|
||||
beacons = event_ret['beacons']
|
||||
except KeyError:
|
||||
@ -621,15 +622,22 @@ def reset(**kwargs):
|
||||
eventer = salt.utils.event.get_event('minion', opts=__opts__, listen=True)
|
||||
res = __salt__['event.fire']({'func': 'reset'}, 'manage_beacons')
|
||||
if res:
|
||||
wait = kwargs.get('timeout', default_event_wait)
|
||||
event_ret = eventer.get_event(
|
||||
tag='/salt/minion/minion_beacon_reset_complete',
|
||||
wait=kwargs.get('timeout', default_event_wait))
|
||||
wait=wait)
|
||||
if event_ret and event_ret['complete']:
|
||||
ret['result'] = True
|
||||
ret['comment'] = 'Beacon configuration reset.'
|
||||
else:
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Something went wrong.'
|
||||
if event_ret is None:
|
||||
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
|
||||
except KeyError:
|
||||
# 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):
|
||||
kwargs = {'/': '38%', 'interval': 5}
|
||||
ret = self.run_state(
|
||||
'beacon.present',
|
||||
name='diskusage',
|
||||
f_timeout=300,
|
||||
**kwargs
|
||||
)
|
||||
# TODO: Figure out why this will sometimes return 'Beacon "diskusage"
|
||||
# is not available.' The loop works around that issue for now
|
||||
for _ in range(10):
|
||||
ret = self.run_state(
|
||||
'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)
|
||||
|
||||
ret = self.run_function('beacons.list',
|
||||
|
Loading…
Reference in New Issue
Block a user