From e08c56634c9ea31541f7671879376e77b1cedd2d Mon Sep 17 00:00:00 2001 From: Hiroki Shirokura Date: Wed, 25 Aug 2021 03:24:19 +0000 Subject: [PATCH] topotests: update test cases about srv6 locator deletion Before this PR, in case of get locator chunk zapi from zclient, zebra precreated a down state locator and set the chunk ownership. After this PR, this is no longer done, and chunks are no longer automatically generated. In this commit, we will make a test update to check the corresponding detailed behavior. Signed-off-by: Hiroki Shirokura --- .../srv6_locator/expected_chunks4.json | 4 --- .../srv6_locator/expected_chunks5.json | 6 ---- .../srv6_locator/expected_chunks6.json | 2 ++ .../srv6_locator/expected_locators4.json | 10 +++--- .../srv6_locator/expected_locators5.json | 13 +------ .../srv6_locator/expected_locators6.json | 5 +++ .../srv6_locator/test_srv6_locator.py | 35 +++++++++++++++---- 7 files changed, 43 insertions(+), 32 deletions(-) create mode 100644 tests/topotests/srv6_locator/expected_chunks6.json create mode 100644 tests/topotests/srv6_locator/expected_locators6.json diff --git a/tests/topotests/srv6_locator/expected_chunks4.json b/tests/topotests/srv6_locator/expected_chunks4.json index 6e49738f37..0d4f101c7a 100644 --- a/tests/topotests/srv6_locator/expected_chunks4.json +++ b/tests/topotests/srv6_locator/expected_chunks4.json @@ -1,6 +1,2 @@ [ - { - "name": "loc3", - "chunks": [] - } ] diff --git a/tests/topotests/srv6_locator/expected_chunks5.json b/tests/topotests/srv6_locator/expected_chunks5.json index a18221859e..0d4f101c7a 100644 --- a/tests/topotests/srv6_locator/expected_chunks5.json +++ b/tests/topotests/srv6_locator/expected_chunks5.json @@ -1,8 +1,2 @@ [ - { - "name": "loc3", - "chunks": [ - "2001:db8:3:3::/64" - ] - } ] diff --git a/tests/topotests/srv6_locator/expected_chunks6.json b/tests/topotests/srv6_locator/expected_chunks6.json new file mode 100644 index 0000000000..0d4f101c7a --- /dev/null +++ b/tests/topotests/srv6_locator/expected_chunks6.json @@ -0,0 +1,2 @@ +[ +] diff --git a/tests/topotests/srv6_locator/expected_locators4.json b/tests/topotests/srv6_locator/expected_locators4.json index 7989f9021b..4b0f95f7be 100644 --- a/tests/topotests/srv6_locator/expected_locators4.json +++ b/tests/topotests/srv6_locator/expected_locators4.json @@ -23,11 +23,13 @@ ] }, { - "name":"loc3", - "statusUp":false, - "chunks":[ + "name": "loc3", + "prefix": "2001:db8:3:3::/64", + "statusUp": true, + "chunks": [ { - "proto":"sharp" + "prefix": "2001:db8:3:3::/64", + "proto": "system" } ] } diff --git a/tests/topotests/srv6_locator/expected_locators5.json b/tests/topotests/srv6_locator/expected_locators5.json index 8c512ebc46..bcffa004bd 100644 --- a/tests/topotests/srv6_locator/expected_locators5.json +++ b/tests/topotests/srv6_locator/expected_locators5.json @@ -1,16 +1,5 @@ { "locators":[ - { - "name": "loc1", - "prefix": "2001:db8:1:1::/64", - "statusUp": true, - "chunks": [ - { - "prefix": "2001:db8:1:1::/64", - "proto": "system" - } - ] - }, { "name": "loc2", "prefix": "2001:db8:2:2::/64", @@ -29,7 +18,7 @@ "chunks":[ { "prefix": "2001:db8:3:3::/64", - "proto": "sharp" + "proto": "system" } ] } diff --git a/tests/topotests/srv6_locator/expected_locators6.json b/tests/topotests/srv6_locator/expected_locators6.json new file mode 100644 index 0000000000..66d23d5556 --- /dev/null +++ b/tests/topotests/srv6_locator/expected_locators6.json @@ -0,0 +1,5 @@ +{ + "locators":[ + ] +} + diff --git a/tests/topotests/srv6_locator/test_srv6_locator.py b/tests/topotests/srv6_locator/test_srv6_locator.py index b48cd09bf9..bc5fa409d2 100755 --- a/tests/topotests/srv6_locator/test_srv6_locator.py +++ b/tests/topotests/srv6_locator/test_srv6_locator.py @@ -102,6 +102,10 @@ def test_srv6(): success, result = topotest.run_and_expect(func, None, count=5, wait=0.5) assert result is None, "Failed" + # FOR DEVELOPER: + # If you want to stop some specific line and start interactive shell, + # please use tgen.mininet_cli() to start it. + logger.info("Test1 for Locator Configuration") check_srv6_locator(router, "expected_locators1.json") check_sharpd_chunk(router, "expected_chunks1.json") @@ -116,12 +120,7 @@ def test_srv6(): check_srv6_locator(router, "expected_locators3.json") check_sharpd_chunk(router, "expected_chunks3.json") - logger.info("Test4 get chunk for non-exist locator by zclient") - router.vtysh_cmd("sharp srv6-manager get-locator-chunk loc3") - check_srv6_locator(router, "expected_locators4.json") - check_sharpd_chunk(router, "expected_chunks4.json") - - logger.info("Test5 Test for Zclient. after locator loc3 was configured") + logger.info("Test4 additional locator loc3") router.vtysh_cmd( """ configure terminal @@ -132,9 +131,33 @@ def test_srv6(): prefix 2001:db8:3:3::/64 """ ) + check_srv6_locator(router, "expected_locators4.json") + check_sharpd_chunk(router, "expected_chunks4.json") + + logger.info("Test5 delete locator and chunk is released automatically") + router.vtysh_cmd( + """ + configure terminal + segment-routing + srv6 + locators + no locator loc1 + """ + ) check_srv6_locator(router, "expected_locators5.json") check_sharpd_chunk(router, "expected_chunks5.json") + logger.info("Test6 delete srv6 all configuration") + router.vtysh_cmd( + """ + configure terminal + segment-routing + no srv6 + """ + ) + check_srv6_locator(router, "expected_locators6.json") + check_sharpd_chunk(router, "expected_chunks6.json") + if __name__ == "__main__": args = ["-s"] + sys.argv[1:]