def test_event_subscription(self): '''Test a single event is received''' me = event.MinionEvent(self.opts, listen=True) me.fire_event({'data': 'foo1'}, 'evt1') self.wait() evt1 = me.get_event(tag='evt1') self.assertEqual(self.tag, 'evt1') self.data.pop('_stamp') # drop the stamp self.assertEqual(self.data, {'data': 'foo1'})
def test_minion_event(self): opts = dict(id='foo', sock_dir=SOCK_DIR) me = event.MinionEvent(**opts) self.assertEqual( me.puburi, 'ipc://{0}'.format( os.path.join(SOCK_DIR, 'minion_event_foo_pub.ipc'))) self.assertEqual( me.pulluri, 'ipc://{0}'.format( os.path.join(SOCK_DIR, 'minion_event_foo_pull.ipc')))
def test_minion_event_no_id(self): me = event.MinionEvent(sock_dir=SOCK_DIR) self.assertEqual( me.puburi, 'ipc://{0}'.format(os.path.join(SOCK_DIR, 'minion_event__pub.ipc'))) self.assertEqual( me.pulluri, 'ipc://{0}'.format(os.path.join(SOCK_DIR, 'minion_event__pull.ipc')))
def test_minion_event_no_id(self): me = event.MinionEvent(dict(sock_dir=SOCK_DIR)) id_hash = hashlib.md5('').hexdigest()[:10] self.assertEqual( me.puburi, 'ipc://{0}'.format( os.path.join(SOCK_DIR, 'minion_event_{0}_pub.ipc'.format(id_hash)))) self.assertEqual( me.pulluri, 'ipc://{0}'.format( os.path.join(SOCK_DIR, 'minion_event_{0}_pull.ipc'.format(id_hash))))
def test_minion_event_no_id(self): me = event.MinionEvent(dict(sock_dir=SOCK_DIR), listen=False) id_hash = hashlib.sha256(to_bytes('')).hexdigest()[:10] self.assertEqual( me.puburi, '{0}'.format( os.path.join(SOCK_DIR, 'minion_event_{0}_pub.ipc'.format(id_hash)))) self.assertEqual( me.pulluri, '{0}'.format( os.path.join(SOCK_DIR, 'minion_event_{0}_pull.ipc'.format(id_hash))))
def test_minion_event(self): opts = dict(id='foo', sock_dir=SOCK_DIR) id_hash = hashlib.sha256(to_bytes(opts['id'])).hexdigest()[:10] me = event.MinionEvent(opts, listen=False) self.assertEqual( me.puburi, '{0}'.format( os.path.join(SOCK_DIR, 'minion_event_{0}_pub.ipc'.format(id_hash)))) self.assertEqual( me.pulluri, '{0}'.format( os.path.join(SOCK_DIR, 'minion_event_{0}_pull.ipc'.format(id_hash))))
def test_minion_event(self): opts = dict(id='foo', sock_dir=SOCK_DIR) id_hash = hashlib.md5(opts['id']).hexdigest()[:10] me = event.MinionEvent(opts) self.assertEqual( me.puburi, 'ipc://{0}'.format( os.path.join(SOCK_DIR, 'minion_event_{0}_pub.ipc'.format(id_hash)))) self.assertEqual( me.pulluri, 'ipc://{0}'.format( os.path.join(SOCK_DIR, 'minion_event_{0}_pull.ipc'.format(id_hash))))
def get_event(events): me = event.MinionEvent(**self.sub_minion_opts) events.put_nowait( me.get_event(wait=10, tag='salttest', full=False) )
def test_minion_event_tcp_ipc_mode(self): opts = dict(id='foo', ipc_mode='tcp') me = event.MinionEvent(**opts) self.assertEqual(me.puburi, 'tcp://127.0.0.1:4510') self.assertEqual(me.pulluri, 'tcp://127.0.0.1:4511')
def test_minion_event_tcp_ipc_mode(self): opts = dict(id='foo', ipc_mode='tcp') me = event.MinionEvent(opts, listen=False) self.assertEqual(me.puburi, 4510) self.assertEqual(me.pulluri, 4511)
def get_event(events): me = event.MinionEvent(self.sub_minion_opts, listen=True) events.put_nowait(me.get_event(wait=10, tag="salttest", full=False))
def get_event(events): with event.MinionEvent(self.minion_opts, listen=True) as me: events.put_nowait( me.get_event(wait=10, tag="salttest", full=False))