Пример #1
0
    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/standalone/thread_wifi_on_tap_ap_service.json"
            self.tap = "wpan0"
        else:
            self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \
                "/../../../topologies/standalone/thread_wifi_ap_service.json"

        self.show_strace = False

        # setting Mesh for thread test
        options = WeaveStateLoad.option()
        options["json_file"] = self.topology_file

        setup_network = WeaveStateLoad.WeaveStateLoad(options)
        ret = setup_network.run()

        # set up Plaid for faster execution
        # The tunnel tests need the amount time run at plaid speed to be
        # limited to avoid the gateway to race ahead and process more events
        # while the test script is sending it a SIGUSR1 to trigger a cleanup.
        # Without a limit on the amount of time spent at plaid-speed, the
        # gateway has time to process extra keepalive messages that will make the
        # test not consistent with an execution at realtime speed.
        # The number below is determined by looking at the logs of a real-time run.
        plaid_opts = Plaid.default_options()
        plaid_opts["max_time_at_high_speed_secs"] = 10
        plaid_opts['num_clients'] = 3
        plaid_opts['strace'] = self.show_strace
        self.plaid = Plaid.Plaid(plaid_opts)
        self.use_plaid = self.plaid.isPlaidConfigured()
Пример #2
0
    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/standalone/three_nodes_on_tap_thread_weave.json"
            self.tap = "wpan0"
        else:
            self.topology_file = os.path.dirname(os.path.realpath(__file__)) + \
                "/../../../topologies/standalone/three_nodes_on_thread_weave.json"

        self.show_strace = False

        # setting Mesh for thread test
        options = WeaveStateLoad.option()
        options["quiet"] = True
        options["json_file"] = self.topology_file

        setup_network = WeaveStateLoad.WeaveStateLoad(options)
        ret = setup_network.run()

        # set up Plaid for faster execution
        plaid_opts = Plaid.default_options()
        plaid_opts['num_clients'] = 3
        if gOptions["mode"] == "service":
            plaid_opts['num_clients'] = 2
            plaid_opts["max_time_at_high_speed_secs"] = 40
        if gOptions["mode"] == "local":
            plaid_opts["max_time_at_high_speed_secs"] = 80
        if gOptions["mode"] == "auto":
            plaid_opts["max_time_at_high_speed_secs"] = 40
        plaid_opts['strace'] = self.show_strace
        self.plaid = Plaid.Plaid(plaid_opts)
        self.use_plaid = self.plaid.isPlaidConfigured()
Пример #3
0
    def __init__(self, opts={}):
        HappyNode.__init__(self)
        HappyNetwork.__init__(self)
        WeaveTest.__init__(self)

        defaultValues = dict(options)
        defaultValues.update(opts)

        self.__dict__.update(defaultValues)

        self.server_process_tag = "WEAVE-WRMP-SERVER" + (
            opts['test_tag'] if 'test_tag' in opts else '')
        self.client_process_tag = "WEAVE-WRMP-CLIENT" + (
            opts['test_tag'] if 'test_tag' in opts else '')
        self.plaid_server_process_tag = "PLAID_SERVER" + (
            opts['test_tag'] if 'test_tag' in opts else '')

        self.client_node_id = None
        self.server_node_id = None
        plaid_opts = Plaid.default_options()
        plaid_opts['quiet'] = self.quiet
        self.plaid_server_node_id = 'node03'
        plaid_opts['server_node_id'] = self.plaid_server_node_id
        plaid_opts['num_clients'] = 2
        plaid_opts['server_ip_address'] = self.getNodeWeaveIPAddress(
            self.plaid_server_node_id)
        plaid_opts['strace'] = self.strace
        self.plaid = Plaid.Plaid(plaid_opts)

        self.use_plaid = opts["plaid"]
        if opts["plaid"] == "auto":
            self.use_plaid = self.plaid.isPlaidConfigured()
