Coverage for src/bin/stats/tests/test_utils : 82%
        
        
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
| 
 """ Utilities and mock modules for unittests of statistics modules 
 """ 
 
 """A signal handler class for deadlock in unittest""" """sets a schedule in SIGARM for invoking the handler via unittest.TestCase after timeout seconds (default is 20)""" 
 """resets the schedule in SIGALRM""" 
 """envokes unittest.TestCase.fail as a signal handler""" self.fail_handler("A deadlock might be detected") 
 cc_session = session else: orig_timeout = cc_session.get_timeout() cc_session.set_timeout(timeout * 1000) except isc.cc.SessionTimeout: pass finally: cc_session.set_timeout(orig_timeout) 
 
 name=self.server_name, target=self.server.run) 
 
 """Shut down the server by calling its own shutdown() method. Then wait for its thread to finish. If blocking is True, the thread.join() blocks until the thread finishes. If not, it uses a zero timeout. The latter is necessary in a number of existing tests. We should redo this part (we should not even need threads in most, if not all, of these threads, see ticket #1668)""" else: 
 
 """Dummy for sys""" 
 # suppress output to stdout and stderr sys.exit("Error on Msgq startup: %s" % result) 
 self.msgq.run() except Exception: pass finally: # explicitly shut down the socket of the msgq before # shutting down the msgq self.msgq.listen_socket.shutdown(msgq.socket.SHUT_RDWR) self.msgq.shutdown() 
 # do nothing 
 os.environ['CONFIG_TESTDATA_PATH'], "b10-config.db") 
 except Exception: pass 
 
 { "module_spec": { "module_name": "Boss", "module_description": "Mock Master process", "config_data": [], "commands": [ { "command_name": "sendstats", "command_description": "Send data to a statistics module at once", "command_args": [] }, { "command_name": "show_processes", "command_description": "List the running BIND 10 processes", "command_args": [] } ], "statistics": [ { "item_name": "boot_time", "item_type": "string", "item_optional": false, "item_default": "1970-01-01T00:00:00Z", "item_title": "Boot time", "item_description": "A date time when bind10 process starts initially", "item_format": "date-time" } ] } } """ 
 # create ModuleCCSession object self.spec_file, self.config_handler, self.command_handler) [ 9998, "b10-auth-2" ], [ 9997, "b10-auth-3" ], [ 9996, "b10-auth-4" ]] 
 except Exception: pass 
 
 
 "data": { 'boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', self._BASETIME) } } send_command("set", "Stats", params=params, session=self.cc_session) return isc.config.create_answer(0) # Return dummy pids 0, self.pid_list) return isc.config.create_answer(1, "Unknown Command") 
 { "module_spec": { "module_name": "Auth", "module_description": "Mock Authoritative service", "config_data": [], "commands": [ { "command_name": "sendstats", "command_description": "Send data to a statistics module at once", "command_args": [] } ], "statistics": [ { "item_name": "queries.tcp", "item_type": "integer", "item_optional": false, "item_default": 0, "item_title": "Queries TCP", "item_description": "A number of total query counts which all auth servers receive over TCP since they started initially" }, { "item_name": "queries.udp", "item_type": "integer", "item_optional": false, "item_default": 0, "item_title": "Queries UDP", "item_description": "A number of total query counts which all auth servers receive over UDP since they started initially" }, { "item_name": "queries.perzone", "item_type": "list", "item_optional": false, "item_default": [ { "zonename" : "test1.example", "queries.udp" : 1, "queries.tcp" : 2 }, { "zonename" : "test2.example", "queries.udp" : 3, "queries.tcp" : 4 } ], "item_title": "Queries per zone", "item_description": "Queries per zone", "list_item_spec": { "item_name": "zones", "item_type": "map", "item_optional": false, "item_default": {}, "map_item_spec": [ { "item_name": "zonename", "item_type": "string", "item_optional": false, "item_default": "", "item_title": "Zonename", "item_description": "Zonename" }, { "item_name": "queries.udp", "item_type": "integer", "item_optional": false, "item_default": 0, "item_title": "Queries UDP per zone", "item_description": "A number of UDP query counts per zone" }, { "item_name": "queries.tcp", "item_type": "integer", "item_optional": false, "item_default": 0, "item_title": "Queries TCP per zone", "item_description": "A number of TCP query counts per zone" } ] } } ] } } """ # create ModuleCCSession object self.spec_file, self.config_handler, self.command_handler) 'zonename': 'test1.example', 'queries.tcp': 5, 'queries.udp': 4 }] 
 self.mccs.check_command(False) except Exception: pass 
 
 
 self.got_command_name = command if command == 'sendstats': params = { "owner": "Auth", "data": { 'queries.tcp': self.queries_tcp, 'queries.udp': self.queries_udp, 'queries.perzone' : self.queries_per_zone } } return send_command("set", "Stats", params=params, session=self.cc_session) return isc.config.create_answer(1, "Unknown Command") 
 
 except Exception: pass 
 
 finally: else: stats_httpd.StatsHttpd.__init__(self) 
 [ dict(address=a[0], port=a[1]) for a in server_address ] finally: 
 except Exception: pass 
 
 # MockMsgq # Check whether msgq is ready. A SessionTimeout is raised here if not. # MockCfgmgr # MockBoss # MockAuth 
 # MockAuth # MockBoss # MockCfgmgr # MockMsgq # remove the unused socket file except OSError: pass  |