mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
[PY3] Add unicode_literals to daemons modules
This commit is contained in:
parent
63172299bf
commit
5b91c78cb6
25 changed files with 382 additions and 452 deletions
|
@ -3,7 +3,7 @@
|
|||
The daemons package is used to store implementations of the Salt Master and
|
||||
Minion enabling different transports.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
# Import Python Libs
|
||||
import sys
|
||||
from collections import namedtuple, Iterable, Sequence, Mapping
|
||||
|
|
|
@ -19,7 +19,7 @@ opts['caller_floscript']
|
|||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
|
||||
# Import modules
|
||||
|
|
|
@ -6,7 +6,7 @@ The core behaviors used by minion and master
|
|||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import time
|
||||
import random
|
||||
|
@ -399,7 +399,7 @@ class SaltRaetRoadStackJoiner(ioflo.base.deeding.Deed):
|
|||
ha=mha,
|
||||
kind=kinds.applKinds.master))
|
||||
except gaierror as ex:
|
||||
log.warning("Unable to connect to master {0}: {1}".format(mha, ex))
|
||||
log.warning("Unable to connect to master %s: %s", mha, ex)
|
||||
if self.opts.value.get(u'master_type') not in (u'failover', u'distributed'):
|
||||
raise ex
|
||||
if not stack.remotes:
|
||||
|
@ -664,10 +664,8 @@ class SaltLoadModules(ioflo.base.deeding.Deed):
|
|||
# this feature ONLY works on *nix like OSs (resource module doesn't work on windows)
|
||||
modules_max_memory = False
|
||||
if self.opts.value.get('modules_max_memory', -1) > 0 and HAS_PSUTIL and HAS_RESOURCE:
|
||||
log.debug(
|
||||
'modules_max_memory set, enforcing a maximum of {0}'.format(
|
||||
self.opts.value['modules_max_memory'])
|
||||
)
|
||||
log.debug('modules_max_memory set, enforcing a maximum of %s',
|
||||
self.opts.value['modules_max_memory'])
|
||||
modules_max_memory = True
|
||||
old_mem_limit = resource.getrlimit(resource.RLIMIT_AS)
|
||||
rss, vms = psutil.Process(os.getpid()).memory_info()[:2]
|
||||
|
@ -1106,22 +1104,22 @@ class SaltRaetRouterMaster(SaltRaetRouter):
|
|||
s_estate, s_yard, s_share = msg['route']['src']
|
||||
d_estate, d_yard, d_share = msg['route']['dst']
|
||||
except (ValueError, IndexError):
|
||||
log.error('Received invalid message: {0}'.format(msg))
|
||||
log.error('Received invalid message: %s', msg)
|
||||
return
|
||||
|
||||
if s_estate is None: # drop
|
||||
return
|
||||
|
||||
log.debug("**** Road Router rxMsg **** id={0} estate={1} yard={2}\n"
|
||||
" msg= {3}\n".format(
|
||||
self.opts.value['id'],
|
||||
self.road_stack.value.local.name,
|
||||
self.lane_stack.value.local.name,
|
||||
msg))
|
||||
log.debug(
|
||||
'**** Road Router rxMsg **** id=%s estate=%s yard=%s\nmsg=%s',
|
||||
self.opts.value['id'],
|
||||
self.road_stack.value.local.name,
|
||||
self.lane_stack.value.local.name,
|
||||
msg
|
||||
)
|
||||
|
||||
if d_estate is not None and d_estate != self.road_stack.value.local.name:
|
||||
log.error(
|
||||
'Road Router Received message for wrong estate: {0}'.format(d_estate))
|
||||
log.error('Road Router Received message for wrong estate: %s', d_estate)
|
||||
return
|
||||
|
||||
if d_yard is not None:
|
||||
|
@ -1132,15 +1130,15 @@ class SaltRaetRouterMaster(SaltRaetRouter):
|
|||
return
|
||||
if d_share is None:
|
||||
# No queue destination!
|
||||
log.error('Received message without share: {0}'.format(msg))
|
||||
log.error('Received message without share: %s', msg)
|
||||
return
|
||||
elif d_share == 'event_fire': # rebroadcast events from other masters
|
||||
self.event.value.append(msg)
|
||||
#log.debug("\n**** Event Fire \n {0}\n".format(msg))
|
||||
#log.debug("\n**** Event Fire \n %s\n", msg)
|
||||
return
|
||||
elif d_share == 'local_cmd':
|
||||
# Refuse local commands over the wire
|
||||
log.error('Received local command remotely! Ignoring: {0}'.format(msg))
|
||||
log.error('Received local command remotely! Ignoring: %s', msg)
|
||||
return
|
||||
elif d_share == 'remote_cmd':
|
||||
# Send it to a remote worker
|
||||
|
@ -1162,7 +1160,7 @@ class SaltRaetRouterMaster(SaltRaetRouter):
|
|||
s_estate, s_yard, s_share = msg['route']['src']
|
||||
d_estate, d_yard, d_share = msg['route']['dst']
|
||||
except (ValueError, IndexError):
|
||||
log.error('Lane Router Received invalid message: {0}'.format(msg))
|
||||
log.error('Lane Router Received invalid message: %s', msg)
|
||||
return
|
||||
|
||||
if s_yard is None:
|
||||
|
@ -1172,12 +1170,13 @@ class SaltRaetRouterMaster(SaltRaetRouter):
|
|||
s_estate = self.road_stack.value.local.name
|
||||
msg['route']['src'] = (s_estate, s_yard, s_share)
|
||||
|
||||
log.debug("**** Lane Router rxMsg **** id={0} estate={1} yard={2}\n"
|
||||
" msg={3}\n".format(
|
||||
self.opts.value['id'],
|
||||
self.road_stack.value.local.name,
|
||||
self.lane_stack.value.local.name,
|
||||
msg))
|
||||
log.debug(
|
||||
'**** Lane Router rxMsg **** id=%s estate=%s yard=%s\nmsg=%s',
|
||||
self.opts.value['id'],
|
||||
self.road_stack.value.local.name,
|
||||
self.lane_stack.value.local.name,
|
||||
msg
|
||||
)
|
||||
|
||||
if d_estate is None:
|
||||
pass
|
||||
|
@ -1204,23 +1203,23 @@ class SaltRaetRouterMaster(SaltRaetRouter):
|
|||
return
|
||||
if d_share is None:
|
||||
# No queue destination!
|
||||
log.error('Lane Router Received message without share: {0}'.format(msg))
|
||||
log.error('Lane Router Received message without share: %s', msg)
|
||||
return
|
||||
elif d_share == 'local_cmd':
|
||||
self.lane_stack.value.transmit(msg,
|
||||
self.lane_stack.value.fetchUidByName(next(self.workers.value)))
|
||||
elif d_share == 'event_req':
|
||||
self.event_req.value.append(msg)
|
||||
#log.debug("\n**** Event Subscribe \n {0}\n".format(msg))
|
||||
#log.debug("\n**** Event Subscribe \n %s\n", msg)
|
||||
elif d_share == 'event_fire':
|
||||
self.event.value.append(msg)
|
||||
#log.debug("\n**** Event Fire \n {0}\n".format(msg))
|
||||
#log.debug("\n**** Event Fire \n %s\n", msg)
|
||||
elif d_share == 'presence_req':
|
||||
self.presence_req.value.append(msg)
|
||||
#log.debug("\n**** Presence Request \n {0}\n".format(msg))
|
||||
#log.debug("\n**** Presence Request \n %s\n", msg)
|
||||
elif d_share == 'stats_req':
|
||||
self.stats_req.value.append(msg)
|
||||
#log.debug("\n**** Stats Request \n {0}\n".format(msg))
|
||||
#log.debug("\n**** Stats Request \n %s\n", msg)
|
||||
|
||||
|
||||
class SaltRaetRouterMinion(SaltRaetRouter):
|
||||
|
@ -1241,22 +1240,22 @@ class SaltRaetRouterMinion(SaltRaetRouter):
|
|||
s_estate, s_yard, s_share = msg['route']['src']
|
||||
d_estate, d_yard, d_share = msg['route']['dst']
|
||||
except (ValueError, IndexError):
|
||||
log.error('Received invalid message: {0}'.format(msg))
|
||||
log.error('Received invalid message: %s', msg)
|
||||
return
|
||||
|
||||
if s_estate is None: # drop
|
||||
return
|
||||
|
||||
log.debug("**** Road Router rxMsg **** id={0} estate={1} yard={2}\n"
|
||||
" msg= {3}\n".format(
|
||||
self.opts.value['id'],
|
||||
self.road_stack.value.local.name,
|
||||
self.lane_stack.value.local.name,
|
||||
msg))
|
||||
log.debug(
|
||||
'**** Road Router rxMsg **** id=%s estate=%s yard=%s\nmsg=%s',
|
||||
self.opts.value['id'],
|
||||
self.road_stack.value.local.name,
|
||||
self.lane_stack.value.local.name,
|
||||
msg
|
||||
)
|
||||
|
||||
if d_estate is not None and d_estate != self.road_stack.value.local.name:
|
||||
log.error(
|
||||
'Road Router Received message for wrong estate: {0}'.format(d_estate))
|
||||
log.error('Road Router Received message for wrong estate: %s', d_estate)
|
||||
return
|
||||
|
||||
if d_yard is not None:
|
||||
|
@ -1268,7 +1267,7 @@ class SaltRaetRouterMinion(SaltRaetRouter):
|
|||
return
|
||||
if d_share is None:
|
||||
# No queue destination!
|
||||
log.error('Received message without share: {0}'.format(msg))
|
||||
log.error('Received message without share: %s', msg)
|
||||
return
|
||||
|
||||
elif d_share == 'fun':
|
||||
|
@ -1276,7 +1275,7 @@ class SaltRaetRouterMinion(SaltRaetRouter):
|
|||
self.fun.value.append(msg)
|
||||
elif d_share == 'stats_req':
|
||||
self.stats_req.value.append(msg)
|
||||
#log.debug("\n**** Stats Request \n {0}\n".format(msg))
|
||||
#log.debug("\n**** Stats Request \n %s\n", msg)
|
||||
|
||||
def _process_lane_rxmsg(self, msg, sender):
|
||||
'''
|
||||
|
@ -1290,7 +1289,7 @@ class SaltRaetRouterMinion(SaltRaetRouter):
|
|||
s_estate, s_yard, s_share = msg['route']['src']
|
||||
d_estate, d_yard, d_share = msg['route']['dst']
|
||||
except (ValueError, IndexError):
|
||||
log.error('Lane Router Received invalid message: {0}'.format(msg))
|
||||
log.error('Lane Router Received invalid message: %s', msg)
|
||||
return
|
||||
|
||||
if s_yard is None:
|
||||
|
@ -1300,12 +1299,13 @@ class SaltRaetRouterMinion(SaltRaetRouter):
|
|||
s_estate = self.road_stack.value.local.name
|
||||
msg['route']['src'] = (s_estate, s_yard, s_share)
|
||||
|
||||
log.debug("**** Lane Router rxMsg **** id={0} estate={1} yard={2}\n"
|
||||
" msg={3}\n".format(
|
||||
self.opts.value['id'],
|
||||
self.road_stack.value.local.name,
|
||||
self.lane_stack.value.local.name,
|
||||
msg))
|
||||
log.debug(
|
||||
'**** Lane Router rxMsg **** id=%s estate=%s yard=%s\nmsg=%s',
|
||||
self.opts.value['id'],
|
||||
self.road_stack.value.local.name,
|
||||
self.lane_stack.value.local.name,
|
||||
msg
|
||||
)
|
||||
|
||||
if d_estate is None:
|
||||
pass
|
||||
|
@ -1327,31 +1327,31 @@ class SaltRaetRouterMinion(SaltRaetRouter):
|
|||
return
|
||||
if d_share is None:
|
||||
# No queue destination!
|
||||
log.error('Lane Router Received message without share: {0}'.format(msg))
|
||||
log.error('Lane Router Received message without share: %s', msg)
|
||||
return
|
||||
|
||||
elif d_share == 'event_req':
|
||||
self.event_req.value.append(msg)
|
||||
#log.debug("\n**** Event Subscribe \n {0}\n".format(msg))
|
||||
#log.debug("\n**** Event Subscribe \n %s\n", msg)
|
||||
elif d_share == 'event_fire':
|
||||
self.event.value.append(msg)
|
||||
#log.debug("\n**** Event Fire \n {0}\n".format(msg))
|
||||
#log.debug("\n**** Event Fire \n %s\n", msg)
|
||||
|
||||
elif d_share == 'remote_cmd': # assume minion to master or salt-call
|
||||
if not self.road_stack.value.remotes:
|
||||
log.error("**** Lane Router: Missing joined master. Unable to route "
|
||||
"remote_cmd. Requeuing".format())
|
||||
"remote_cmd. Requeuing")
|
||||
self.laters.value.append((msg, sender))
|
||||
return
|
||||
d_estate = self._get_master_estate_name(clustered=self.opts.get('cluster_mode', False))
|
||||
if not d_estate:
|
||||
log.error("**** Lane Router: No available destination estate for 'remote_cmd'."
|
||||
"Unable to route. Requeuing".format())
|
||||
"Unable to route. Requeuing")
|
||||
self.laters.value.append((msg, sender))
|
||||
return
|
||||
msg['route']['dst'] = (d_estate, d_yard, d_share)
|
||||
log.debug("**** Lane Router: Missing destination estate for 'remote_cmd'. "
|
||||
"Using default route={0}.".format(msg['route']['dst']))
|
||||
"Using default route=%s.", msg['route']['dst'])
|
||||
self.road_stack.value.message(msg,
|
||||
self.road_stack.value.nameRemotes[d_estate].uid)
|
||||
|
||||
|
@ -1527,7 +1527,7 @@ class SaltRaetPresenter(ioflo.base.deeding.Deed):
|
|||
minions = states[state].value
|
||||
except KeyError:
|
||||
# error: wrong/unknown state requested
|
||||
log.error('Lane Router Received invalid message: {0}'.format(msg))
|
||||
log.error('Lane Router Received invalid message: %s', msg)
|
||||
return
|
||||
|
||||
result = odict()
|
||||
|
@ -1581,7 +1581,7 @@ class SaltRaetStatsEventer(ioflo.base.deeding.Deed):
|
|||
elif tag == tagify('lane', 'stats'):
|
||||
return self.lane_stack.value.stats
|
||||
else:
|
||||
log.error('Missing or invalid tag: {0}'.format(tag))
|
||||
log.error('Missing or invalid tag: %s', tag)
|
||||
return None
|
||||
|
||||
def action(self):
|
||||
|
|
|
@ -15,7 +15,7 @@ without the need for a swarm of real minions.
|
|||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
# Import salt libs
|
||||
|
@ -39,7 +39,7 @@ class SaltDummyPublisher(ioflo.base.deeding.Deed):
|
|||
def action(self):
|
||||
while self.publish.value:
|
||||
pub = self.publish.value.popleft()
|
||||
log.debug('Dummy publisher publishing: {0}'.format(pub))
|
||||
log.debug('Dummy publisher publishing: %s', pub)
|
||||
msg = self._fill_tmpl(pub)
|
||||
self.lane_stack.value.transmit(msg, self.lane_stack.value.fetchUidByName(next(self.workers.value)))
|
||||
|
||||
|
@ -64,5 +64,5 @@ class SaltDummyPublisher(ioflo.base.deeding.Deed):
|
|||
}
|
||||
}
|
||||
|
||||
log.debug('Dummy publisher faking return with: {0}'.format(msg))
|
||||
log.debug('Dummy publisher faking return with: %s', msg)
|
||||
return msg
|
||||
|
|
|
@ -6,7 +6,7 @@ Jobber Behaviors
|
|||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import sys
|
||||
import types
|
||||
|
@ -238,13 +238,15 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
|
|||
continue
|
||||
if 'user' in data:
|
||||
log.info(
|
||||
'User {0[user]} Executing command {0[fun]} with jid '
|
||||
'{0[jid]}'.format(data))
|
||||
'User %s Executing command %s with jid %s',
|
||||
data['user'], data['fun'], data['jid']
|
||||
)
|
||||
else:
|
||||
log.info(
|
||||
'Executing command {0[fun]} with jid {0[jid]}'.format(data)
|
||||
)
|
||||
log.debug('Command details {0}'.format(data))
|
||||
'Executing command %s with jid %s',
|
||||
data['fun'], data['jid']
|
||||
)
|
||||
log.debug('Command details %s', data)
|
||||
|
||||
if is_windows():
|
||||
# SaltRaetNixJobber is not picklable. Pickling is necessary
|
||||
|
@ -255,9 +257,7 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
|
|||
try:
|
||||
self.proc_run(msg)
|
||||
except Exception as exc:
|
||||
log.error(
|
||||
'Exception caught by jobber: {0}'.format(exc),
|
||||
exc_info=True)
|
||||
log.error('Exception caught by jobber: %s', exc, exc_info=True)
|
||||
else:
|
||||
process = multiprocessing.Process(
|
||||
target=self.proc_run,
|
||||
|
@ -302,11 +302,13 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
|
|||
if isinstance(executors, six.string_types):
|
||||
executors = [executors]
|
||||
elif not isinstance(executors, list) or not executors:
|
||||
raise SaltInvocationError("Wrong executors specification: {0}. String or non-empty list expected".
|
||||
format(executors))
|
||||
raise SaltInvocationError(
|
||||
'Wrong executors specification: {0}. String or '
|
||||
'non-empty list expected'.format(executors)
|
||||
)
|
||||
if self.opts.get('sudo_user', '') and executors[-1] != 'sudo':
|
||||
executors[-1] = 'sudo.get' # replace
|
||||
log.trace("Executors list {0}".format(executors))
|
||||
log.trace("Executors list %s", executors)
|
||||
|
||||
for name in executors:
|
||||
if name not in self.module_executors.value:
|
||||
|
@ -326,7 +328,7 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
|
|||
iret = []
|
||||
iret.append(single)
|
||||
tag = tagify(
|
||||
[data['jid'], 'prog', self.opts['id'], str(ind)],
|
||||
[data['jid'], 'prog', self.opts['id'], six.text_type(ind)],
|
||||
'job')
|
||||
event_data = {'return': single}
|
||||
self._fire_master(event_data, tag) # Need to look into this
|
||||
|
@ -347,19 +349,15 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
|
|||
ret['return'] = '{0}: {1}'.format(msg, exc)
|
||||
except CommandExecutionError as exc:
|
||||
log.error(
|
||||
'A command in \'{0}\' had a problem: {1}'.format(
|
||||
function_name,
|
||||
exc
|
||||
),
|
||||
'A command in \'%s\' had a problem: %s',
|
||||
function_name, exc,
|
||||
exc_info_on_loglevel=logging.DEBUG
|
||||
)
|
||||
ret['return'] = 'ERROR: {0}'.format(exc)
|
||||
except SaltInvocationError as exc:
|
||||
log.error(
|
||||
'Problem executing \'{0}\': {1}'.format(
|
||||
function_name,
|
||||
exc
|
||||
),
|
||||
'Problem executing \'%s\': %s',
|
||||
function_name, exc,
|
||||
exc_info_on_loglevel=logging.DEBUG
|
||||
)
|
||||
ret['return'] = 'ERROR executing \'{0}\': {1}'.format(
|
||||
|
@ -389,12 +387,7 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
|
|||
returner
|
||||
)](ret)
|
||||
except Exception as exc:
|
||||
log.error(
|
||||
'The return failed for job {0} {1}'.format(
|
||||
data['jid'],
|
||||
exc
|
||||
)
|
||||
)
|
||||
log.error('The return failed for job %s %s', data['jid'], exc)
|
||||
console.concise("Closing Jobber Stack {0}\n".format(stack.name))
|
||||
stack.server.close()
|
||||
salt.transport.jobber_stack = None
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Define the behaviors used in the maintenance process
|
||||
'''
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
# Import python libs
|
||||
import multiprocessing
|
||||
import os
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Start the reactor!
|
||||
'''
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
# Import salt libs
|
||||
import salt.utils.reactor
|
||||
import salt.utils.event
|
||||
|
|
|
@ -5,7 +5,7 @@ The core behaviors used by minion and master
|
|||
# pylint: disable=W0232
|
||||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import time
|
||||
|
@ -210,10 +210,10 @@ class SaltRaetWorkerRouter(ioflo.base.deeding.Deed):
|
|||
s_estate, s_yard, s_share = msg['route']['src']
|
||||
d_estate, d_yard, d_share = msg['route']['dst']
|
||||
except (ValueError, IndexError):
|
||||
log.error('Received invalid message: {0}'.format(msg))
|
||||
log.error('Received invalid message: %s', msg)
|
||||
return
|
||||
|
||||
log.debug("**** Worker Router rxMsg\n msg= {0}\n".format(msg))
|
||||
log.debug("**** Worker Router rxMsg\nmsg=%s", msg)
|
||||
|
||||
if 'load' in msg:
|
||||
cmd = msg['load'].get('cmd')
|
||||
|
|
|
@ -6,7 +6,7 @@ IoFlo behaviors for running a ZeroMQ based master
|
|||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import logging
|
||||
import hashlib
|
||||
|
@ -86,7 +86,7 @@ class ZmqRet(multiprocessing.Process):
|
|||
'''
|
||||
self.context = zmq.Context(self.opts['worker_threads'])
|
||||
self.uri = 'tcp://{interface}:{ret_port}'.format(**self.opts)
|
||||
log.info('ZMQ Ret port binding to {0}'.format(self.uri))
|
||||
log.info('ZMQ Ret port binding to %s', self.uri)
|
||||
self.clients = self.context.socket(zmq.ROUTER)
|
||||
if self.opts['ipv6'] is True and hasattr(zmq, 'IPV4ONLY'):
|
||||
# IPv6 sockets work for both IPv6 and IPv4 addresses
|
||||
|
@ -186,7 +186,7 @@ class SaltZmqPublisher(ioflo.base.deeding.Deed):
|
|||
self.pub_sock.setsockopt(zmq.IPV4ONLY, 0)
|
||||
self.pub_sock.setsockopt(zmq.BACKLOG, self.opts.get('zmq_backlog', 1000))
|
||||
self.pub_uri = 'tcp://{interface}:{publish_port}'.format(**self.opts.value)
|
||||
log.info('Starting the Salt ZeroMQ Publisher on {0}'.format(self.pub_uri))
|
||||
log.info('Starting the Salt ZeroMQ Publisher on %s', self.pub_uri)
|
||||
self.pub_sock.bind(self.pub_uri)
|
||||
self.created = True
|
||||
# Don't pop the publish messages! The raet behavior still needs them
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
This module contains all of the routines needed to set up a master server, this
|
||||
involves preparing the three listeners and the workers needed by the master.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import fnmatch
|
||||
|
@ -99,13 +99,13 @@ def clean_fsbackend(opts):
|
|||
'envs.p'
|
||||
)
|
||||
if os.path.isfile(env_cache):
|
||||
log.debug('Clearing {0}fs env cache'.format(backend))
|
||||
log.debug('Clearing %sfs env cache', backend)
|
||||
try:
|
||||
os.remove(env_cache)
|
||||
except OSError as exc:
|
||||
log.critical(
|
||||
'Unable to clear env cache file {0}: {1}'
|
||||
.format(env_cache, exc)
|
||||
'Unable to clear env cache file %s: %s',
|
||||
env_cache, exc
|
||||
)
|
||||
|
||||
file_lists_dir = os.path.join(
|
||||
|
@ -123,8 +123,8 @@ def clean_fsbackend(opts):
|
|||
os.remove(cache_file)
|
||||
except OSError as exc:
|
||||
log.critical(
|
||||
'Unable to file_lists cache file {0}: {1}'
|
||||
.format(cache_file, exc)
|
||||
'Unable to file_lists cache file %s: %s',
|
||||
cache_file, exc
|
||||
)
|
||||
|
||||
|
||||
|
@ -194,7 +194,7 @@ def mk_key(opts, user):
|
|||
)
|
||||
|
||||
if os.path.exists(keyfile):
|
||||
log.debug('Removing stale keyfile: {0}'.format(keyfile))
|
||||
log.debug('Removing stale keyfile: %s', keyfile)
|
||||
if salt.utils.platform.is_windows() and not os.access(keyfile, os.W_OK):
|
||||
# Cannot delete read-only files on Windows.
|
||||
os.chmod(keyfile, stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
@ -203,7 +203,7 @@ def mk_key(opts, user):
|
|||
key = salt.crypt.Crypticle.generate_key_string()
|
||||
cumask = os.umask(191)
|
||||
with salt.utils.files.fopen(keyfile, 'w+') as fp_:
|
||||
fp_.write(key)
|
||||
fp_.write(salt.utils.stringutils.to_str(key))
|
||||
os.umask(cumask)
|
||||
# 600 octal: Read and write access to the owner only.
|
||||
# Write access is necessary since on subsequent runs, if the file
|
||||
|
@ -265,7 +265,7 @@ def fileserver_update(fileserver):
|
|||
fileserver.update()
|
||||
except Exception as exc:
|
||||
log.error(
|
||||
'Exception {0} occurred in file server update'.format(exc),
|
||||
'Exception %s occurred in file server update', exc,
|
||||
exc_info_on_loglevel=logging.DEBUG
|
||||
)
|
||||
|
||||
|
@ -311,8 +311,7 @@ class AutoKey(object):
|
|||
return False
|
||||
|
||||
if not self.check_permissions(signing_file):
|
||||
message = 'Wrong permissions for {0}, ignoring content'
|
||||
log.warning(message.format(signing_file))
|
||||
log.warning('Wrong permissions for %s, ignoring content', signing_file)
|
||||
return False
|
||||
|
||||
with salt.utils.files.fopen(signing_file, 'r') as fp_:
|
||||
|
@ -340,7 +339,7 @@ class AutoKey(object):
|
|||
stub_file = os.path.join(autosign_dir, f)
|
||||
mtime = os.path.getmtime(stub_file)
|
||||
if mtime < min_time:
|
||||
log.warning('Autosign keyid expired {0}'.format(stub_file))
|
||||
log.warning('Autosign keyid expired %s', stub_file)
|
||||
os.remove(stub_file)
|
||||
|
||||
stub_file = os.path.join(autosign_dir, keyid)
|
||||
|
@ -353,24 +352,26 @@ class AutoKey(object):
|
|||
'''
|
||||
Check for matching grains in the autosign_grains_dir.
|
||||
'''
|
||||
if not autosign_grains or u'autosign_grains_dir' not in self.opts:
|
||||
if not autosign_grains or 'autosign_grains_dir' not in self.opts:
|
||||
return False
|
||||
|
||||
autosign_grains_dir = self.opts[u'autosign_grains_dir']
|
||||
autosign_grains_dir = self.opts['autosign_grains_dir']
|
||||
for root, dirs, filenames in os.walk(autosign_grains_dir):
|
||||
for grain in filenames:
|
||||
if grain in autosign_grains:
|
||||
grain_file = os.path.join(autosign_grains_dir, grain)
|
||||
|
||||
if not self.check_permissions(grain_file):
|
||||
message = 'Wrong permissions for {0}, ignoring content'
|
||||
log.warning(message.format(grain_file))
|
||||
log.warning(
|
||||
'Wrong permissions for %s, ignoring content',
|
||||
grain_file
|
||||
)
|
||||
continue
|
||||
|
||||
with salt.utils.files.fopen(grain_file, u'r') as f:
|
||||
with salt.utils.files.fopen(grain_file, 'r') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line.startswith(u'#'):
|
||||
if line.startswith('#'):
|
||||
continue
|
||||
if autosign_grains[grain] == line:
|
||||
return True
|
||||
|
@ -535,10 +536,8 @@ class RemoteFuncs(object):
|
|||
except Exception as exc:
|
||||
# If anything happens in the top generation, log it and move on
|
||||
log.error(
|
||||
'Top function {0} failed with error {1} for minion '
|
||||
'{2}'.format(
|
||||
fun, exc, load['id']
|
||||
)
|
||||
'Top function %s failed with error %s for minion %s',
|
||||
fun, exc, load['id']
|
||||
)
|
||||
return ret
|
||||
|
||||
|
@ -566,11 +565,11 @@ class RemoteFuncs(object):
|
|||
expr_form = load.get('expr_form')
|
||||
if expr_form is not None and 'tgt_type' not in load:
|
||||
salt.utils.versions.warn_until(
|
||||
u'Neon',
|
||||
u'_mine_get: minion {0} uses pre-Nitrogen API key '
|
||||
u'"expr_form". Accepting for backwards compatibility '
|
||||
u'but this is not guaranteed '
|
||||
u'after the Neon release'.format(load['id'])
|
||||
'Neon',
|
||||
'_mine_get: minion {0} uses pre-Nitrogen API key '
|
||||
'"expr_form". Accepting for backwards compatibility '
|
||||
'but this is not guaranteed '
|
||||
'after the Neon release'.format(load['id'])
|
||||
)
|
||||
match_type = expr_form
|
||||
else:
|
||||
|
@ -664,9 +663,8 @@ class RemoteFuncs(object):
|
|||
|
||||
if len(load['data']) + load.get('loc', 0) > file_recv_max_size:
|
||||
log.error(
|
||||
'Exceeding file_recv_max_size limit: {0}'.format(
|
||||
file_recv_max_size
|
||||
)
|
||||
'Exceeding file_recv_max_size limit: %s',
|
||||
file_recv_max_size
|
||||
)
|
||||
return False
|
||||
# Normalize Windows paths
|
||||
|
@ -704,7 +702,7 @@ class RemoteFuncs(object):
|
|||
if any(key not in load for key in ('id', 'grains')):
|
||||
return False
|
||||
# pillar = salt.pillar.Pillar(
|
||||
log.debug('Master _pillar using ext: {0}'.format(load.get('ext')))
|
||||
log.debug('Master _pillar using ext: %s', load.get('ext'))
|
||||
pillar = salt.pillar.get_pillar(
|
||||
self.opts,
|
||||
load['grains'],
|
||||
|
@ -762,7 +760,7 @@ class RemoteFuncs(object):
|
|||
# save the load, since we don't have it
|
||||
saveload_fstr = '{0}.save_load'.format(self.opts['master_job_cache'])
|
||||
self.mminion.returners[saveload_fstr](load['jid'], load)
|
||||
log.info('Got return from {id} for job {jid}'.format(**load))
|
||||
log.info('Got return from %s for job %s', load['id'], load['jid'])
|
||||
self.event.fire_event(load, load['jid']) # old dup event
|
||||
self.event.fire_event(load, salt.utils.event.tagify([load['jid'], 'ret', load['id']], 'job'))
|
||||
self.event.fire_ret_load(load)
|
||||
|
@ -822,11 +820,7 @@ class RemoteFuncs(object):
|
|||
if not good:
|
||||
# The minion is not who it says it is!
|
||||
# We don't want to listen to it!
|
||||
log.warning(
|
||||
'Minion id {0} is not who it says it is!'.format(
|
||||
load['id']
|
||||
)
|
||||
)
|
||||
log.warning('Minion id %s is not who it says it is!', load['id'])
|
||||
return {}
|
||||
# Prepare the runner object
|
||||
opts = {}
|
||||
|
@ -912,7 +906,7 @@ class RemoteFuncs(object):
|
|||
'publish_auth')
|
||||
if not os.path.isdir(auth_cache):
|
||||
os.makedirs(auth_cache)
|
||||
jid_fn = os.path.join(auth_cache, str(ret['jid']))
|
||||
jid_fn = os.path.join(auth_cache, six.text_type(ret['jid']))
|
||||
with salt.utils.files.fopen(jid_fn, 'w+') as fp_:
|
||||
fp_.write(load['id'])
|
||||
return ret
|
||||
|
@ -1077,11 +1071,10 @@ class LocalFuncs(object):
|
|||
load.get('kwarg', {}),
|
||||
username)
|
||||
except Exception as exc:
|
||||
log.error('Exception occurred while '
|
||||
'introspecting {0}: {1}'.format(fun, exc))
|
||||
log.exception('Exception occurred while introspecting %s')
|
||||
return {'error': {'name': exc.__class__.__name__,
|
||||
'args': exc.args,
|
||||
'message': str(exc)}}
|
||||
'message': six.text_type(exc)}}
|
||||
|
||||
def wheel(self, load):
|
||||
'''
|
||||
|
@ -1136,8 +1129,7 @@ class LocalFuncs(object):
|
|||
return {'tag': tag,
|
||||
'data': data}
|
||||
except Exception as exc:
|
||||
log.error('Exception occurred while '
|
||||
'introspecting {0}: {1}'.format(fun, exc))
|
||||
log.exception('Exception occurred while introspecting %s', fun)
|
||||
data['return'] = 'Exception occurred in wheel {0}: {1}: {2}'.format(
|
||||
fun,
|
||||
exc.__class__.__name__,
|
||||
|
@ -1179,12 +1171,9 @@ class LocalFuncs(object):
|
|||
if publisher_acl.user_is_blacklisted(load['user']) or \
|
||||
publisher_acl.cmd_is_blacklisted(load['fun']):
|
||||
log.error(
|
||||
'{user} does not have permissions to run {function}. Please '
|
||||
'contact your local administrator if you believe this is in '
|
||||
'error.\n'.format(
|
||||
user=load['user'],
|
||||
function=load['fun']
|
||||
)
|
||||
'%s does not have permissions to run %s. Please contact '
|
||||
'your local administrator if you believe this is in error.',
|
||||
load['user'], load['fun']
|
||||
)
|
||||
return ''
|
||||
|
||||
|
@ -1237,7 +1226,7 @@ class LocalFuncs(object):
|
|||
if auth_type == 'token':
|
||||
username = auth_check.get('username')
|
||||
load['user'] = username
|
||||
log.debug('Minion tokenized user = "{0}"'.format(username))
|
||||
log.debug('Minion tokenized user = "%s"', username)
|
||||
elif auth_type == 'eauth':
|
||||
# The username we are attempting to auth with
|
||||
load['user'] = self.loadauth.load_name(extra)
|
||||
|
@ -1284,13 +1273,12 @@ class LocalFuncs(object):
|
|||
except KeyError:
|
||||
log.critical(
|
||||
'The specified returner used for the external job cache '
|
||||
'"{0}" does not have a save_load function!'.format(
|
||||
self.opts['ext_job_cache']
|
||||
)
|
||||
'"%s" does not have a save_load function!',
|
||||
self.opts['ext_job_cache']
|
||||
)
|
||||
except Exception:
|
||||
log.critical(
|
||||
'The specified returner threw a stack trace:\n',
|
||||
'The specified returner threw a stack trace:',
|
||||
exc_info=True
|
||||
)
|
||||
|
||||
|
@ -1301,13 +1289,12 @@ class LocalFuncs(object):
|
|||
except KeyError:
|
||||
log.critical(
|
||||
'The specified returner used for the master job cache '
|
||||
'"{0}" does not have a save_load function!'.format(
|
||||
self.opts['master_job_cache']
|
||||
)
|
||||
'"%s" does not have a save_load function!',
|
||||
self.opts['master_job_cache']
|
||||
)
|
||||
except Exception:
|
||||
log.critical(
|
||||
'The specified returner threw a stack trace:\n',
|
||||
'The specified returner threw a stack trace:',
|
||||
exc_info=True
|
||||
)
|
||||
# Altering the contents of the publish load is serious!! Changes here
|
||||
|
@ -1347,18 +1334,16 @@ class LocalFuncs(object):
|
|||
|
||||
if 'user' in load:
|
||||
log.info(
|
||||
'User {user} Published command {fun} with jid {jid}'.format(
|
||||
**load
|
||||
)
|
||||
'User %s Published command %s with jid %s',
|
||||
load['user'], load['fun'], load['jid']
|
||||
)
|
||||
pub_load['user'] = load['user']
|
||||
else:
|
||||
log.info(
|
||||
'Published command {fun} with jid {jid}'.format(
|
||||
**load
|
||||
)
|
||||
'Published command %s with jid %s',
|
||||
load['fun'], load['jid']
|
||||
)
|
||||
log.debug('Published command details {0}'.format(pub_load))
|
||||
log.debug('Published command details %s', pub_load)
|
||||
|
||||
return {'ret': {
|
||||
'jid': load['jid'],
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
salting.py module of salt specific interfaces to raet
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
# pylint: skip-file
|
||||
# pylint: disable=W0611
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@ from salt.daemons import test
|
|||
test.run()
|
||||
|
||||
'''
|
||||
# pylint: skip-file
|
||||
# pylint: disable=C0103,3rd-party-module-not-gated
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import sys
|
||||
# pylint: disable=blacklisted-import
|
||||
if sys.version_info < (2, 7):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
# pylint: enable=blacklisted-import
|
||||
import os
|
||||
|
||||
|
||||
|
@ -24,6 +24,7 @@ from ioflo.base.consoling import getConsole
|
|||
console = getConsole()
|
||||
console.reinit(verbosity=console.Wordage.concise)
|
||||
|
||||
|
||||
def run(start=None):
|
||||
'''
|
||||
Run unittests starting at directory given by start
|
||||
|
@ -37,7 +38,7 @@ def run(start=None):
|
|||
|
||||
console.terse("\nRunning all salt.daemons unit tests in '{0}', starting at '{1}'\n".format(top, start))
|
||||
loader = unittest.TestLoader()
|
||||
suite = loader.discover(start, 'test_*.py', top )
|
||||
suite = loader.discover(start, 'test_*.py', top)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
from . import actors
|
||||
|
||||
__all__ = ['actors']
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
'''
|
||||
Test behaviors used by test plans
|
||||
'''
|
||||
# pylint: skip-file
|
||||
# pylint: disable=C0103
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import stat
|
||||
import time
|
||||
|
@ -28,7 +26,7 @@ from salt.daemons import salting
|
|||
from salt.utils.event import tagify
|
||||
|
||||
|
||||
class DeedTestWrapper():
|
||||
class DeedTestWrapper(object):
|
||||
def assertTrue(self, condition):
|
||||
if not condition:
|
||||
self.failure.value = 'Fail'
|
||||
|
@ -94,7 +92,7 @@ class TestOptsSetup(ioflo.base.deeding.Deed):
|
|||
raet_port=self.raet_port,
|
||||
transport='raet',
|
||||
client_acl=dict(),
|
||||
publisher_acl = dict(),
|
||||
publisher_acl=dict(),
|
||||
pki_dir=pkiDirpath,
|
||||
sock_dir=sockDirpath,
|
||||
cachedir=cacheDirpath,
|
||||
|
@ -243,9 +241,9 @@ class TestPresenceAvailable(ioflo.base.deeding.Deed):
|
|||
'ival': set()}}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'available' request (A1, B*)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -306,9 +304,9 @@ class TestPresenceJoined(ioflo.base.deeding.Deed):
|
|||
'ival': odict()}}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'joined' request (A2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -350,9 +348,9 @@ class TestPresenceAllowed(ioflo.base.deeding.Deed):
|
|||
'ival': odict()}}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'allowed' request (A3)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -394,9 +392,9 @@ class TestPresenceAlived(ioflo.base.deeding.Deed):
|
|||
'ival': odict()}}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'alived' request (A4)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -438,9 +436,9 @@ class TestPresenceReaped(ioflo.base.deeding.Deed):
|
|||
'ival': odict()}}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'reaped' request (A5)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -479,14 +477,11 @@ class TestPresenceNoRequest(ioflo.base.deeding.Deed):
|
|||
Ioinits = {}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter with no requests (C1)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
pass # do nothing
|
||||
|
||||
|
||||
class TestPresenceNoRequestCheck(ioflo.base.deeding.Deed, DeedTestWrapper):
|
||||
Ioinits = {'event_stack': '.salt.test.lane.stack',
|
||||
|
@ -505,9 +500,9 @@ class TestPresenceUnknownSrc(ioflo.base.deeding.Deed, DeedTestWrapper):
|
|||
'failure': '.meta.failure'}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter handles request from unknown (disconnected) source (C2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -537,9 +532,9 @@ class TestPresenceAvailableNoMinions(ioflo.base.deeding.Deed):
|
|||
'event_stack': '.salt.test.lane.stack'}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'available' request with no minions in the state (D1)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -580,9 +575,9 @@ class TestPresenceAvailableOneMinion(ioflo.base.deeding.Deed):
|
|||
'ival': set()}}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'available' request with one minions in the state (D2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -626,9 +621,9 @@ class TestPresenceAvailableUnknownIp(ioflo.base.deeding.Deed):
|
|||
'ival': set()}}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'available' request with one minions in the state (D3)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -673,9 +668,9 @@ class TestPresenceAllowedNoMinions(ioflo.base.deeding.Deed):
|
|||
'event_stack': '.salt.test.lane.stack'}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'allowed' request with no minions in the state (D4)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -713,9 +708,9 @@ class TestPresenceAllowedOneMinion(ioflo.base.deeding.Deed):
|
|||
'ival': odict()}}
|
||||
|
||||
def action(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'allowed' request with one minion in the state (D5)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.action.__doc__))
|
||||
|
||||
# Prepare
|
||||
|
@ -745,7 +740,7 @@ class TestPresenceAllowedOneMinionCheck(ioflo.base.deeding.Deed, DeedTestWrapper
|
|||
self.assertTrue(msg == {'route': {'src': [None, 'manor', None],
|
||||
'dst': [None, None, 'event_fire']},
|
||||
'tag': tag,
|
||||
'data': {'allowed': {'alpha':'1.1.1.1'}}})
|
||||
'data': {'allowed': {'alpha': '1.1.1.1'}}})
|
||||
|
||||
|
||||
class StatsMasterTestSetup(ioflo.base.deeding.Deed):
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
Runs minion floscript
|
||||
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
# pylint: skip-file
|
||||
import os
|
||||
import stat
|
||||
|
|
|
@ -3,15 +3,11 @@
|
|||
'''
|
||||
Runs minion floscript
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
# pylint: skip-file
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import stat
|
||||
|
||||
from ioflo.aid.odicting import odict
|
||||
from ioflo.base.consoling import getConsole
|
||||
console = getConsole()
|
||||
|
||||
|
@ -21,6 +17,7 @@ FLO_DIR_PATH = os.path.join(
|
|||
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'flo'
|
||||
)
|
||||
|
||||
|
||||
def test():
|
||||
""" Execute run.start """
|
||||
|
||||
|
@ -48,37 +45,35 @@ def test():
|
|||
mode = os.stat(localFilepath).st_mode
|
||||
print(mode)
|
||||
|
||||
|
||||
cacheDirpath = os.path.join('/tmp/raet', 'cache', 'minion')
|
||||
if not os.path.exists(cacheDirpath):
|
||||
os.makedirs(cacheDirpath)
|
||||
|
||||
sockDirpath = os.path.join('/tmp/raet', 'sock', 'minion')
|
||||
if not os.path.exists(sockDirpath):
|
||||
os.makedirs(sockDirpath)
|
||||
|
||||
os.makedirs(sockDirpath)
|
||||
|
||||
#filepath = os.path.join(FLO_DIR_PATH, 'minion.flo')
|
||||
filepath = 'minion.flo'
|
||||
opts = dict(
|
||||
id="minion",
|
||||
__role='minion',
|
||||
ioflo_period=0.1,
|
||||
ioflo_realtime=True,
|
||||
minion_floscript=filepath,
|
||||
ioflo_verbose=2,
|
||||
interface="",
|
||||
raet_port=7531,
|
||||
master_port=7530,
|
||||
master='127.0.0.1',
|
||||
transport='raet',
|
||||
client_acl=dict(),
|
||||
publisher_acl=dict(),
|
||||
pki_dir=pkiDirpath,
|
||||
sock_dir=sockDirpath,
|
||||
cachedir=cacheDirpath,
|
||||
open_mode=True,
|
||||
auto_accept=True)
|
||||
id="minion",
|
||||
__role='minion',
|
||||
ioflo_period=0.1,
|
||||
ioflo_realtime=True,
|
||||
minion_floscript=filepath,
|
||||
ioflo_verbose=2,
|
||||
interface="",
|
||||
raet_port=7531,
|
||||
master_port=7530,
|
||||
master='127.0.0.1',
|
||||
transport='raet',
|
||||
client_acl=dict(),
|
||||
publisher_acl=dict(),
|
||||
pki_dir=pkiDirpath,
|
||||
sock_dir=sockDirpath,
|
||||
cachedir=cacheDirpath,
|
||||
open_mode=True,
|
||||
auto_accept=True)
|
||||
|
||||
minion = salt.daemons.flo.IofloMinion(opts=opts)
|
||||
minion.start(behaviors=['raet.flo.behaving'])
|
||||
|
|
|
@ -3,41 +3,33 @@
|
|||
Tests of utilities that support multiple masters in Salt Raet
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
# pylint: skip-file
|
||||
# pylint: disable=C0103
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import sys
|
||||
from salt.ext.six.moves import map
|
||||
# pylint: disable=blacklisted-import
|
||||
if sys.version_info < (2, 7):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
# pylint: enable=blacklisted-import
|
||||
|
||||
import os
|
||||
import stat
|
||||
import time
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
from ioflo.aid.odicting import odict
|
||||
from ioflo.aid.timing import Timer, StoreTimer
|
||||
from ioflo.aid.timing import StoreTimer
|
||||
from ioflo.base import storing
|
||||
from ioflo.base.consoling import getConsole
|
||||
console = getConsole()
|
||||
|
||||
from raet import raeting
|
||||
|
||||
from salt.daemons import parse_hostname, extract_masters
|
||||
from salt.daemons import parse_hostname, extract_masters
|
||||
|
||||
|
||||
def setUpModule():
|
||||
console.reinit(verbosity=console.Wordage.concise)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
pass
|
||||
|
||||
class BasicTestCase(unittest.TestCase):
|
||||
""""""
|
||||
|
||||
class BasicTestCase(unittest.TestCase): # pylint: disable=moved-test-case-class
|
||||
|
||||
def setUp(self):
|
||||
self.store = storing.Store(stamp=0.0)
|
||||
|
@ -48,8 +40,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def testParseHostname(self):
|
||||
'''
|
||||
Test parsing hostname provided according to syntax for opts['master']
|
||||
|
@ -88,7 +78,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
self.assertEquals(parse_hostname(' fe80::1%lo0 ', self.port),
|
||||
('fe80::1%lo0', 4506))
|
||||
|
||||
|
||||
self.assertEquals(parse_hostname('localhost 4510', self.port),
|
||||
('localhost', 4510))
|
||||
self.assertEquals(parse_hostname('127.0.0.1 4510', self.port),
|
||||
|
@ -105,7 +94,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
self.assertEquals(parse_hostname('fe80::1%lo0 4510', self.port),
|
||||
('fe80::1%lo0', 4510))
|
||||
|
||||
|
||||
self.assertEquals(parse_hostname(' localhost 4510 ', self.port),
|
||||
('localhost', 4510))
|
||||
self.assertEquals(parse_hostname(' 127.0.0.1 4510 ', self.port),
|
||||
|
@ -122,7 +110,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
self.assertEquals(parse_hostname(' fe80::1%lo0 4510 ', self.port),
|
||||
('fe80::1%lo0', 4510))
|
||||
|
||||
|
||||
self.assertEquals(parse_hostname('localhost abcde', self.port), None)
|
||||
self.assertEquals(parse_hostname('127.0.0.1 a4510', self.port), None)
|
||||
self.assertEquals(parse_hostname(list([1, 2, 3]), self.port), None)
|
||||
|
@ -150,7 +137,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
self.assertEquals(parse_hostname('localhost::4510', self.port),
|
||||
('localhost::4510', 4506))
|
||||
|
||||
|
||||
def testExtractMastersSingle(self):
|
||||
'''
|
||||
Test extracting from master provided according to syntax for opts['master']
|
||||
|
@ -189,7 +175,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
internal=None),
|
||||
])
|
||||
|
||||
|
||||
master = '10.0.2.23'
|
||||
self.opts.update(master=master)
|
||||
self.assertEquals(extract_masters(self.opts),
|
||||
|
@ -240,8 +225,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
master = dict(internal='10.0.2.23 4510')
|
||||
self.opts.update(master=master)
|
||||
self.assertEquals(extract_masters(self.opts),[])
|
||||
|
||||
self.assertEquals(extract_masters(self.opts), [])
|
||||
|
||||
def testExtractMastersMultiple(self):
|
||||
'''
|
||||
|
@ -332,22 +316,24 @@ def runOne(test):
|
|||
suite = unittest.TestSuite([test])
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
|
||||
def runSome():
|
||||
'''
|
||||
Unittest runner
|
||||
'''
|
||||
tests = []
|
||||
tests = []
|
||||
names = [
|
||||
'testParseHostname',
|
||||
'testExtractMastersSingle',
|
||||
'testExtractMastersMultiple',
|
||||
]
|
||||
'testParseHostname',
|
||||
'testExtractMastersSingle',
|
||||
'testExtractMastersMultiple',
|
||||
]
|
||||
|
||||
tests.extend(list(list(map(BasicTestCase, names))))
|
||||
|
||||
suite = unittest.TestSuite(tests)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
|
||||
def runAll():
|
||||
'''
|
||||
Unittest runner
|
||||
|
@ -357,12 +343,13 @@ def runAll():
|
|||
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
|
||||
if __name__ == '__main__' and __package__ is None:
|
||||
|
||||
#console.reinit(verbosity=console.Wordage.concise)
|
||||
|
||||
#runAll() #run all unittests
|
||||
#runAll() # run all unittests
|
||||
|
||||
runSome()#only run some
|
||||
runSome() # only run some
|
||||
|
||||
#runOne('testParseHostname')
|
||||
|
|
|
@ -9,7 +9,7 @@ Runs all the example FloScripts
|
|||
# pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
|
||||
# Import 3rd-party libs
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
'''
|
||||
Raet Ioflo Behavior Unittests
|
||||
"""
|
||||
# pylint: skip-file
|
||||
# pylint: disable=C0103
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import sys
|
||||
from salt.ext.six.moves import map
|
||||
# pylint: disable=blacklisted-import
|
||||
if sys.version_info < (2, 7):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
# pylint: enable=blacklisted-import
|
||||
|
||||
from ioflo.base.consoling import getConsole
|
||||
console = getConsole()
|
||||
|
@ -21,37 +22,31 @@ from raet.stacking import Stack
|
|||
|
||||
from salt.utils.event import tagify
|
||||
|
||||
# Import Ioflo Deeds
|
||||
from salt.daemons.flo import core
|
||||
from salt.daemons.test.plan import actors
|
||||
|
||||
|
||||
def setUpModule():
|
||||
console.reinit(verbosity=console.Wordage.concise)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
pass
|
||||
|
||||
|
||||
class PresenterTestCase(testing.FrameIofloTestCase):
|
||||
"""
|
||||
'''
|
||||
Test case for Salt Raet Presenter deed
|
||||
"""
|
||||
|
||||
'''
|
||||
def setUp(self):
|
||||
"""
|
||||
'''
|
||||
Call super if override so House Framer and Frame are setup correctly
|
||||
"""
|
||||
'''
|
||||
super(PresenterTestCase, self).setUp()
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
'''
|
||||
Call super if override so House Framer and Frame are torn down correctly
|
||||
"""
|
||||
'''
|
||||
super(PresenterTestCase, self).tearDown()
|
||||
|
||||
|
||||
def addPresenceInfo(self, stateGrp, name, ip, port):
|
||||
self.assertIn(stateGrp, ('alloweds', 'aliveds', 'reapeds'))
|
||||
group = self.store.fetch('.salt.var.presence.{0}'.format(stateGrp))
|
||||
|
@ -61,19 +56,17 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
remote.ha = (ip, port)
|
||||
group.value[name] = remote
|
||||
|
||||
|
||||
def addAvailable(self, name):
|
||||
availables = self.store.fetch('.salt.var.presence.availables')
|
||||
if availables.value is None:
|
||||
availables.value = set()
|
||||
availables.value.add(name)
|
||||
|
||||
|
||||
def testContextSetup(self):
|
||||
"""
|
||||
'''
|
||||
Test the context setup procedure used in all the consequence tests works as expected
|
||||
This test intended to avoid some checks in other tests
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testContextSetup.__doc__))
|
||||
|
||||
act = self.addEnterDeed("TestOptsSetupMaster")
|
||||
|
@ -118,11 +111,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceAvailable(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'available' request (A1, B*)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceAvailable.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -187,11 +179,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceJoined(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'joined' request (A2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceJoined.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -238,11 +229,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceAllowed(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'allowed' request (A3)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceAllowed.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -288,11 +278,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceAlived(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'alived' request (A4)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceAlived.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -338,11 +327,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceReaped(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'reaped' request (A5)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceReaped.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -388,11 +376,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceNoRequest(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter with no requests (C1)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceNoRequest.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -418,11 +405,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceUnknownSrc(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter handles request from unknown (disconnected) source (C2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceUnknownSrc.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -458,11 +444,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceAvailableNoMinions(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'available' request with no minions in the state (D1)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceAvailableNoMinions.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -503,11 +488,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceAvailableOneMinion(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'available' request with one minion in the state (D2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceAvailableOneMinion.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -551,11 +535,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceAvailableSomeIpUnknown(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'available' request with some minion addresses aren't known (D3)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceAvailableSomeIpUnknown.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -604,11 +587,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceAllowedNoMinions(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'allowed' request with no minions in the state (D4)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceAllowedNoMinions.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -650,11 +632,10 @@ class PresenterTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def testPresenceAllowedOneMinion(self):
|
||||
"""
|
||||
'''
|
||||
Test Presenter 'allowed' request with one minion in the state (D5)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testPresenceAllowedOneMinion.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -709,7 +690,9 @@ def runOne(test):
|
|||
|
||||
|
||||
def runSome():
|
||||
""" Unittest runner """
|
||||
'''
|
||||
Unittest runner
|
||||
'''
|
||||
tests = []
|
||||
names = [
|
||||
'testContextSetup',
|
||||
|
@ -725,14 +708,16 @@ def runSome():
|
|||
'testPresenceAvailableSomeIpUnknown',
|
||||
'testPresenceAllowedNoMinions',
|
||||
'testPresenceAllowedOneMinion',
|
||||
]
|
||||
tests.extend(map(PresenterTestCase, names))
|
||||
]
|
||||
tests.extend(list(map(PresenterTestCase, names)))
|
||||
suite = unittest.TestSuite(tests)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
|
||||
def runAll():
|
||||
""" Unittest runner """
|
||||
'''
|
||||
Unittest runner
|
||||
'''
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(PresenterTestCase))
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Tests to try out salt key.RaetKey Potentially ephemeral
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
# pylint: skip-file
|
||||
# pylint: disable=C0103
|
||||
import sys
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Tests to try out salt key.RaetKey Potentially ephemeral
|
||||
|
||||
'''
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from __future__ import absolute_import
|
||||
# pylint: skip-file
|
||||
# pylint: disable=C0103
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import sys
|
||||
from salt.ext.six.moves import map
|
||||
# pylint: disable=blacklisted-import
|
||||
if sys.version_info < (2, 7):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
# pylint: enable=blacklisted-import
|
||||
|
||||
import os
|
||||
import stat
|
||||
|
@ -22,27 +19,27 @@ import tempfile
|
|||
import shutil
|
||||
|
||||
from ioflo.aid.odicting import odict
|
||||
from ioflo.aid.timing import Timer, StoreTimer
|
||||
from ioflo.aid.timing import StoreTimer
|
||||
from ioflo.base import storing
|
||||
from ioflo.base.consoling import getConsole
|
||||
console = getConsole()
|
||||
|
||||
from raet import raeting, nacling
|
||||
from raet.road import estating, keeping, stacking
|
||||
from raet.road import estating, stacking
|
||||
|
||||
from salt.key import RaetKey
|
||||
from salt.daemons import salting
|
||||
from salt import daemons
|
||||
import salt.utils.kinds as kinds
|
||||
|
||||
|
||||
def setUpModule():
|
||||
console.reinit(verbosity=console.Wordage.concise)
|
||||
|
||||
|
||||
def tearDownModule():
|
||||
pass
|
||||
|
||||
class BasicTestCase(unittest.TestCase):
|
||||
""""""
|
||||
|
||||
class BasicTestCase(unittest.TestCase): # pylint: disable=moved-test-case-class
|
||||
|
||||
def setUp(self):
|
||||
self.store = storing.Store(stamp=0.0)
|
||||
|
@ -68,7 +65,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
'''
|
||||
pkiDirpath = os.path.join(dirpath, 'pki', role, 'raet')
|
||||
if not os.path.exists(pkiDirpath):
|
||||
os.makedirs(pkiDirpath)
|
||||
os.makedirs(pkiDirpath)
|
||||
|
||||
acceptedDirpath = os.path.join(pkiDirpath, 'accepted')
|
||||
if not os.path.exists(acceptedDirpath):
|
||||
|
@ -103,7 +100,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
)
|
||||
return opts
|
||||
|
||||
def createRoadData(self, role, kind=kinds.APPL_KIND_NAMES[kinds.applKinds.master], cachedirpath=''):
|
||||
def createRoadData(self, role, kind=kinds.APPL_KIND_NAMES[kinds.applKinds.master], cachedirpath=''):
|
||||
'''
|
||||
Creates odict and populates with data to setup road stack
|
||||
{
|
||||
|
@ -116,9 +113,9 @@ class BasicTestCase(unittest.TestCase):
|
|||
}
|
||||
'''
|
||||
data = odict()
|
||||
data['name'] = "{0}_{1}".format(role, kind )
|
||||
data['name'] = "{0}_{1}".format(role, kind)
|
||||
data['role'] = role
|
||||
data['kind'] = kinds.APPL_KINDS[kind] # convert to integer from kind name
|
||||
data['kind'] = kinds.APPL_KINDS[kind] # convert to integer from kind name
|
||||
data['basedirpath'] = os.path.join(cachedirpath, 'raet')
|
||||
signer = nacling.Signer()
|
||||
data['sighex'] = signer.keyhex
|
||||
|
@ -127,10 +124,9 @@ class BasicTestCase(unittest.TestCase):
|
|||
data['prihex'] = privateer.keyhex
|
||||
data['pubhex'] = privateer.pubhex
|
||||
|
||||
|
||||
return data
|
||||
|
||||
def createRoadStack(self, data, keep, uid=None, main=None, ha=None, mutable=None):
|
||||
def createRoadStack(self, data, keep, uid=None, main=None, ha=None, mutable=None):
|
||||
'''
|
||||
Creates stack and local estate from data with
|
||||
local estate.uid = uid
|
||||
|
@ -144,7 +140,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
returns stack
|
||||
|
||||
'''
|
||||
|
||||
stack = stacking.RoadStack(store=self.store,
|
||||
name=data['name'],
|
||||
keep=keep,
|
||||
|
@ -166,8 +161,8 @@ class BasicTestCase(unittest.TestCase):
|
|||
console.terse("\nJoin Transaction **************\n")
|
||||
if not initiator.remotes:
|
||||
remote = initiator.addRemote(estating.RemoteEstate(stack=initiator,
|
||||
fuid=0, # vacuous join
|
||||
sid=0, # always 0 for join
|
||||
fuid=0, # vacuous join
|
||||
sid=0, # always 0 for join
|
||||
ha=correspondent.local.ha))
|
||||
deid = remote.uid
|
||||
initiator.join(uid=deid)
|
||||
|
@ -181,7 +176,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
other.allow()
|
||||
self.service(main, other, duration=duration)
|
||||
|
||||
def message(self, main, other, mains, others, duration=2.0):
|
||||
def message(self, main, other, mains, others, duration=2.0):
|
||||
'''
|
||||
Utility to send messages both ways
|
||||
'''
|
||||
|
@ -218,7 +213,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=False)
|
||||
mainData = self.createRoadData(cachedirpath=opts['cachedir'],
|
||||
role=opts['id'],
|
||||
kind=opts['__role'] )
|
||||
kind=opts['__role'])
|
||||
mainKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=mainData['basedirpath'],
|
||||
stackname=mainData['name'])
|
||||
|
@ -228,7 +223,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -341,7 +336,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=False)
|
||||
otherData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
otherKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=otherData['basedirpath'],
|
||||
stackname=otherData['name'])
|
||||
|
@ -468,7 +463,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -579,7 +574,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
otherData = self.createRoadData(role='other',
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
otherKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=otherData['basedirpath'],
|
||||
stackname=otherData['name'])
|
||||
|
@ -596,7 +591,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
other.name, other.keep.dirpath))
|
||||
self.assertTrue(other.keep.dirpath.endswith(os.path.join('other', 'raet', 'other_minion')))
|
||||
self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT))
|
||||
self.assertIs(other.keep.auto,raeting.AutoMode.always.value)
|
||||
self.assertIs(other.keep.auto, raeting.AutoMode.always.value)
|
||||
|
||||
self.assertDictEqual(other.keep.loadLocalData(),
|
||||
{
|
||||
|
@ -696,7 +691,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
mainData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
mainKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=mainData['basedirpath'],
|
||||
stackname=mainData['name'])
|
||||
|
@ -706,14 +701,14 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
main.name, main.keep.dirpath))
|
||||
self.assertTrue(main.keep.dirpath.endswith(os.path.join('main', 'raet', 'main_master')))
|
||||
self.assertTrue(main.ha, ("0.0.0.0", raeting.RAET_PORT))
|
||||
self.assertIs(main.keep.auto, raeting.AutoMode.once.value)
|
||||
self.assertIs(main.keep.auto, raeting.AutoMode.once.value)
|
||||
self.assertDictEqual(main.keep.loadLocalData(), {
|
||||
'name': mainData['name'],
|
||||
'uid': 1,
|
||||
|
@ -819,7 +814,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
otherData = self.createRoadData(role='other',
|
||||
kind=kinds.APPL_KIND_NAMES[kinds.applKinds.minion],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
otherKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=otherData['basedirpath'],
|
||||
stackname=otherData['name'])
|
||||
|
@ -947,7 +942,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -982,7 +977,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
role=data1['role'],
|
||||
verkey=data1['verhex'],
|
||||
pubkey=data1['pubhex'],
|
||||
) )
|
||||
))
|
||||
|
||||
data2 = self.createRoadData(role='primary',
|
||||
kind=kinds.APPL_KIND_NAMES[kinds.applKinds.caller],
|
||||
|
@ -995,7 +990,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
role=data2['role'],
|
||||
verkey=data2['verhex'],
|
||||
pubkey=data2['pubhex'],
|
||||
) )
|
||||
))
|
||||
|
||||
main.dumpRemotes()
|
||||
|
||||
|
@ -1095,7 +1090,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -1129,7 +1124,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
ha=('127.0.0.1', 7532),
|
||||
role=data1['role'],
|
||||
verkey=data1['verhex'],
|
||||
pubkey=data1['pubhex'],) )
|
||||
pubkey=data1['pubhex'],))
|
||||
|
||||
data2 = self.createRoadData(role='primary',
|
||||
kind='syndic',
|
||||
|
@ -1140,9 +1135,9 @@ class BasicTestCase(unittest.TestCase):
|
|||
ha=('127.0.0.1', 7533),
|
||||
role=data2['role'],
|
||||
verkey=data2['verhex'],
|
||||
pubkey=data2['pubhex'],) )
|
||||
pubkey=data2['pubhex'],))
|
||||
|
||||
main.dumpRemotes() # second one keys will clobber first one keys
|
||||
main.dumpRemotes() # second one keys will clobber first one keys
|
||||
|
||||
self.assertDictEqual(main.keep.loadAllRemoteData(),
|
||||
{
|
||||
|
@ -1239,7 +1234,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -1275,7 +1270,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
role=data1['role'],
|
||||
verkey=data1['verhex'],
|
||||
pubkey=data1['pubhex'],
|
||||
) )
|
||||
))
|
||||
|
||||
data2 = self.createRoadData(role='primary',
|
||||
kind='syndic',
|
||||
|
@ -1288,7 +1283,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
role=data2['role'],
|
||||
verkey=data2['verhex'],
|
||||
pubkey=data2['pubhex'],
|
||||
) )
|
||||
))
|
||||
|
||||
main.dumpRemotes()
|
||||
|
||||
|
@ -1365,7 +1360,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
self.assertEqual(remote.pubber.keyhex, data1['pubhex'])
|
||||
self.assertEqual(remote.verfer.keyhex, data1['verhex'])
|
||||
|
||||
|
||||
main.server.close()
|
||||
|
||||
def testBootstrapNever(self):
|
||||
|
@ -1381,7 +1375,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=False)
|
||||
mainData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
mainKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=mainData['basedirpath'],
|
||||
stackname=mainData['name'])
|
||||
|
@ -1391,7 +1385,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -1422,7 +1416,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
otherData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
otherKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=otherData['basedirpath'],
|
||||
stackname=otherData['name'])
|
||||
|
@ -1439,7 +1433,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
other.name, other.keep.dirpath))
|
||||
self.assertTrue(other.keep.dirpath.endswith(os.path.join('other', 'raet', 'other_minion')))
|
||||
self.assertEqual(other.ha, ("0.0.0.0", raeting.RAET_TEST_PORT))
|
||||
self.assertIs(other.keep.auto, raeting.AutoMode.once.value)
|
||||
self.assertIs(other.keep.auto, raeting.AutoMode.once.value)
|
||||
self.assertDictEqual(other.keep.loadLocalData(),
|
||||
{
|
||||
'name': otherData['name'],
|
||||
|
@ -1458,7 +1452,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
})
|
||||
|
||||
self.join(other, main)
|
||||
self.assertEqual(len(main.transactions), 1) # pending
|
||||
self.assertEqual(len(main.transactions), 1) # pending
|
||||
main.keep.acceptRemote(main.nameRemotes[other.local.name])
|
||||
self.service(main, other, duration=1.0)
|
||||
|
||||
|
@ -1482,7 +1476,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
"{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext))
|
||||
self.assertTrue(os.path.exists(path))
|
||||
|
||||
|
||||
# now delete a key and see if road keep file is also deleted
|
||||
main.keep.saltRaetKey.delete_key(match=other.local.role)
|
||||
remote = main.remotes[2]
|
||||
|
@ -1507,7 +1500,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
mainData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
mainKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=mainData['basedirpath'],
|
||||
stackname=mainData['name'])
|
||||
|
@ -1517,7 +1510,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -1548,7 +1541,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
otherData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
otherKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=otherData['basedirpath'],
|
||||
stackname=otherData['name'])
|
||||
|
@ -1604,7 +1597,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
"{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext))
|
||||
self.assertTrue(os.path.exists(path))
|
||||
|
||||
|
||||
# now delete a key and see if road keep file is also deleted
|
||||
main.keep.saltRaetKey.delete_key(match=other.local.role)
|
||||
remote = main.remotes[2]
|
||||
|
@ -1629,7 +1621,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
mainData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
mainKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=mainData['basedirpath'],
|
||||
stackname=mainData['name'])
|
||||
|
@ -1639,7 +1631,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -1670,7 +1662,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
otherData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
otherKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=otherData['basedirpath'],
|
||||
stackname=otherData['name'])
|
||||
|
@ -1726,7 +1718,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
"{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext))
|
||||
self.assertTrue(os.path.exists(path))
|
||||
|
||||
|
||||
# now delete a key and see if road keep file is also deleted
|
||||
main.keep.saltRaetKey.delete_key(match=other.local.role)
|
||||
remote = main.remotes[2]
|
||||
|
@ -1751,7 +1742,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=False)
|
||||
mainData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
mainKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=mainData['basedirpath'],
|
||||
stackname=mainData['name'])
|
||||
|
@ -1761,7 +1752,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -1792,7 +1783,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
other1Data = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
other1Keep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=other1Data['basedirpath'],
|
||||
stackname=other1Data['name'])
|
||||
|
@ -1828,7 +1819,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
})
|
||||
|
||||
self.join(other1, main)
|
||||
self.assertEqual(len(main.transactions), 1) # pending
|
||||
self.assertEqual(len(main.transactions), 1) # pending
|
||||
main.keep.acceptRemote(main.nameRemotes[other1.local.name])
|
||||
self.service(main, other1, duration=1.0)
|
||||
|
||||
|
@ -1860,7 +1851,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
other2Data = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
other2Keep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=other2Data['basedirpath'],
|
||||
stackname=other2Data['name'])
|
||||
|
@ -1897,7 +1888,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
# should not join since role same but keys different
|
||||
self.join(other2, main)
|
||||
self.assertEqual(len(main.transactions), 0) # rejected since not same keys
|
||||
self.assertEqual(len(main.transactions), 0) # rejected since not same keys
|
||||
self.assertEqual(len(other2.remotes), 0)
|
||||
self.assertEqual(len(main.remotes), 1)
|
||||
#main.removeRemote(main.nameRemotes[other2.local.name], clear=True)
|
||||
|
@ -1918,7 +1909,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
other2Data = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
other2Data['sighex'] = other1Data['sighex']
|
||||
other2Data['prihex'] = other1Data['prihex']
|
||||
other2Keep = salting.SaltKeep(opts=opts,
|
||||
|
@ -2006,7 +1997,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
mainData = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
mainKeep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=mainData['basedirpath'],
|
||||
stackname=mainData['name'])
|
||||
|
@ -2016,7 +2007,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
|
||||
main = self.createRoadStack(data=mainData,
|
||||
main=True,
|
||||
ha=None, #default ha is ("", raeting.RAET_PORT)
|
||||
ha=None, # default ha is ("", raeting.RAET_PORT)
|
||||
keep=mainKeep)
|
||||
|
||||
console.terse("{0}\nkeep dirpath = {1}\n".format(
|
||||
|
@ -2047,7 +2038,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
other1Data = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
other1Keep = salting.SaltKeep(opts=opts,
|
||||
basedirpath=other1Data['basedirpath'],
|
||||
stackname=other1Data['name'])
|
||||
|
@ -2111,7 +2102,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
autoAccept=True)
|
||||
other2Data = self.createRoadData(role=opts['id'],
|
||||
kind=opts['__role'],
|
||||
cachedirpath=opts['cachedir'] )
|
||||
cachedirpath=opts['cachedir'])
|
||||
other2Data['sighex'] = other1Data['sighex']
|
||||
other2Data['prihex'] = other1Data['prihex']
|
||||
|
||||
|
@ -2172,7 +2163,6 @@ class BasicTestCase(unittest.TestCase):
|
|||
"{0}.{1}.{2}".format(main.keep.prefix, remote.name, main.keep.ext))
|
||||
self.assertTrue(os.path.exists(path))
|
||||
|
||||
|
||||
# now delete a key and see if both road keep file are also deleted
|
||||
main.keep.saltRaetKey.delete_key(match=other1.local.role)
|
||||
remote = main.remotes[2]
|
||||
|
@ -2188,6 +2178,7 @@ class BasicTestCase(unittest.TestCase):
|
|||
stack.server.close()
|
||||
stack.clearAllKeeps()
|
||||
|
||||
|
||||
def runOne(test):
|
||||
'''
|
||||
Unittest Runner
|
||||
|
@ -2196,11 +2187,12 @@ def runOne(test):
|
|||
suite = unittest.TestSuite([test])
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
|
||||
def runSome():
|
||||
'''
|
||||
Unittest runner
|
||||
'''
|
||||
tests = []
|
||||
tests = []
|
||||
names = ['testBasic',
|
||||
'testBasicOpen',
|
||||
'testBasicAuto',
|
||||
|
@ -2214,11 +2206,12 @@ def runSome():
|
|||
'testBootstrapRoleAuto',
|
||||
]
|
||||
|
||||
tests.extend(map(BasicTestCase, names))
|
||||
tests.extend(list(map(BasicTestCase, names)))
|
||||
|
||||
suite = unittest.TestSuite(tests)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
|
||||
def runAll():
|
||||
'''
|
||||
Unittest runner
|
||||
|
@ -2232,8 +2225,8 @@ if __name__ == '__main__' and __package__ is None:
|
|||
|
||||
#console.reinit(verbosity=console.Wordage.concise)
|
||||
|
||||
#runAll() #run all unittests
|
||||
#runAll() # run all unittests
|
||||
|
||||
runSome()#only run some
|
||||
runSome() # only run some
|
||||
|
||||
#runOne('testBootstrapRoleAuto')
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
'''
|
||||
Raet Ioflo Behavior Unittests
|
||||
"""
|
||||
# pylint: skip-file
|
||||
# pylint: disable=C0103
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import sys
|
||||
from salt.ext.six.moves import map
|
||||
# pylint: disable=blacklisted-import
|
||||
if sys.version_info < (2, 7):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
# pylint: enable=blacklisted-import
|
||||
import time
|
||||
|
||||
from ioflo.base.consoling import getConsole
|
||||
|
@ -20,14 +21,9 @@ from ioflo.test import testing
|
|||
from raet.abiding import ns2u
|
||||
from raet.lane.stacking import LaneStack
|
||||
from raet.road.stacking import RoadStack
|
||||
from raet.stacking import Stack
|
||||
|
||||
from salt.utils.event import tagify
|
||||
|
||||
# Import Ioflo Deeds
|
||||
from salt.daemons.flo import core
|
||||
from salt.daemons.test.plan import actors
|
||||
|
||||
|
||||
def setUpModule():
|
||||
console.reinit(verbosity=console.Wordage.concise)
|
||||
|
@ -38,29 +34,27 @@ def tearDownModule():
|
|||
|
||||
|
||||
class StatsEventerTestCase(testing.FrameIofloTestCase):
|
||||
"""
|
||||
'''
|
||||
Test case for Salt Raet Stats Eventer Master and Minion deeds
|
||||
"""
|
||||
'''
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
'''
|
||||
Call super if override so House Framer and Frame are setup correctly
|
||||
"""
|
||||
'''
|
||||
super(StatsEventerTestCase, self).setUp()
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
'''
|
||||
Call super if override so House Framer and Frame are torn down correctly
|
||||
"""
|
||||
'''
|
||||
super(StatsEventerTestCase, self).tearDown()
|
||||
|
||||
|
||||
def testMasterContextSetup(self):
|
||||
"""
|
||||
'''
|
||||
Test the context setup procedure used in all the consequence tests works as expected
|
||||
This test intended to avoid some checks in other tests
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMasterContextSetup.__doc__))
|
||||
|
||||
act = self.addEnterDeed("TestOptsSetupMaster")
|
||||
|
@ -105,9 +99,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
act.actor.road_stack.value.server.close()
|
||||
|
||||
def testMasterRoadStats(self):
|
||||
"""
|
||||
'''
|
||||
Test Master Road Stats request (A1)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMasterRoadStats.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -160,9 +154,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
time.sleep(0.1)
|
||||
|
||||
def testMasterLaneStats(self):
|
||||
"""
|
||||
'''
|
||||
Test Master Road Stats request (A2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMasterLaneStats.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -214,9 +208,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
testStack.value.server.close()
|
||||
|
||||
def testMasterStatsWrongMissingTag(self):
|
||||
"""
|
||||
'''
|
||||
Test Master Stats requests with unknown and missing tag (A3, A4)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMasterStatsWrongMissingTag.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -268,9 +262,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
testStack.value.server.close()
|
||||
|
||||
def testMasterStatsUnknownRemote(self):
|
||||
"""
|
||||
'''
|
||||
Test Master Stats request with unknown remote (B1)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMasterStatsUnknownRemote.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -318,9 +312,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
testStack.value.server.close()
|
||||
|
||||
def testMasterStatsNoRequest(self):
|
||||
"""
|
||||
'''
|
||||
Test Master Stats no requests (nothing to do) (B2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMasterStatsNoRequest.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -364,10 +358,10 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
testStack.value.server.close()
|
||||
|
||||
def testMinionContextSetup(self):
|
||||
"""
|
||||
'''
|
||||
Test the context setup procedure used in all the consequence tests works as expected
|
||||
This test intended to avoid some checks in other tests
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMinionContextSetup.__doc__))
|
||||
|
||||
act = self.addEnterDeed("TestOptsSetupMinion")
|
||||
|
@ -412,9 +406,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
act.actor.road_stack.value.server.close()
|
||||
|
||||
def testMinionRoadStats(self):
|
||||
"""
|
||||
'''
|
||||
Test Minion Road Stats request (A1)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMinionRoadStats.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -469,9 +463,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
testStack.value.server.close()
|
||||
|
||||
def testMinionLaneStats(self):
|
||||
"""
|
||||
'''
|
||||
Test Minion Road Stats request (A2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMinionLaneStats.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -526,9 +520,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
testStack.value.server.close()
|
||||
|
||||
def testMinionStatsWrongMissingTag(self):
|
||||
"""
|
||||
'''
|
||||
Test Minion Stats requests with unknown and missing tag (A3, A4)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMinionStatsWrongMissingTag.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -582,9 +576,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
testStack.value.server.close()
|
||||
|
||||
def testMinionStatsUnknownRemote(self):
|
||||
"""
|
||||
'''
|
||||
Test Minion Stats request with unknown remote (B1)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMinionStatsUnknownRemote.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -633,9 +627,9 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
testStack.value.server.close()
|
||||
|
||||
def testMinionStatsNoRequest(self):
|
||||
"""
|
||||
'''
|
||||
Test Minion Stats no requests (nothing to do) (B2)
|
||||
"""
|
||||
'''
|
||||
console.terse("{0}\n".format(self.testMinionStatsNoRequest.__doc__))
|
||||
|
||||
# Bootstrap
|
||||
|
@ -679,6 +673,7 @@ class StatsEventerTestCase(testing.FrameIofloTestCase):
|
|||
if testStack:
|
||||
testStack.value.server.close()
|
||||
|
||||
|
||||
def runOne(test):
|
||||
'''
|
||||
Unittest Runner
|
||||
|
@ -689,7 +684,9 @@ def runOne(test):
|
|||
|
||||
|
||||
def runSome():
|
||||
""" Unittest runner """
|
||||
'''
|
||||
Unittest runner
|
||||
'''
|
||||
tests = []
|
||||
names = [
|
||||
'testMasterContextSetup',
|
||||
|
@ -705,13 +702,15 @@ def runSome():
|
|||
'testMinionStatsUnknownRemote',
|
||||
'testMinionStatsNoRequest',
|
||||
]
|
||||
tests.extend(map(StatsEventerTestCase, names))
|
||||
tests.extend(list(map(StatsEventerTestCase, names)))
|
||||
suite = unittest.TestSuite(tests)
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
||||
|
||||
def runAll():
|
||||
""" Unittest runner """
|
||||
'''
|
||||
Unittest runner
|
||||
'''
|
||||
suite = unittest.TestSuite()
|
||||
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(StatsEventerTestCase))
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
||||
|
@ -723,6 +722,6 @@ if __name__ == '__main__' and __package__ is None:
|
|||
|
||||
#runAll() # run all unittests
|
||||
|
||||
runSome() #only run some
|
||||
runSome() # only run some
|
||||
|
||||
#runOne('testMasterLaneStats')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
|
@ -14,7 +14,7 @@ from tests.support.paths import TMP, INTEGRATION_TEST_DIR
|
|||
|
||||
# Import Salt libs
|
||||
import salt.utils.files
|
||||
|
||||
import salt.utils.stringutils
|
||||
|
||||
# all read, only owner write
|
||||
autosign_file_permissions = stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IWUSR
|
||||
|
@ -62,7 +62,7 @@ class AutosignGrainsTest(ShellCase):
|
|||
def test_autosign_grains_accept(self):
|
||||
grain_file_path = os.path.join(self.autosign_grains_dir, 'test_grain')
|
||||
with salt.utils.files.fopen(grain_file_path, 'w') as f:
|
||||
f.write('#invalid_value\ncheese')
|
||||
f.write(salt.utils.stringutils.to_str('#invalid_value\ncheese'))
|
||||
os.chmod(grain_file_path, autosign_file_permissions)
|
||||
|
||||
self.run_call('test.ping -l quiet') # get minon to try to authenticate itself again
|
||||
|
@ -71,7 +71,7 @@ class AutosignGrainsTest(ShellCase):
|
|||
def test_autosign_grains_fail(self):
|
||||
grain_file_path = os.path.join(self.autosign_grains_dir, 'test_grain')
|
||||
with salt.utils.files.fopen(grain_file_path, 'w') as f:
|
||||
f.write('#cheese\ninvalid_value')
|
||||
f.write(salt.utils.stringutils.to_str('#cheese\ninvalid_value'))
|
||||
os.chmod(grain_file_path, autosign_file_permissions)
|
||||
|
||||
self.run_call('test.ping -l quiet') # get minon to try to authenticate itself again
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
from functools import wraps
|
||||
import io
|
||||
import stat
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import multiprocessing
|
||||
|
||||
# Import Salt Testing libs
|
||||
|
|
Loading…
Add table
Reference in a new issue