Пример #4
0
    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"

        self.show_strace = False

        # setting Mesh for thread test
        options = WeaveStateLoad.option()
        options["json_file"] = self.topology_file

        setup_network = WeaveStateLoad.WeaveStateLoad(options)
        ret = setup_network.run()

        # Wait for a second to ensure that Weave ULA addresses passed dad
        # and are no longer tentative
        time.sleep(2)

        # set up Plaid for faster execution
        plaid_opts = Plaid.default_options()
        plaid_opts['num_clients'] = 3
        plaid_opts['strace'] = self.show_strace
        self.plaid = Plaid.Plaid(plaid_opts)
        self.use_plaid = self.plaid.isPlaidConfigured()
Пример #5
0
    def __init__(self, opts=options):
        HappyNode.__init__(self)
        HappyNetwork.__init__(self)
        WeaveTest.__init__(self)

        remove_keys = [
            "test_server_case", "total_server_count", "final_server_status",
            "timer_server_period", "enable_server_stop",
            "test_server_iterations", "test_server_delay",
            "enable_server_flip", "save_server_perf", "server_event_generator",
            "server_inter_event_period", "wdm_server_liveness_check_period"
        ]

        if opts['server'] == 'service':
            for i in remove_keys:
                if i in opts:
                    del opts[i]

        self.__dict__.update(opts)

        self.no_service = False

        self.server_process_tag = "WEAVE_WDM_SERVER" + (
            opts["test_tag"] if "test_tag" in opts else "")
        self.client_process_tag = "WEAVE_WDM_CLIENT" + (
            opts["test_tag"] if "test_tag" in opts else "")
        self.plaid_server_process_tag = "PLAID_SERVER" + (
            opts["test_tag"] if "test_tag" in opts else "")

        self.client_node_id = None
        self.server_node_id = None

        self.clients_info = []

        self.wdm_client_option = None
        self.wdm_server_option = None

        plaid_opts = Plaid.default_options()
        plaid_opts["quiet"] = self.quiet
        self.plaid_server_node_id = "node03"
        plaid_opts["server_node_id"] = self.plaid_server_node_id
        plaid_opts["num_clients"] = 2
        plaid_opts["server_ip_address"] = self.getNodeWeaveIPAddress(
            self.plaid_server_node_id)
        plaid_opts["strace"] = self.strace
        self.plaid = Plaid.Plaid(plaid_opts)

        self.use_plaid = opts["plaid"]
        if opts["plaid"] == "auto":
            if self.server == "service":
                # can't use plaid when talking to an external service
                self.use_plaid = False
            else:
                self.use_plaid = self.plaid.isPlaidConfigured()
Пример #6
0
    def __init__(self, opts=options):
        HappyNode.__init__(self)
        HappyNetwork.__init__(self)
        WeaveTest.__init__(self)

        self.quiet = opts["quiet"]
        self.tcp = opts["tcp"]
        self.udp = opts["udp"]
        self.wrmp = opts["wrmp"]
        self.case = opts["CASE"]
        self.pase = opts["PASE"]
        self.group_key = opts["group_key"]
        self.group_key_id = opts["group_key_id"]
        self.count = opts["count"]
        self.client = opts["client"]
        self.server = opts["server"]
        self.tap = opts["tap"]
        self.client_faults = opts["client_faults"]
        self.server_faults = opts["server_faults"]
        self.iterations = opts["iterations"]
        self.strace = opts["strace"]
        self.use_persistent_storage = opts["use_persistent_storage"]

        self.no_service = False

        self.server_process_tag = "WEAVE-SECURITY-PING-SERVER" + opts[
            "test_tag"]
        self.client_process_tag = "WEAVE-SECURITY-PING-CLIENT" + opts[
            "test_tag"]
        self.plaid_server_process_tag = "PLAID_SERVER" + opts["test_tag"]

        self.client_node_id = None
        self.server_node_id = None

        plaid_opts = Plaid.default_options()
        plaid_opts['quiet'] = self.quiet
        self.plaid_server_node_id = 'node03'
        plaid_opts['server_node_id'] = self.plaid_server_node_id
        plaid_opts['num_clients'] = 2
        plaid_opts['server_ip_address'] = self.getNodeWeaveIPAddress(
            self.plaid_server_node_id)
        plaid_opts['interface'] = 'wlan0'
        self.plaid = Plaid.Plaid(plaid_opts)

        self.use_plaid = opts["plaid"]
        if opts["plaid"] == "auto":
            if self.server == "service":
                # can't use plaid when talking to an external service
                self.use_plaid = False
            else:
                self.use_plaid = self.plaid.isPlaidConfigured()
