-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to test dplane_fpm_nl.c file #15369
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
852a748
doc, tools: Remove ARRAY_SIZE check
donaldsharp fef93e6
zebra: Add fpm_listener
donaldsharp 0a9e8ef
zebra: Add `show fpm status [json]` command
donaldsharp a0c4fe2
doc: Add `show fpm status [json]` command to documentation
donaldsharp 841d50e
tests: Add ability to run a fpm listener
donaldsharp 5ca133e
tests: Add a very simple test for the dplane_fpm_nl module
donaldsharp c12f88c
tests: Add a pytest marker for the fpm
donaldsharp 0beabd7
debian: Add a frr-test-tools debian package
donaldsharp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
usr/lib/frr/fpm_listener |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"connected":true, | ||
"useNHG":true, | ||
"useRouteReplace":true, | ||
"disabled":false, | ||
"address":"127.0.0.1", | ||
"port":2620 | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"routes":[ | ||
{ | ||
"fib":1, | ||
"rib":1, | ||
"fibOffLoaded":0, | ||
"fibTrapped":0, | ||
"type":"connected" | ||
}, | ||
{ | ||
"fib":1, | ||
"rib":1, | ||
"fibOffLoaded":0, | ||
"fibTrapped":0, | ||
"type":"local" | ||
}, | ||
{ | ||
"fib":10000, | ||
"rib":10000, | ||
"fibOffLoaded":0, | ||
"fibTrapped":0, | ||
"type":"sharp" | ||
} | ||
], | ||
"routesTotal":10002, | ||
"routesTotalFib":10002 | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/topotests/fpm_testing_topo1/r1/routes_summ_removed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"routes":[ | ||
{ | ||
"fib":1, | ||
"rib":1, | ||
"fibOffLoaded":0, | ||
"fibTrapped":0, | ||
"type":"connected" | ||
}, | ||
{ | ||
"fib":1, | ||
"rib":1, | ||
"fibOffLoaded":0, | ||
"fibTrapped":0, | ||
"type":"local" | ||
} | ||
], | ||
"routesTotal":2, | ||
"routesTotalFib":2 | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
fpm address 127.0.0.1 | ||
|
||
interface r1-eth0 | ||
ip address 192.168.44.1/24 | ||
! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
#!/usr/bin/env python | ||
# SPDX-License-Identifier: ISC | ||
|
||
# | ||
# test_route_scale1.py | ||
# | ||
# Copyright (c) 2024 by | ||
# Nvidia, Inc. | ||
# Donald Sharp | ||
# | ||
|
||
""" | ||
test_fpm_topo1.py: Testing FPM module | ||
|
||
""" | ||
import os | ||
import re | ||
import sys | ||
import pytest | ||
import json | ||
from functools import partial | ||
|
||
# Save the Current Working Directory to find configuration files. | ||
CWD = os.path.dirname(os.path.realpath(__file__)) | ||
sys.path.append(os.path.join(CWD, "../")) | ||
|
||
# pylint: disable=C0413 | ||
# Import topogen and topotest helpers | ||
from lib import topotest | ||
from lib.topogen import Topogen, TopoRouter, get_topogen | ||
from lib.topolog import logger | ||
|
||
|
||
pytestmark = [pytest.mark.fpm, pytest.mark.sharpd] | ||
|
||
|
||
def build_topo(tgen): | ||
"Build function" | ||
|
||
# Populate routers | ||
tgen.add_router("r1") | ||
|
||
switch = tgen.add_switch("sw1") | ||
switch.add_link(tgen.gears["r1"]) | ||
|
||
|
||
def setup_module(module): | ||
"Setup topology" | ||
|
||
# fpm_stub = os.system("which fpm-stub") | ||
# if fpm-stub: | ||
# pytest.skip("") | ||
|
||
tgen = Topogen(build_topo, module.__name__) | ||
tgen.start_topology() | ||
|
||
router_list = tgen.routers() | ||
for rname, router in router_list.items(): | ||
router.load_config( | ||
TopoRouter.RD_ZEBRA, | ||
os.path.join(CWD, "{}/zebra.conf".format(rname)), | ||
"-M dplane_fpm_nl", | ||
) | ||
router.load_config( | ||
TopoRouter.RD_SHARP, os.path.join(CWD, "{}/sharpd.conf".format(rname)) | ||
) | ||
router.load_config( | ||
TopoRouter.RD_FPM_LISTENER, os.path.join(CWD, "{}/fpm_stub.conf".format(rname)) | ||
) | ||
|
||
tgen.start_router() | ||
|
||
|
||
def teardown_module(_mod): | ||
"Teardown the pytest environment" | ||
|
||
tgen = get_topogen() | ||
|
||
# This function tears down the whole topology. | ||
tgen.stop_topology() | ||
|
||
|
||
def test_fpm_connection_made(): | ||
"Test that the fpm starts up and a connection is made" | ||
|
||
tgen = get_topogen() | ||
router = tgen.gears["r1"] | ||
|
||
fpm_counters = "{}/r1/fpm_counters.json".format(CWD) | ||
expected = json.loads(open(fpm_counters).read()) | ||
|
||
test_func = partial( | ||
topotest.router_json_cmp, router, "show fpm status json", expected | ||
) | ||
|
||
success, result = topotest.run_and_expect(test_func, None, 30, 1) | ||
assert success, "Unable to connect to the fpm:\n{}".format(result) | ||
|
||
|
||
def test_fpm_install_routes(): | ||
"Test that simple routes installed appears to work" | ||
|
||
tgen = get_topogen() | ||
router = tgen.gears["r1"] | ||
|
||
# Let's install 10000 routes | ||
router.vtysh_cmd("sharp install routes 10.0.0.0 nexthop 192.168.44.33 10000") | ||
routes_file = "{}/r1/routes_summ.json".format(CWD) | ||
expected = json.loads(open(routes_file).read()) | ||
|
||
test_func = partial( | ||
topotest.router_json_cmp, router, "show ip route summ json", expected | ||
) | ||
|
||
success, result = topotest.run_and_expect(test_func, None, 60, 1) | ||
assert success, "Unable to successfully install 10000 routes: {}".format(result) | ||
|
||
# Let's remove 10000 routes | ||
router.vtysh_cmd("sharp remove routes 10.0.0.0 10000") | ||
|
||
routes_file_removed = "{}/r1/routes_summ_removed.json".format(CWD) | ||
expected = json.loads(open(routes_file_removed).read()) | ||
|
||
test_func = partial( | ||
topotest.router_json_cmp, router, "show ip route summ json", expected | ||
) | ||
|
||
success, result = topotest.run_and_expect(test_func, None, 60, 1) | ||
assert success, "Unable to remove 10000 routes: {}".format(result) | ||
|
||
|
||
if __name__ == "__main__": | ||
args = ["-s"] + sys.argv[1:] | ||
sys.exit(pytest.main(args)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be good for RPM too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent 2 seconds looking at it and decided I have no idea how to do this in rpm land. If someone needs this as part of the rpm stuff, then they can add it. I feel it is ok for this approach because of the low usage of rpms