Skip to content

Commit

Permalink
[tests] rename get_netdata_nat64_prefix() to `get_netdata_nat64_rou…
Browse files Browse the repository at this point in the history
…tes()` (#9678)
  • Loading branch information
superwhd authored Dec 5, 2023
1 parent 11622a1 commit 4ed44bc
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def test(self):
self.assertNotEqual(br2_local_nat64_prefix, br2.get_br_favored_nat64_prefix())
br2_infra_nat64_prefix = br2.get_br_favored_nat64_prefix()

self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
nat64_prefix = br1.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br1.get_netdata_nat64_routes()), 1)
nat64_prefix = br1.get_netdata_nat64_routes()[0]
self.assertEqual(nat64_prefix, br2_infra_nat64_prefix)
self.assertNotEqual(nat64_prefix, br1_local_nat64_prefix)
self.assertDictIncludes(br1.nat64_state, {
Expand All @@ -151,8 +151,8 @@ def test(self):
br2.nat64_set_enabled(False)
self.simulator.go(10)

self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
nat64_prefix = br1.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br1.get_netdata_nat64_routes()), 1)
nat64_prefix = br1.get_netdata_nat64_routes()[0]
self.assertEqual(nat64_prefix, br1_local_nat64_prefix)
self.assertDictIncludes(br1.nat64_state, {
'PrefixManager': NAT64_STATE_ACTIVE,
Expand All @@ -174,8 +174,8 @@ def test(self):
self.simulator.go(10)
self.assertEqual(br2_local_nat64_prefix, br2.get_br_favored_nat64_prefix())

self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
nat64_prefix = br1.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br1.get_netdata_nat64_routes()), 1)
nat64_prefix = br1.get_netdata_nat64_routes()[0]
self.assertEqual(nat64_prefix, br1_local_nat64_prefix)
self.assertNotEqual(nat64_prefix, br2_local_nat64_prefix)
self.assertDictIncludes(br1.nat64_state, {
Expand All @@ -194,8 +194,8 @@ def test(self):
br1.nat64_set_enabled(False)

self.simulator.go(10)
self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
nat64_prefix = br1.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br1.get_netdata_nat64_routes()), 1)
nat64_prefix = br1.get_netdata_nat64_routes()[0]
self.assertEqual(br2_local_nat64_prefix, nat64_prefix)
self.assertNotEqual(br1_local_nat64_prefix, nat64_prefix)
self.assertDictIncludes(br1.nat64_state, {
Expand All @@ -214,8 +214,8 @@ def test(self):
br1.nat64_set_enabled(True)

self.simulator.go(10)
self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
nat64_prefix = br1.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br1.get_netdata_nat64_routes()), 1)
nat64_prefix = br1.get_netdata_nat64_routes()[0]
self.assertEqual(br2_local_nat64_prefix, nat64_prefix)
self.assertNotEqual(br1_local_nat64_prefix, nat64_prefix)
self.assertDictIncludes(br1.nat64_state, {
Expand All @@ -233,8 +233,8 @@ def test(self):
#
br2.disable_br()
self.simulator.go(10)
self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
nat64_prefix = br1.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br1.get_netdata_nat64_routes()), 1)
nat64_prefix = br1.get_netdata_nat64_routes()[0]
self.assertEqual(br1_local_nat64_prefix, nat64_prefix)
self.assertNotEqual(br2_local_nat64_prefix, nat64_prefix)
self.assertDictIncludes(br1.nat64_state, {
Expand All @@ -252,8 +252,8 @@ def test(self):
#
br2.enable_br()
self.simulator.go(10)
self.assertEqual(len(br1.get_netdata_nat64_prefix()), 1)
nat64_prefix = br1.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br1.get_netdata_nat64_routes()), 1)
nat64_prefix = br1.get_netdata_nat64_routes()[0]
self.assertEqual(br1_local_nat64_prefix, nat64_prefix)
self.assertNotEqual(br2_local_nat64_prefix, nat64_prefix)
self.assertDictIncludes(br1.nat64_state, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def test(self):
self.simulator.go(5)
local_nat64_prefix = br.get_br_nat64_prefix()

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
nat64_prefix = br.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
nat64_prefix = br.get_netdata_nat64_routes()[0]
self.assertEqual(nat64_prefix, local_nat64_prefix)

#
Expand All @@ -150,15 +150,15 @@ def test(self):
br.register_netdata()
self.simulator.go(5)

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertNotEqual(local_nat64_prefix, br.get_netdata_nat64_prefix()[0])
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertNotEqual(local_nat64_prefix, br.get_netdata_nat64_routes()[0])

br.remove_route(SMALL_NAT64_PREFIX)
br.register_netdata()
self.simulator.go(10)

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertEqual(local_nat64_prefix, br.get_netdata_nat64_prefix()[0])
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertEqual(local_nat64_prefix, br.get_netdata_nat64_routes()[0])

#
# Case 3.
Expand All @@ -169,15 +169,15 @@ def test(self):
br.register_netdata()
self.simulator.go(5)

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertNotEqual(local_nat64_prefix, br.get_netdata_nat64_prefix()[0])
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertNotEqual(local_nat64_prefix, br.get_netdata_nat64_routes()[0])

br.remove_route(LARGE_NAT64_PREFIX)
br.register_netdata()
self.simulator.go(10)

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertEqual(local_nat64_prefix, br.get_netdata_nat64_prefix()[0])
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertEqual(local_nat64_prefix, br.get_netdata_nat64_routes()[0])

#
# Case 4. Disable and re-enable border routing on the border router.
Expand All @@ -186,7 +186,7 @@ def test(self):
self.simulator.go(5)

# NAT64 prefix is withdrawn from Network Data.
self.assertEqual(len(br.get_netdata_nat64_prefix()), 0)
self.assertEqual(len(br.get_netdata_nat64_routes()), 0)

br.enable_br()
self.simulator.go(config.BORDER_ROUTER_STARTUP_DELAY)
Expand Down Expand Up @@ -256,17 +256,17 @@ def test(self):
self.simulator.go(5)

# NAT64 prefix is withdrawn from Network Data.
self.assertEqual(len(br.get_netdata_nat64_prefix()), 0)
self.assertEqual(len(br.get_netdata_nat64_routes()), 0)

br.enable_ether()
self.simulator.go(80)

# Same NAT64 prefix is advertised to Network Data.
self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertEqual(nat64_prefix, br.get_netdata_nat64_prefix()[0])
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertEqual(nat64_prefix, br.get_netdata_nat64_routes()[0])
# Same NAT64 prefix is advertised to Network Data.
self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertEqual(nat64_prefix, br.get_netdata_nat64_prefix()[0])
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertEqual(nat64_prefix, br.get_netdata_nat64_routes()[0])


if __name__ == '__main__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def test(self):
# Case 1 No infra-derived OMR prefix. BR publishes its local prefix.
local_nat64_prefix = br.get_br_nat64_prefix()

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
nat64_prefix = br.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
nat64_prefix = br.get_netdata_nat64_routes()[0]
self.assertEqual(nat64_prefix, local_nat64_prefix)

self.assertDictIncludes(br.nat64_state, {
Expand All @@ -112,8 +112,8 @@ def test(self):
self.assertNotEqual(favored_nat64_prefix, local_nat64_prefix)
infra_nat64_prefix = favored_nat64_prefix

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
nat64_prefix = br.get_netdata_nat64_prefix()[0]
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
nat64_prefix = br.get_netdata_nat64_routes()[0]
self.assertEqual(nat64_prefix, infra_nat64_prefix)
self.assertDictIncludes(br.nat64_state, {
'PrefixManager': NAT64_STATE_ACTIVE,
Expand All @@ -126,8 +126,8 @@ def test(self):
br.register_netdata()
self.simulator.go(5)

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertNotEqual(infra_nat64_prefix, br.get_netdata_nat64_prefix()[0])
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertNotEqual(infra_nat64_prefix, br.get_netdata_nat64_routes()[0])
self.assertDictIncludes(br.nat64_state, {
'PrefixManager': NAT64_STATE_IDLE,
'Translator': NAT64_STATE_NOT_RUNNING
Expand All @@ -137,16 +137,16 @@ def test(self):
br.register_netdata()
self.simulator.go(10)

self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertEqual(nat64_prefix, infra_nat64_prefix)

# Case 4 No change when a smaller prefix in low preference is present
br.add_route(SMALL_NAT64_PREFIX, stable=False, nat64=True, prf='low')
br.register_netdata()
self.simulator.go(5)

self.assertEqual(len(br.get_netdata_nat64_prefix()), 2)
self.assertEqual(br.get_netdata_nat64_prefix(), [infra_nat64_prefix, SMALL_NAT64_PREFIX])
self.assertEqual(len(br.get_netdata_nat64_routes()), 2)
self.assertEqual(br.get_netdata_nat64_routes(), [infra_nat64_prefix, SMALL_NAT64_PREFIX])
self.assertDictIncludes(br.nat64_state, {
'PrefixManager': NAT64_STATE_ACTIVE,
'Translator': NAT64_STATE_NOT_RUNNING
Expand All @@ -162,8 +162,8 @@ def test(self):

local_nat64_prefix = br.get_br_nat64_prefix()
self.assertNotEqual(local_nat64_prefix, infra_nat64_prefix)
self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertEqual(br.get_netdata_nat64_prefix()[0], local_nat64_prefix)
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertEqual(br.get_netdata_nat64_routes()[0], local_nat64_prefix)
self.assertDictIncludes(br.nat64_state, {
'PrefixManager': NAT64_STATE_ACTIVE,
'Translator': NAT64_STATE_ACTIVE
Expand All @@ -174,8 +174,8 @@ def test(self):
self.simulator.go(NAT64_PREFIX_REFRESH_DELAY)

self.assertEqual(br.get_br_favored_nat64_prefix(), infra_nat64_prefix)
self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertEqual(br.get_netdata_nat64_prefix()[0], infra_nat64_prefix)
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertEqual(br.get_netdata_nat64_routes()[0], infra_nat64_prefix)
self.assertDictIncludes(br.nat64_state, {
'PrefixManager': NAT64_STATE_ACTIVE,
'Translator': NAT64_STATE_NOT_RUNNING
Expand All @@ -188,8 +188,8 @@ def test(self):
self.simulator.go(NAT64_PREFIX_REFRESH_DELAY)

self.assertEqual(br.get_br_favored_nat64_prefix(), SMALL_NAT64_PREFIX)
self.assertEqual(len(br.get_netdata_nat64_prefix()), 1)
self.assertEqual(br.get_netdata_nat64_prefix()[0], SMALL_NAT64_PREFIX)
self.assertEqual(len(br.get_netdata_nat64_routes()), 1)
self.assertEqual(br.get_netdata_nat64_routes()[0], SMALL_NAT64_PREFIX)
self.assertDictIncludes(br.nat64_state, {
'PrefixManager': NAT64_STATE_ACTIVE,
'Translator': NAT64_STATE_NOT_RUNNING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ def test(self):
self.assertEqual(br1_omr_prefix, br1.get_netdata_omr_prefixes()[0])

# Each BR should independently register an external route for the on-link prefix.
self.assertEqual(len(br1.get_netdata_non_nat64_prefixes()), 2)
self.assertEqual(len(router1.get_netdata_non_nat64_prefixes()), 2)
self.assertEqual(len(br2.get_netdata_non_nat64_prefixes()), 2)
self.assertEqual(len(router2.get_netdata_non_nat64_prefixes()), 2)
self.assertEqual(len(br1.get_netdata_non_nat64_routes()), 2)
self.assertEqual(len(router1.get_netdata_non_nat64_routes()), 2)
self.assertEqual(len(br2.get_netdata_non_nat64_routes()), 2)
self.assertEqual(len(router2.get_netdata_non_nat64_routes()), 2)

br1_on_link_prefix = br1.get_br_on_link_prefix()

Expand Down Expand Up @@ -192,10 +192,10 @@ def test(self):
# There should be no changes to the external route for the
# on-link prefix, given that the on-link prefix is derived
# from the Extended PAN ID.
self.assertEqual(len(br1.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(router1.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(br2.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(router2.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(br1.get_netdata_non_nat64_routes()), 1)
self.assertEqual(len(router1.get_netdata_non_nat64_routes()), 1)
self.assertEqual(len(br2.get_netdata_non_nat64_routes()), 1)
self.assertEqual(len(router2.get_netdata_non_nat64_routes()), 1)

br2_on_link_prefix = br2.get_br_on_link_prefix()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ def test(self):

# Each BR should independently register an external route for the on-link prefix
# and OMR prefix in another Thread Network.
self.assertEqual(br1.get_netdata_non_nat64_prefixes(), ['fc00::/7'])
self.assertEqual(router1.get_netdata_non_nat64_prefixes(), ['fc00::/7'])
self.assertEqual(br2.get_netdata_non_nat64_prefixes(), ['fc00::/7'])
self.assertEqual(router2.get_netdata_non_nat64_prefixes(), ['fc00::/7'])
self.assertEqual(br1.get_netdata_non_nat64_routes(), ['fc00::/7'])
self.assertEqual(router1.get_netdata_non_nat64_routes(), ['fc00::/7'])
self.assertEqual(br2.get_netdata_non_nat64_routes(), ['fc00::/7'])
self.assertEqual(router2.get_netdata_non_nat64_routes(), ['fc00::/7'])

self.assertTrue(len(router1.get_ip6_address(config.ADDRESS_TYPE.OMR)) == 1)
self.assertTrue(len(router2.get_ip6_address(config.ADDRESS_TYPE.OMR)) == 1)
Expand Down
10 changes: 5 additions & 5 deletions tests/scripts/thread-cert/border_router/test_on_link_prefix.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test(self):
logging.info("ROUTER1 addrs: %r", router1.get_addrs())
logging.info("HOST addrs: %r", host.get_addrs())

self.assertEqual(len(br1.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(br1.get_netdata_non_nat64_routes()), 1)

host_on_link_addr = host.get_matched_ula_addresses(ON_LINK_PREFIX)[0]
self.assertTrue(router1.ping(host_on_link_addr))
Expand Down Expand Up @@ -166,10 +166,10 @@ def test(self):
# but don't remove the external routes for the radvd on-link prefix
# immediately, because the SLAAC addresses are still valid.

self.assertEqual(len(br1.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(router1.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(br2.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(router2.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(br1.get_netdata_non_nat64_routes()), 1)
self.assertEqual(len(router1.get_netdata_non_nat64_routes()), 1)
self.assertEqual(len(br2.get_netdata_non_nat64_routes()), 1)
self.assertEqual(len(router2.get_netdata_non_nat64_routes()), 1)

br2_on_link_prefix = br2.get_br_on_link_prefix()

Expand Down
8 changes: 4 additions & 4 deletions tests/scripts/thread-cert/border_router/test_radvd_coexist.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def test(self):

self.assertEqual(len(br.get_netdata_omr_prefixes()), 1)
self.assertEqual(len(router.get_netdata_omr_prefixes()), 1)
self.assertEqual(len(br.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(router.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(br.get_netdata_non_nat64_routes()), 1)
self.assertEqual(len(router.get_netdata_non_nat64_routes()), 1)

self.assertEqual(len(br.get_ip6_address(config.ADDRESS_TYPE.OMR)), 1)
self.assertEqual(len(router.get_ip6_address(config.ADDRESS_TYPE.OMR)), 1)
Expand All @@ -122,8 +122,8 @@ def test(self):

self.assertEqual(len(br.get_netdata_omr_prefixes()), 1)
self.assertEqual(len(router.get_netdata_omr_prefixes()), 1)
self.assertEqual(len(br.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(router.get_netdata_non_nat64_prefixes()), 1)
self.assertEqual(len(br.get_netdata_non_nat64_routes()), 1)
self.assertEqual(len(router.get_netdata_non_nat64_routes()), 1)

self.assertEqual(len(br.get_ip6_address(config.ADDRESS_TYPE.OMR)), 1)
self.assertEqual(len(router.get_ip6_address(config.ADDRESS_TYPE.OMR)), 1)
Expand Down
Loading

0 comments on commit 4ed44bc

Please sign in to comment.