Пример #7
0
    def __init__(self, opts=options):
        HappyNode.__init__(self)
        HappyNetwork.__init__(self)
        WeaveTest.__init__(self)

        default_values = {
            "count": None,
            'udp': True,
            'wrmp': False,
            'tcp': False,
            "sign_msgs": True,
            "key_id": "0x00010400",
            'tap': None,
            'client_faults': None,
            'server_faults': None,
            'iterations': None,
            'test_tag': ""
        }

        default_values.update(opts)

        self.__dict__.update(default_values)

        self.no_service = False

        self.server_process_tag = "WEAVE_KEY_EXPORT_SERVER" + opts["test_tag"]
        self.client_process_tag = "WEAVE_KEY_EXPORT_CLIENT" + opts["test_tag"]
        self.plaid_server_process_tag = "PLAID_SERVER" + opts["test_tag"]

        self.client_node_id = None
        self.server_node_id = None

        plaid_opts = Plaid.default_options()
        plaid_opts['quiet'] = self.quiet
        self.plaid_server_node_id = 'node03'
        plaid_opts['server_node_id'] = self.plaid_server_node_id
        plaid_opts['num_clients'] = 2
        plaid_opts['server_ip_address'] = self.getNodeWeaveIPAddress(
            self.plaid_server_node_id)
        plaid_opts['interface'] = 'wlan0'
        self.plaid = Plaid.Plaid(plaid_opts)

        self.use_plaid = opts["plaid"]
        if opts["plaid"] == "auto":
            if self.server == "service":
                # can't use plaid when talking to an external service
                self.use_plaid = False
            else:
                self.use_plaid = self.plaid.isPlaidConfigured()
Пример #8
0
    def __init__(self, opts=options):
        HappyNode.__init__(self)
        HappyNetwork.__init__(self)
        WeaveTest.__init__(self)

        self.quiet = opts["quiet"]
        self.client = opts["client"]
        self.server = opts["server"]
        self.tmp = opts["tmp"]
        self.download = opts["download"]
        self.upload = opts["upload"]
        self.receive = opts["receive"]
        self.offset = opts["offset"]
        self.length = opts["length"]
        self.tap = opts["tap"]
        self.server_version = opts["server_version"]
        self.client_version = opts["client_version"]
        self.server_faults = opts["server_faults"]
        self.client_faults = opts["client_faults"]
        self.iterations = opts["iterations"]

        self.server_process_tag = "WEAVE-BDX-SERVER" + opts["test_tag"]
        self.client_process_tag = "WEAVE-BDX-CLIENT" + opts["test_tag"]

        self.client_node_id = None
        self.server_node_id = None

        self.strace = opts["strace"]

        plaid_opts = Plaid.default_options()
        plaid_opts['quiet'] = self.quiet
        self.plaid_server_node_id = 'node03'
        plaid_opts['server_node_id'] = self.plaid_server_node_id
        plaid_opts['num_clients'] = 2
        plaid_opts['server_ip_address'] = self.getNodeWeaveIPAddress(
            self.plaid_server_node_id)
        plaid_opts['strace'] = self.strace
        self.plaid = Plaid.Plaid(plaid_opts)

        self.use_plaid = opts["plaid"]
        if opts["plaid"] == "auto":
            if self.server == "service":
                # can't use plaid when talking to an external service
                self.use_plaid = False
            else:
                self.use_plaid = self.plaid.isPlaidConfigured()
