def __process_results(self, client_output, service_output): result = {} result["connection_completed"] = False client_parser_error, client_leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors( client_output) result["no_client_parser_error"] = not client_parser_error result["no_client_leak_detected"] = not client_leak_detected service_parser_error, service_leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors( service_output) result["no_service_parser_error"] = not service_parser_error result["no_service_leak_detected"] = not service_leak_detected for line in client_output.split("\n"): if "AppConnectionComplete" in line: result["connection_completed"] = True break final_result = reduce((lambda x, y: x and y), result.values()) print "weave-service-dir test from client %s to service %s: " % ( self.client, self.service) if self.quiet == False: if final_result: print hgreen("succeeded") else: print hred("failed") if not final_result: pprint.pprint(result) return result
def __process_results(self, client_output, server_output, client_info): kevents = re.findall(r"WEAVE:.+kEvent_\w+", client_output) smoke_check = False client_parser_error = None client_leak_detected = None server_parser_error = None server_leak_detected = None result = {} client_parser_error, client_leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors( client_output) result["no_client_parser_error"] = not client_parser_error result["no_client_leak_detected"] = not client_leak_detected if server_output is not "": server_parser_error, server_leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors( server_output) result["no_server_parser_error"] = not client_parser_error result["no_server_leak_detected"] = not server_leak_detected if self.wdm_option == "view": if any("kEvent_ViewResponseReceived" in s for s in kevents) and \ kevents[-1] == "kEvent_ViewResponseConsumed": smoke_check = True else: smoke_check = False elif self.wdm_option == "one_way_subscribe": if any("Client->kEvent_OnSubscriptionEstablished" in s for s in kevents) \ and "Closing endpoints" in client_output: smoke_check = True else: smoke_check = False elif self.wdm_option == "mutual_subscribe": if any("Publisher->kEvent_OnSubscriptionEstablished" in s for s in kevents) \ and "Closing endpoints" in client_output: smoke_check = True else: smoke_check = False result["smoke_check"] = smoke_check if self.quiet is False: print "weave-wdm-next %s from node %s (%s) to node %s (%s) : "\ % (self.wdm_option, client_info["client_node_id"], client_info["client_ip"], self.server_node_id, self.server_ip) if smoke_check is True: for kevent in kevents: print hgreen(kevent) print hgreen("weave-wdm-next %s success" % self.wdm_option) else: for kevent in kevents: print hred(kevent) print hred("weave-wdm-next %s failure" % self.wdm_option) if client_parser_error is True: print hred("client parser error") if client_leak_detected is True: print hred("client_resource leak detected") if server_parser_error is True: print hred("server parser error") if server_leak_detected is True: print hred("server resource leak detected") return result
def run(self): self.logger.debug("[localhost] WeaveSecurityPing: Run.") self.__pre_check() if self.use_plaid: self.__start_plaid_server() self.__start_server_side() emsg = "WeaveSecurityPing %s should be running." % ( self.server_process_tag) self.logger.debug("[%s] WeaveSecurityPing: %s" % (self.server_node_id, emsg)) self.__start_client_side(False) self.__wait_for_client() client_output_value, client_output_data = \ self.get_test_output(self.client_node_id, self.client_process_tag, True) if self.strace: client_strace_value, client_strace_data = \ self.get_test_strace(self.client_node_id, self.client_process_tag, True) if self.no_service: server_output_data = "" server_strace_data = "" else: self.__stop_server_side() if self.use_plaid: self.__stop_plaid_server() server_output_value, server_output_data = \ self.get_test_output(self.server_node_id, self.server_process_tag, True) if self.strace: server_strace_value, server_strace_data = \ self.get_test_strace(self.server_node_id, self.server_process_tag, True) avg, results = self.__process_results(client_output_data) client_parser_error, client_leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors( client_output_data) server_parser_error, server_leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors( server_output_data) data = {} data["client_output"] = client_output_data data["server_output"] = server_output_data if self.strace: data["client_strace"] = client_strace_data data["server_strace"] = server_strace_data data[ "other_failure"] = client_parser_error or client_leak_detected or server_parser_error or server_leak_detected self.logger.debug("[localhost] WeaveSecurityPing: Done.") return ReturnMsg(avg, data)
def __process_results(self, client_output, server_output): parser_error = False leak_detected = False transfer_done = False parser_error, leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors( client_output) for line in client_output.split("\n"): if "WEAVE:BDX: Transfer complete!" in line: transfer_done = True break if self.quiet == False: if self.download: print "weave-bdx from server v%s %s (%s) to client v%s %s (%s) : " % \ (self.server_version, self.server_node_id, self.server_ip, self.client_version, self.client_node_id, self.client_ip) if transfer_done: print hgreen("downloaded") else: print hred("not downloaded") else: print "weave-bdx from client %s (%s) to server %s (%s) : " % \ (self.client_node_id, self.client_ip, self.server_node_id, self.server_ip) if transfer_done: print hgreen("uploaded") else: print hred("not uploaded") if leak_detected: print hred("resource leak detected in the client's ouput") if parser_error: print hred("parser error in the client's output") pass_test = transfer_done and not leak_detected and not parser_error if self.server is not "service": # check the server for leaks and parser errors parser_error, leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors( server_output) if self.quiet == False: if leak_detected: print hred("resource leak detected in the server's ouput") if parser_error: print hred("parser error in the server's output") pass_test = pass_test and not parser_error and not leak_detected return (pass_test, client_output)
def validate_happy_sequence(self): output_logs = self.output_logs counters = {} counters['client'] = WeaveUtilities.parse_fault_injection_counters( output_logs['client']) counters['server'] = WeaveUtilities.parse_fault_injection_counters( output_logs['server']) # As of today, all fault points should be executed on the server required_server_faults = [ key for key in counters["server"].keys() if "Weave_WDM" in key ] # This will raise a ValueError WeaveUtilities.validate_counters(required_server_faults, counters["server"], "server") # As of today, the client does not send commands required_client_faults = [ key for key in counters["client"].keys() if "Weave_WDM" in key and not "SendCommand" in key ] # This will raise a ValueError WeaveUtilities.validate_counters(required_client_faults, counters["client"], "client")
def __process_tunnel_results(self, gw, gw_value, gw_data, ping_value, ping_data, test_tag): gw_output = gw_data.get("gateway_output") service_output = gw_data.get("service_output") tunnel_up = self.__is_tunnel_up(gw_output) gw_parser_error, gw_leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors(gw_output) service_parser_error, service_leak_detected = WeaveUtilities.scan_for_leaks_and_parser_errors(service_output) # at the end of the test, 'tunnel_up' should be True if not tunnel_up: print hred(" Tunnel start: Failed [" + test_tag + "]") if ping_value != 0: # loss_percentage == 0 print hred(" Ping test: Failed [" + test_tag + "]") if gw_parser_error is True: print hred(" gateway parser error [" + test_tag + "]") if gw_leak_detected is True: print hred(" gateway leak detected [" + test_tag + "]+") if service_parser_error is True: print hred("service parser error") if service_leak_detected is True: print hred("service resource leak detected") result = {} result["tunnel_up"] = tunnel_up result["ping_successful"] = ping_value == 0 #loss_percentage == 0 result["no_gw_parser_error"] = not gw_parser_error result["no_gw_leak_detected"] = not gw_leak_detected result["no_service_parser_error"] = not service_parser_error result["no_service_leak_detected"] = not service_leak_detected return result
('Client\[0\] moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations']), ('Handler\[0\] Moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations']) ] wdm_next_args['server_log_check'] = [ ('Client\[0\] \[(ALIVE|CONFM)\] bound mutual subscription is going away', wdm_next_args['test_client_iterations']), ('Handler\[0\] \[(ALIVE|CONFM)]\ EndSubscription Ref\(\d+\)', wdm_next_args['test_client_iterations']), ('Client->kEvent_OnNotificationProcessed', wdm_next_args['test_client_iterations'] * (wdm_next_args['total_client_count'] + 1)), ('Client\[0\] moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations']), ('Handler\[0\] Moving to \[ FREE\] Ref\(0\)', wdm_next_args['test_client_iterations']) ] wdm_next_args['test_tag'] = self.__class__.__name__[19:].upper() wdm_next_args['test_case_name'] = [ 'F30: Mutual Subscribe: Root path. Null Version. Mutate data in initiator and responder. Publisher in responder cancels' ] print 'test file: ' + self.__class__.__name__ print "weave-wdm-next test F30" super(test_weave_wdm_next_mutual_subscribe_38, self).weave_wdm_next_test_base(wdm_next_args) if __name__ == "__main__": WeaveUtilities.run_unittest()
# @file # Injects a series of faults into the SubscriptionClient and # SubscriptionHandler, confirming the retry mechanism for a # mutual subscription is still successfully established # after some number of resubscribes. # import getopt import sys import unittest import set_test_path import plugin.WeaveUtilities as WeaveUtilities from weave_wdm_next_test_base import weave_wdm_next_test_base gFaultopts = WeaveUtilities.FaultInjectionOptions() class test_weave_wdm_next_mutual_resub(weave_wdm_next_test_base): def test_weave_wdm_next_mutual_resub(self): wdm_next_args = {} wdm_next_args['wdm_option'] = "mutual_subscribe" wdm_next_args['total_client_count'] = 2 wdm_next_args['final_client_status'] = 0 wdm_next_args['timer_client_period'] = 5000 wdm_next_args['enable_client_stop'] = True wdm_next_args['test_client_iterations'] = 1 wdm_next_args['test_client_delay'] = 2000 wdm_next_args['enable_client_flip'] = 1
import os import unittest import set_test_path import getopt import sys from happy.Utils import * import happy.HappyNodeList import plugins.weave.WeaveStateLoad as WeaveStateLoad import plugins.weave.WeaveStateUnload as WeaveStateUnload import plugin.WeaveServiceDir as WeaveServiceDir import plugin.WeaveUtilities as WeaveUtilities import plugin.WeaveUtilities as WeaveUtilities gFaultopts = WeaveUtilities.FaultInjectionOptions(nodes=["client", "service"]) gOptions = {"fault-injection": False} class test_service_directory_01(unittest.TestCase): def setUp(self): self.tap = None if "WEAVE_SYSTEM_CONFIG_USE_LWIP" in os.environ.keys( ) and os.environ["WEAVE_SYSTEM_CONFIG_USE_LWIP"] == "1": self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \ "/../topologies/thread_wifi_on_tap_ap_service.json" self.tap = "wpan0" else: self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \ "/../topologies/thread_wifi_ap_service.json"