def setUp(self): mpx.service.session.SessionManager.PASSWD_FILE = (os.path.join( os.path.dirname(__file__), 'passwd.test')) DefaultTestFixture.setUp(self) self.config = {} lo = [] lr = {} lr['alias'] = 'default' lr['class'] = 'mpx.lib.xmlrpc.XMLRPC_DefaultObject' lr['lifetime'] = 'Request' lo.append(lr) lr = {} lr['alias'] = 'rna_xmlrpc' lr['class'] = 'mpx.lib.xmlrpc.rna_xmlrpc.RNA_XMLRPC_Handler' lr['lifetime'] = 'Runtime' lo.append(lr) config = {} config['name'] = 'XMLRPC_Handler' config['parent'] = None config['module'] = '' config['deployed_objects'] = lo self.handler = XMLRPC_Handler() self.handler.configure(config) root = as_internal_node('/') self.new_node_tree() as_internal_node('/').start() self._session = as_internal_node('/services/session_manager').create( 'mpxadmin', 'mpxadmin') return
def setUp(self): DefaultTestFixture.setUp(self) server_socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) server_socket.bind(('localhost',0)) # Bind to any available port on # localhost. server_socket.listen(5) sockname = server_socket.getsockname() ## # Socket ready to accept "eWebConnect" Alarm messages. self.server_socket = server_socket ## # The "eWebConnect" host. self.sever_address = sockname[0] ## # The "eWebConnect" post. self.server_port = sockname[1] self.new_node_tree() root = as_internal_node('/') self.configure({'name':'Test Case', 'parent':'/'}) client = EWebConnectAlarmClient() client.configure({'name':'eWebConnect', 'parent':self, 'host':'localhost', 'port':self.server_port}) as_internal_node('/').start() return
def tearDown(self): try: if hasattr(self, 'seq'): del self.seq finally: DefaultTestFixture.tearDown(self) return
def setUp(self): DefaultTestFixture.setUp(self) self.__event_updated_values = {} self.new_node_tree() root = as_internal_node("/") self._cov_counter = 0 GetException().configure({"name": "exception", "parent": "/services"}) SUBSCRIPTION_MANAGER.configure( { "debug": 0, "_normal_pool_size": 2, "_slow_pool_size": 2, "_prime_pool_size": 2, "_minimum_poll_interval": 0.001, "_slow_poll_threshold": 0.500, } ) for i in range(0, 10): f = FastNode() f.configure({"parent": root, "name": "FastNode-%03d" % i}) s = SlowNode() s.configure({"parent": root, "name": "SlowNode-%03d" % i}) e = ErrorNode() e.configure({"parent": root, "name": "ErrorNode-%03d" % i}) b = BatchNode(i & 1) b.configure({"parent": root, "name": "BatchNode-%03d" % i}) root.start() return
def tearDown(self): self.user_manager.stop() self.user_manager = None os.unlink(self.passwd_file) self.passwd_file = None DefaultTestFixture.tearDown(self) return
def __init__(self, *args, **kw): DefaultTestFixture.__init__(self, *args, **kw) EventConsumerMixin.__init__(self, self.change_of_value) self.__event_lock = Lock() self.__event_updated_values = {} self._cov_counter = 0 return
def tearDown(self): try: self._circular.close() del(self._circular) finally: DefaultTestFixture.tearDown(self) return
def setUp(self): DefaultTestFixture.setUp(self) self.__event_updated_values = {} self.new_node_tree() root = as_internal_node('/') self._cov_counter = 0 GetException().configure({'name': 'exception', 'parent': '/services'}) SUBSCRIPTION_MANAGER.configure({ 'debug': 0, '_normal_pool_size': 2, '_slow_pool_size': 2, '_prime_pool_size': 2, '_minimum_poll_interval': 0.001, '_slow_poll_threshold': 0.500, }) for i in range(0, 10): f = FastNode() f.configure({'parent': root, 'name': "FastNode-%03d" % i}) s = SlowNode() s.configure({'parent': root, 'name': "SlowNode-%03d" % i}) e = ErrorNode() e.configure({'parent': root, 'name': "ErrorNode-%03d" % i}) b = BatchNode(i & 1) b.configure({'parent': root, 'name': "BatchNode-%03d" % i}) root.start() return
def tearDown(self): try: self._circular.close() del (self._circular) finally: DefaultTestFixture.tearDown(self) return
def setUp(self): DefaultTestFixture.setUp(self) self.lock = Lock() self.pool = ThreadPool(3) self.queue = Queue() self.simple_action_counter = 0 return
def setUp(self): DefaultTestFixture.setUp(self) self.root = as_internal_node('/') self.input = CompositeNode() self.output = CompositeNode() self.input.configure({'parent': self.root, 'name': 'input'}) self.output.configure({'parent': self.root, 'name': 'output'}) self.input_value = SimpleValue() self.output_value = SimpleValue() self.input_value.configure({'parent': self.input, 'name': 'value'}) self.output_value.configure({'parent': self.output, 'name': 'value'}) self.aliases = Aliases() self.aliases.configure({'parent': self.root, 'name': 'aliases'}) self.alias_input = Alias() self.alias_input.configure({ 'parent': self.aliases, 'name': 'input', 'node_url': '/input/value' }) self.alias_output = Alias() self.alias_output.configure({ 'parent': self.aliases, 'name': 'output', 'node_url': '/output/value' }) self.input_value.set(1) self.output_value.set(0) return
def setUp(self): global debug DefaultTestFixture.setUp(self) self.case = 100 # Set up defaults self.port = 80 self._username = '******' self._password = '******' self.hostname = 'bubba' self.nodeurl = '/interfaces/eth1/mehtatech_ied_protocol' # Override as needed #self.hostname = 'localhost' #self.port = 8080 self.port = 443 self.xmlrpcurl = 'https://%s:%s/xmlrpc' % (self.hostname, self.port) self.server = xmlrpclib.Server(self.xmlrpcurl, None, None, debug) # Authenticate with the server and get back a session ID self.session = self.server.rna_xmlrpc2.create_session(self._username, self._password)
def tearDown(self): try: self.root.prune() self.root = None finally: DefaultTestFixture.tearDown(self) return
def tearDown(self): try: if hasattr(self, 'collector'): del self.collector finally: DefaultTestFixture.tearDown(self) return
def tearDown(self): try: if hasattr(self,'collector'): del self.collector finally: DefaultTestFixture.tearDown(self) return
def setUp(self): DefaultTestFixture.setUp(self) f = StringIO() # A file-like object. f.write(file_text) f.seek(0) # Rewind the file. self.file_object = f return
def __init__(self, *args, **kw): DefaultTestFixture.__init__(self, *args,**kw) EventConsumerMixin.__init__(self, self.change_of_value) self.__event_lock = Lock() self.__event_updated_values = {} self._cov_counter = 0 return
def setUp(self): mpx.service.session.SessionManager.PASSWD_FILE = ( os.path.join(os.path.dirname(__file__), 'passwd.test') ) DefaultTestFixture.setUp(self) self.config = {} lo = [] lr = {} lr['alias'] = 'default' lr['class'] = 'mpx.lib.xmlrpc.XMLRPC_DefaultObject' lr['lifetime'] = 'Request' lo.append(lr) lr = {} lr['alias'] = 'rna_xmlrpc' lr['class'] = 'mpx.lib.xmlrpc.rna_xmlrpc.RNA_XMLRPC_Handler' lr['lifetime'] = 'Runtime' lo.append(lr) config = {} config['name'] = 'XMLRPC_Handler' config['parent'] = None config['module'] = '' config['deployed_objects'] = lo self.handler = XMLRPC_Handler() self.handler.configure(config) root = as_internal_node('/') self.new_node_tree() as_internal_node('/').start() self._session = as_internal_node( '/services/session_manager' ).create('mpxadmin', 'mpxadmin') return
def setUp(self): DefaultTestFixture.setUp(self) server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server_socket.bind(('localhost', 0)) # Bind to any available port on # localhost. server_socket.listen(5) sockname = server_socket.getsockname() ## # Socket ready to accept "eWebConnect" Alarm messages. self.server_socket = server_socket ## # The "eWebConnect" host. self.sever_address = sockname[0] ## # The "eWebConnect" post. self.server_port = sockname[1] self.new_node_tree() root = as_internal_node('/') self.configure({'name': 'Test Case', 'parent': '/'}) client = EWebConnectAlarmClient() client.configure({ 'name': 'eWebConnect', 'parent': self, 'host': 'localhost', 'port': self.server_port }) as_internal_node('/').start() return
def setUp(self): DefaultTestFixture.setUp(self) self.__event_updated_values = {} self.new_node_tree() root = as_internal_node('/') self._cov_counter = 0 GetException().configure({'name':'exception', 'parent':'/services'}) SUBSCRIPTION_MANAGER.configure({'debug':0, '_normal_pool_size':2, '_slow_pool_size':2, '_prime_pool_size':2, '_minimum_poll_interval':0.001, '_slow_poll_threshold':0.500, } ) for i in range(0,10): f = FastNode() f.configure({'parent':root, 'name':"FastNode-%03d"%i}) s = SlowNode() s.configure({'parent':root, 'name':"SlowNode-%03d"%i}) e = ErrorNode() e.configure({'parent':root, 'name':"ErrorNode-%03d"%i}) b = BatchNode(i & 1) b.configure({'parent':root, 'name':"BatchNode-%03d"%i}) root.start() return
def setUp(self): DefaultTestFixture.setUp(self) self.root = as_internal_node('/') self.child1 = CompositeNode() self.child2 = CompositeNode() self.child1_1 = CompositeNode() self.child1.configure({ 'parent': self.root, 'name': 'child1', '__node_id__': '1234' }) self.child2.configure({'parent': self.root, 'name': 'child2'}) self.child1_1.configure({ 'parent': self.child1, 'name': 'child1_1', '__factory__': 'Hand crafted in America' }) self.aliases = Aliases() self.aliases.configure({'parent': self.root, 'name': 'aliases'}) self.alias1 = Alias() self.alias1.configure({ 'parent': self.aliases, 'name': 'child1', 'node_url': '/child1' }) self.plus1 = CompositeNode() self.plus1.configure({'parent': self.root, 'name': '1+1'}) self.space1 = CompositeNode() self.space1.configure({'parent': self.root, 'name': 'space between'}) self.test_lock_owner = None self.test_lock_node = None return
def tearDown(self): try: if hasattr(self,'server'): del self.server if hasattr(self,'client'): del self.client if hasattr(self,'lhc'): del self.lhc if hasattr(self,'lhs'): self.lhs.server.server_thread.should_die() self.lhs.server.close_connection() kill_a_server(self.lhs.server.server_thread) while self.lhs.server.server_thread.isAlive(): time.sleep(0.01) # @fixme WHY IS THIS COMMENTED? #self.lhs.server.server_thread.exit() del self.lhs.server.server_thread del self.lhs.server del self.lhs if hasattr(self,'ip'): del self.ip if hasattr(self,'eth0'): del self.eth0 finally: DefaultTestFixture.tearDown(self) return
def __init__(self, other): DefaultTestFixture.__init__(self, other) self.eth0 = None self.ip = None self.server = None self.client = None return
def __init__(self, *args, **kw): DefaultTestFixture.__init__(self, *args, **kw) self.assertions_enabled = 0 try: assert False except AssertionError: self.assertions_enabled = 1 return
def tearDown(self): try: self.rna_target._abort = True self.root.prune() self.root = None finally: DefaultTestFixture.tearDown(self) return
def setUp(self): DefaultTestFixture.setUp(self) self.log = log.TrimmingLog('trimming_test') # __init__(self, name = None, position = None, sort_order = None): self.c2 = log.ColumnConfiguration('c2', 1, 'none') self.c3 = log.ColumnConfiguration('c3', 2, 'none') self.c4 = log.ColumnConfiguration('c4', 3, 'none') self.timestamp = log.ColumnConfiguration('timestamp', 0, 'ascending') return
def tearDown(self): try: if hasattr(self, "port"): if self.port.is_open(): self.port.close() del self.port finally: DefaultTestFixture.tearDown(self) return
def setUp(self): DefaultTestFixture.setUp(self) self.user_manager = mpx.lib.factory( 'mpx.service.user_manager.UserManager' ) self.user_manager.configure({'name':'User Manager','parent':None}) self.passwd_file = self.new_passwd_file() f = open(self.passwd_file,'r') return
def setUp(self): DefaultTestFixture.setUp(self) self.eth0 = eth.factory() self.eth0.configure({"name": "eth0", "parent": None, "dev": "eth0"}) self.ip = ip.factory() self.ip.configure({"name": "ip", "parent": self.eth0}) self.server = server.ServerDevice() self.server.configure({"name": "server", "parent": self.ip, "address": 255}) return
def setUp(self): DefaultTestFixture.setUp(self) self.data = [] for x in range(1, 20): entry = {} entry['timestamp'] = time.time() entry['column-A'] = x self.data.append(entry) return
def setUp(self): DefaultTestFixture.setUp(self) self.data = [] for x in range(1,20): entry = {} entry['timestamp'] = time.time() entry['column-A'] = x self.data.append(entry) return
def setUp(self): DefaultTestFixture.setUp(self) self.port = factory() self.port.configure({ 'name': 'port1', 'parent': None, 'dev': '/dev/ttyS0' }) return
def tearDown(self): try: if hasattr(self, 'port'): if self.port.is_open(): self.port.close() del self.port finally: DefaultTestFixture.tearDown(self) return
def tearDown(self): pfx = '%s.%s: ' % (self.name, f_name()) try: # Delete TGZ file, add_list, # Rmv user "mpxadmin" # pass finally: DefaultTestFixture.tearDown(self) return
def setUp(self): DefaultTestFixture.setUp(self) global _failed global _callback_stream global _reason global _callback_count _callback_count = 0 _failed = None _callback_stream = None _reason = ''
def setUp(self): DefaultTestFixture.setUp(self) self.data = _DataHolder() self.data.configure(['timestamp', 'column-A']) for x in range(1, 20): self.data.add_entry([time.time(), x]) exporters = _ParentHolder(self.data) exporter = _ParentHolder(exporters) exporter.log = self.data self.formatter = CSVFormatter() self.formatter.configure({'name': 'csvformatter', 'parent': exporter})
def setUp(self): DefaultTestFixture.setUp(self) self.data = [] ts = float(15*int(time.time()/15)) for x in range(1,20): entry = {} entry['timestamp'] = ts entry['column-A'] = x self.data.append(entry) ts += 15 return
def setUp(self): DefaultTestFixture.setUp(self) self.data = _DataHolder() self.data.configure(['timestamp','column-A']) for x in range(1,20): self.data.add_entry([time.time(),x]) exporters = _ParentHolder(self.data) exporter = _ParentHolder(exporters) exporter.log = self.data self.formatter = CSVFormatter() self.formatter.configure({'name':'csvformatter','parent':exporter})
def setUp(self): DefaultTestFixture.setUp(self) self.data = [] ts = float(15 * int(time.time() / 15)) for x in range(1, 20): entry = {} entry['timestamp'] = ts entry['column-A'] = x self.data.append(entry) ts += 15 return
def setUp(self): DefaultTestFixture.setUp(self) self.eth0 = eth.factory() self.eth0.configure({'name': 'eth0', 'parent': None, 'dev': 'eth0'}) self.ip = ip.factory() self.ip.configure({'name': 'ip', 'parent': self.eth0}) self.server = server.ServerDevice() self.server.configure({ 'name': 'server', 'parent': self.ip, 'address': 255 }) return
def tearDown(self): try: if hasattr(self, "server"): del self.server if hasattr(self, "client"): del self.client if hasattr(self, "ip"): del self.ip if hasattr(self, "eth0"): del self.eth0 finally: DefaultTestFixture.tearDown(self) return
def tearDown(self): try: if hasattr(self, 'server'): del self.server if hasattr(self, 'client'): del self.client if hasattr(self, 'ip'): del self.ip if hasattr(self, 'eth0'): del self.eth0 finally: DefaultTestFixture.tearDown(self) return
def setUp(self): pfx = '%s.%s: ' % (self.name, f_name()) DefaultTestFixture.setUp(self) # Delete any existing SRNA secure materials trees from # "target NBM": print 'prop.SRNATMP_DATA: %s' % prop.SRNATMP_DATA if exists(prop.SRNATMP_DATA): shutil.rmtree(prop.SRNATMP_DATA, True) # ignore errors if exists(prop.SRNA_UPDATE_TGZ): os.remove(prop.SRNA_UPDATE_TGZ, True) # ignore errors # Delete any existing SRNA secure materials trees from # "admin NBM-Mgr": if exists(SRNA_UPDATE_TGZ_SRC_PATH): os.remove(SRNA_UPDATE_TGZ_SRC_PATH) if exists(IP_ADDRS_PATH): os.remove(IP_ADDRS_PATH) # Verify that the update_srna_network.pyc tool file is in proper place: if not exists(UPDATE_SRNA_NETWORK_PATH): self.fail('%sExpected file "%s" to exist; deeply disappointed.' \ % (pfx,UPDATE_SRNA_NETWORK_PATH)) return # Verify that the srna_openssl.cnf file is in proper place: if not exists(SRNA_OPENSSL_CNF_PATH): self.fail('%sExpected file "%s" to exist; deeply disappointed.' \ % (pfx, SRNA_OPENSSL_CNF_PATH)) return # Verify that the update_srna_local.pyc tool file is in proper place: if not exists(UPDATE_SRNA_LOCAL_PATH): self.fail('%sExpected file "%s" to exist; deeply disappointed.' \ % (pfx, UPDATE_SRNA_LOCAL_PATH)) return # Verify that ADMINUSER user and home directory for simulated target NBM # ALREADY exist (presumably running on an NBM-Mgr...): test_ADMINUSER_exist = Popen(('id', ADMINUSER), stdout=PIPE, stderr=PIPE) result = test_ADMINUSER_exist.communicate() if test_ADMINUSER_exist.returncode != 0: self.fail('%sExpected user "%s" to exist; deeply disappointed: %s' \ % (pfx, ADMINUSER, result[1])) return if not os.path.exists(ADMIN_HOME): self.fail('%sExpected dir "%s" to exist; deeply disappointed.' \ % (pfx, ADMIN_HOME)) return # Create a test IP address list file: addr_list_file = open(ADDR_LIST_PATH, 'w') addr_list_file.write('127.0.0.1\n127.0.0.1\n') addr_list_file.close() print 'prop.SRNA_UPDATE_TGZ: %s' % prop.SRNA_UPDATE_TGZ return
def setUp(self): pfx = '%s.%s: ' % (self.name, f_name()) DefaultTestFixture.setUp(self) # Delete any existing SRNA secure materials trees from # "target NBM": print 'prop.SRNATMP_DATA: %s' % prop.SRNATMP_DATA if exists(prop.SRNATMP_DATA): shutil.rmtree(prop.SRNATMP_DATA, True) # ignore errors if exists(prop.SRNA_UPDATE_TGZ): os.remove(prop.SRNA_UPDATE_TGZ, True) # ignore errors # Delete any existing SRNA secure materials trees from # "admin NBM-Mgr": if exists(SRNA_UPDATE_TGZ_SRC_PATH): os.remove(SRNA_UPDATE_TGZ_SRC_PATH) if exists(IP_ADDRS_PATH): os.remove(IP_ADDRS_PATH) # Verify that the update_srna_network.pyc tool file is in proper place: if not exists(UPDATE_SRNA_NETWORK_PATH): self.fail('%sExpected file "%s" to exist; deeply disappointed.' \ % (pfx,UPDATE_SRNA_NETWORK_PATH)) return # Verify that the srna_openssl.cnf file is in proper place: if not exists(SRNA_OPENSSL_CNF_PATH): self.fail('%sExpected file "%s" to exist; deeply disappointed.' \ % (pfx, SRNA_OPENSSL_CNF_PATH)) return # Verify that the update_srna_local.pyc tool file is in proper place: if not exists(UPDATE_SRNA_LOCAL_PATH): self.fail('%sExpected file "%s" to exist; deeply disappointed.' \ % (pfx, UPDATE_SRNA_LOCAL_PATH)) return # Verify that ADMINUSER user and home directory for simulated target NBM # ALREADY exist (presumably running on an NBM-Mgr...): test_ADMINUSER_exist = Popen(('id', ADMINUSER), stdout=PIPE,stderr=PIPE) result = test_ADMINUSER_exist.communicate() if test_ADMINUSER_exist.returncode != 0: self.fail('%sExpected user "%s" to exist; deeply disappointed: %s' \ % (pfx, ADMINUSER, result[1])) return if not os.path.exists(ADMIN_HOME): self.fail('%sExpected dir "%s" to exist; deeply disappointed.' \ % (pfx, ADMIN_HOME)) return # Create a test IP address list file: addr_list_file = open(ADDR_LIST_PATH, 'w') addr_list_file.write('127.0.0.1\n127.0.0.1\n') addr_list_file.close() print 'prop.SRNA_UPDATE_TGZ: %s' % prop.SRNA_UPDATE_TGZ return
def __init__(self, x): DefaultTestFixture.__init__(self, x) self.name = self.__class__.__name__ self.start_dir = os.getcwd() # Create dir for preserving data and results between tests: if exists(PRESERVE_DIR): shutil.rmtree(PRESERVE_DIR, True) os.makedirs(PRESERVE_DIR, 0777) print 'prop.SRNA_TOOLS: %s' % prop.SRNA_TOOLS print 'UPDATE_SRNA_NETWORK_PATH: %s' % UPDATE_SRNA_NETWORK_PATH print 'UPDATE_SRNA_LOCAL_PATH: %s' % UPDATE_SRNA_LOCAL_PATH print 'SRNA_OPENSSL_CNF_PATH: %s' % SRNA_OPENSSL_CNF_PATH print 'SRNA_UPDATE_TGZ_SRC_PATH: %s' % SRNA_UPDATE_TGZ_SRC_PATH print 'IP_ADDRS_PATH: %s' % IP_ADDRS_PATH print 'ADDR_LIST_PATH: %s' % ADDR_LIST_PATH return
def __init__(self,*args,**kw): args = (self,) + args DefaultTestFixture.__init__(*args, **kw) self.test = ( ('${mpx.properties.HTTP_ROOT}',1,'beginnig of line test'), (' ${mpx.properties.HTTP_ROOT}',1,'space before '), (' sadfsaasdf sdfsad \${mpx.properties.HTTP_ROOT}',0,'words then a slash'), (' \${mpx.properties.HTTP_ROOT}',0,'space then a slash'), ('some test ${mpx.properties.HTTP_ROOT} ',1,''), (' ${mpx.properties.HTTP_ROOT} ',1,''), ('\${mpx.properties.HTTP_ROOT} ${mpx.properties.HTTP_ROOT} ',1,''), ('${mpx.properties.HTTP_ROOT} \${mpx.properties.HTTP_ROOT} ',1,''), ('${mpx.properties.HTTP_ROOT } ',0,''), ('${mpx.properties.http_root} ',0,''), ('${mpx.properties.http_root } ',0,''), ('',0,''), ('${mpx.properties.HTTP_ROOT} ${mpx.properties.HTTP_ROOT} ',1,'') )