Пример #9
0
    def __init__(self, opts=options):
        HappyNode.__init__(self)
        HappyNetwork.__init__(self)
        WeaveTest.__init__(self)

        self.__dict__.update(opts)

        self.client_process_tag = "WEAVE-SD-CLIENT" + self.test_tag
        self.service_process_tag = "WEAVE-SD-SERVICE" + self.test_tag

        plaid_opts = Plaid.default_options()
        plaid_opts['num_clients'] = 2
        plaid_opts['strace'] = self.strace
        self.plaid = Plaid.Plaid(plaid_opts)

        self.use_plaid = opts["plaid"]
        if opts["plaid"] == "auto":
            self.use_plaid = self.plaid.isPlaidConfigured()
Пример #10
0
    def __init__(self, opts=options):
        HappyNode.__init__(self)
        HappyNetwork.__init__(self)
        WeaveTest.__init__(self)

        self.__dict__.update(opts)

        self.no_service = False

        self.server_process_tag = "WEAVE_WDM_SERVER" + (
            opts["test_tag"] if "test_tag" in opts else "")
        self.client_process_tag = "WEAVE_WDM_CLIENT" + (
            opts["test_tag"] if "test_tag" in opts else "")
        self.plaid_server_process_tag = "PLAID_SERVER" + (
            opts["test_tag"] if "test_tag" in opts else "")

        self.client_node_id = None
        self.server_node_id = None

        self.clients_info = []

        self.wdm_client_option = None
        self.wdm_server_option = None

        plaid_opts = Plaid.default_options()
        plaid_opts["quiet"] = self.quiet
        self.plaid_server_node_id = "node03"
        plaid_opts["server_node_id"] = self.plaid_server_node_id
        plaid_opts["num_clients"] = 2
        plaid_opts["server_ip_address"] = self.getNodeWeaveIPAddress(
            self.plaid_server_node_id)
        plaid_opts["strace"] = self.strace
        self.plaid = Plaid.Plaid(plaid_opts)

        self.use_plaid = opts["plaid"]
        if opts["plaid"] == "auto":
            if self.server == "service":
                # can't use plaid when talking to an external service
                self.use_plaid = False
            else:
                self.use_plaid = self.plaid.isPlaidConfigured()
Пример #11
0
def run_unittest():
    """
    Wrapper for unittest.main() that ensures the Happy state is deleted in case
    of failure or error.
    This is meant to be used with mock-to-mock test cases that always delete the topology they create.
    If the test case can reuse an existing topology and therefore does not always delete the topology,
    it should handle exceptions in setUp and tearDown explicitly.

    Unittest traps all exceptions but not KeyboardInterrupt.
    So, a KeyboardInterrupt will cause the Happy state not to be deleted.
    An exception raised during a test results in the test ending with an "error"
    as opposed to a "failure" (see the docs for more details). tearDown is invoked
    in that case.
    If an exception is raised during setUp, tearDown is not invoked, and so the
    Happy state is not cleaned up.
    Note that an invocation of sys.exit() from the Happy code results in an
    exception itself (and then it depends if that is happening during setUp,
    during the test, or during tearDown).
    So,
      1. we must cleanup in case of KeyboardInterrupt, and
      2. to keep it simple, we cleanup in case of any SystemExit that carries
         an error (we don't care if unittest was able to run tearDown or not).
    """
    try:
        unittest.main()

    except KeyboardInterrupt:
        print("\n\nWeaveUtilities.run_unittest caught KeyboardInterrupt")
        cleanup_after_exception()
        raise

    except SystemExit as e:
        if e.args[0] not in [0, False]:
            print(
                "\n\nWeaveUtilities.run_unittest caught some kind of test error or failure"
            )
            cleanup_after_exception()
        raise e
    finally:
        Plaid.deletePlaidNetwork()