def check_prefix_and_slaac_address_are_added(self):
     wpan_util.verify_correct_prefix_among_similar_prefixes(self.all_nodes,
                                                            PREFIX,
                                                            stable=True,
                                                            on_mesh=True,
                                                            slaac=True)
     wpan_util.verify_address(self.all_nodes, PREFIX)
Ejemplo n.º 2
0
    def test03_Verify_NCP_Reset(self):

        # Verify that prefix1 is retained by `wpantund` and pushed to NCP after a reset
        self.r1.reset_thread_radio()
        self.wait_for_completion(self.device_list)

        # Wait for r1 to recover after reset
        start_time = time.time()
        wait_time = 5
        while not is_associated(self.r1):
            if time.time() - start_time > wait_time:
                print(
                    "Took too long for node to recover after reset ({}>{} sec)"
                    .format(time.time() - start_time, wait_time))
                exit(1)
            time.sleep(0.25)

        # Wait for on-mesh prefix to be updated
        time.sleep(0.5)
        verify_prefix(self.all_nodes,
                      prefix1,
                      stable=True,
                      on_mesh=True,
                      slaac=True)
        verify_address(self.all_nodes, prefix1)
Ejemplo n.º 3
0
    def test03_allowlist_r1_r2(self):
        # Add on-mesh prefix1 on router r1
        self.r1.config_gateway1(prefix1)
        self.wait_for_completion(self.device_list)
        time.sleep(60)
        r1_network_nodes = [self.r1, self.fed1]
        # Verify that the prefix1 and its corresponding address are present on all nodes
        verify_prefix(r1_network_nodes,
                      prefix1,
                      stable=True,
                      on_mesh=True,
                      slaac=True)
        verify_address(r1_network_nodes, prefix1)

        self.r1.allowlist_node(self.r2)
        self.r2.allowlist_node(self.r1)
        time.sleep(60)

        # verify partition id match
        r1_partition = self.r1.wpanctl("get", "get " + wpan.WPAN_PARTITION_ID,
                                       2).split("=")[1].strip()[1:-1]
        r2_partition = self.r2.wpanctl("get", "get " + wpan.WPAN_PARTITION_ID,
                                       2).split("=")[1].strip()[1:-1]
        self.logger.info("r1 partition is {}, r2 partition is {}".format(
            r1_partition, r2_partition))
        self.assertTrue(
            r1_partition == r2_partition,
            "r1, r2 partition id are not same after allowlisting r1, r2")
Ejemplo n.º 4
0
    def test02_unallowlist_r1_r2(self):
        """unallowlist r1 and r2, verify r2 become leader.
        """
        self.r1.un_allowlist_node(self.r2)
        self.r2.un_allowlist_node(self.r1)

        # verify r2 become leader
        r2_result = self._verify_device_role("r2", "leader")
        self.assertTrue(
            r2_result,
            "r2 cannot get into leader role after 180 seconds timeout")

        # verify r1 become leader
        r1_result = self._verify_device_role("r1", "leader")
        self.assertTrue(
            r1_result,
            "r1 cannot get into leader role after 180 seconds timeout")

        # Now add prefix2 with priority `high` on router r2 and check r2&fed2 nodes for the new prefix/address
        self.r2.config_gateway1(prefix2, default_route=True, priority="1")
        self.wait_for_completion(self.device_list)
        time.sleep(60)
        r2_network_nodes = [self.r2, self.fed2]
        verify_prefix(r2_network_nodes,
                      prefix2,
                      stable=True,
                      on_mesh=True,
                      slaac=True,
                      default_route=True,
                      priority="high")
        verify_address(r2_network_nodes, prefix2)

        # verify r1, r2 has different partition
        r1_partition = self.r1.wpanctl("get", "get " + wpan.WPAN_PARTITION_ID,
                                       2).split("=")[1].strip()[1:-1]
        r2_partition = self.r2.wpanctl("get", "get " + wpan.WPAN_PARTITION_ID,
                                       2).split("=")[1].strip()[1:-1]
        self.logger.info("r1 partition is {}, r2 partition is {}".format(
            r1_partition, r2_partition))
        self.assertFalse(
            r1_partition == r2_partition,
            "r1, r2 partition id are same after unallowlisting r1, r2")
Ejemplo n.º 5
0
    def test04_verify_role_prefix_childTable(self):
        # Verify that the prefix1 and its corresponding address are present on all nodes
        verify_prefix(self.all_nodes,
                      prefix1,
                      stable=True,
                      on_mesh=True,
                      slaac=True)
        verify_address(self.all_nodes, prefix1)
        # Verify that the prefix1 and its corresponding address are present on all nodes
        verify_prefix(self.all_nodes,
                      prefix2,
                      stable=True,
                      on_mesh=True,
                      slaac=True,
                      default_route=True,
                      priority="high")
        verify_address(self.all_nodes, prefix2)

        # verify r1, r2 role, one of them is leader
        r1_role = self.r1.wpanctl("get", "get " + wpan.WPAN_NODE_TYPE,
                                  2).split("=")[1].strip()[1:-1]
        r2_role = self.r2.wpanctl("get", "get " + wpan.WPAN_NODE_TYPE,
                                  2).split("=")[1].strip()[1:-1]
        roles_result = (r1_role == "leader"
                        and r2_role == "router") or (r2_role == "leader"
                                                     and r1_role == "router")
        self.assertTrue(
            roles_result,
            "r1, r2 role is not right, r1 is {}, r2 is {}".format(
                r1_role, r2_role))

        # verify their children stayed with their parents
        child_table = self.r1.wpanctl("get",
                                      "get " + wpan.WPAN_THREAD_CHILD_TABLE, 2)
        child_table = wpan_table_parser.parse_child_table_result(child_table)
        verify(len(child_table) == NUM_CHILDREN)

        child_table = self.r2.wpanctl("get",
                                      "get " + wpan.WPAN_THREAD_CHILD_TABLE, 2)
        child_table = wpan_table_parser.parse_child_table_result(child_table)
        verify(len(child_table) == NUM_CHILDREN)
Ejemplo n.º 6
0
    def test02_Verify_Prefix(self):
        # Add on-mesh prefix1 on router r1
        self.r1.config_gateway1(prefix1)
        self.wait_for_completion(self.device_list)
        time.sleep(60)

        # Verify that the prefix1 and its corresponding address are present on all nodes
        verify_prefix(self.all_nodes,
                      prefix1,
                      stable=True,
                      on_mesh=True,
                      slaac=True)
        verify_address(self.all_nodes, prefix1)

        # Now add prefix2 with priority `high` on router r2 and check all nodes for the new prefix/address
        self.r2.config_gateway1(prefix2, default_route=True, priority="1")
        self.wait_for_completion(self.device_list)
        time.sleep(60)
        verify_prefix(self.all_nodes,
                      prefix2,
                      stable=True,
                      on_mesh=True,
                      slaac=True,
                      default_route=True,
                      priority="high")
        verify_address(self.all_nodes, prefix2)

        # Add prefix3 on sleepy end-device and check for it on all nodes
        self.sc1.config_gateway1(prefix3, priority="-1")
        self.wait_for_completion(self.device_list)
        time.sleep(60)
        verify_prefix(self.all_nodes,
                      prefix3,
                      stable=True,
                      on_mesh=True,
                      slaac=True,
                      priority="low")
        verify_address(self.all_nodes, prefix3)
 def check_addresses_on_child():
     verify_address([self.child], prefix1)
     verify_address([self.child], prefix2)
     verify_address([self.child], prefix3)
     verify_address([self.child], prefix4)