Minimal e2e implementation of packet trace. - #1433
Conversation
|
How could we test this? E.g., for the compiler we have golden tests to ensure that the output matches our expectations. We could also use gtests and pattern match, but that is harder to maintain and review and might not capture the full picture of a trace. |
During development I have a local smoke test script(which generates the trace in the pr description). Though I haven't think very thoroughly on how to test this. Since it is using existing infrastructure I hope we could reuse the existing nanomsg backend testing, but not sure if that exists. |
Basically you want avoid that this feature slowly bitrots. Ideally, we have infra for E2E tests that run BMv2, generate a trace and then we compare outputs. |
|
@c8ef I think we should be producing golden tests for this and adding appropriate test cases so that we can see if the behavior is as we expect. Ideally, we would iterate over the different P4 pipelines that we have define and send the corresponding input packets through BMv2 and then we output the packet trace in a golden file (.expected file). Since you added the Bazel support, we can do some golden tests. Here are a couple of examples: This is the corresponding test runner: https://github.com/google/p4-infra/blob/f107159078db6ba189a413d7308f00b4c0d1d9fe/p4_pdpi/references_test_runner.cc This is a sample expected file: https://github.com/google/p4-infra/blob/f107159078db6ba189a413d7308f00b4c0d1d9fe/p4_pdpi/references.expected We can also add the golden tests to the Github workflow. |
e97f11d to
2712f9c
Compare
Thanks for the pointers on the test runners! Following that pattern, I added a similar test runner for BMv2 and the structured packet trace test. Since the test isn't necessarily related to gRPC, I added it to the simple_switch target directory. |
Signed-off-by: c8ef <c8ef@outlook.com>
matthewtlam
left a comment
There was a problem hiding this comment.
Sending some initial comments. Sorry for the late review, I've been on vacation and haven't had a good chance to take a look at things. Also the PR is big so it will take sometime. Will try to have faster reviews. LOoking good as a start!
| Output packets: | ||
| port=1 len=6 bytes=000000010000 | ||
| Packet traces: | ||
| --- trace_1.txtpb |
There was a problem hiding this comment.
The numbering of the traces should be unique and ideally start at 0 for each packet test. It will be hard to keep track of the correct number of expected outputs for cases like WCMP where we want to make sure that we output the correct number of traces
There was a problem hiding this comment.
In current design the trace filename closely related to packet_id, which in the parser_error case there are precisely 3 packets here. I think we could use this to test the number logic here, and if there is special case like WCMP, maybe we could limit to one packet, and focus on the single trace?
There was a problem hiding this comment.
I think for WCMP we would not want to only show a single packet nor a single packet trace but show a comprehensive set of packets despite being lengthy as it helps provide all the debug info needed. We should adjust the output of this golden test to account for this
There was a problem hiding this comment.
Understood. Now in the latest version, the traces and packet_ids have been renamed, so we can clearly see the expected number of packet or packet_id.
| -- INPUT ---------------------------------------------------------------- | ||
| P4 pipeline: recirc.json | ||
| Table programming: | ||
| (none) |
There was a problem hiding this comment.
For recirculate, we should have table entries such that we expect to see the packet entering the ingress + egress stage at least twice. Perhaps add another test case here to show this property off
There was a problem hiding this comment.
Actually it has the default table entry (see the related json file for more detail), so here (none) means no manually added table programming. I should make it clearer here.
There was a problem hiding this comment.
Fixed the trace file description and removed the redundant manually defined table entry in e5ebb0e
There was a problem hiding this comment.
Ack sounds good. Though we should have more comprehensive tests in itself for the recirculate behavior in itself. Perhaps we should open an issue to track this
There was a problem hiding this comment.
I think when packet trace relates to recirculate is implemented, current test will be sufficient for the recirculate testing? If not we can add more test then.
Signed-off-by: c8ef <c8ef@outlook.com>
Signed-off-by: c8ef <c8ef@outlook.com>
| Output packets: | ||
| port=1 len=6 bytes=000000010000 | ||
| Packet traces: | ||
| --- trace_1.txtpb |
There was a problem hiding this comment.
I think for WCMP we would not want to only show a single packet nor a single packet trace but show a comprehensive set of packets despite being lengthy as it helps provide all the debug info needed. We should adjust the output of this golden test to account for this
| -- INPUT ---------------------------------------------------------------- | ||
| P4 pipeline: recirc.json | ||
| Table programming: | ||
| (none) |
There was a problem hiding this comment.
Ack sounds good. Though we should have more comprehensive tests in itself for the recirculate behavior in itself. Perhaps we should open an issue to track this
|
|
||
| std::cout << kOutputBanner << "\n"; | ||
| std::cout << "Output packets:\n"; | ||
| if (outputs.empty()) std::cout << " (none)\n"; |
There was a problem hiding this comment.
May be nice to specify the packets get dropped, but we can handle that in a follow up PR as well
There was a problem hiding this comment.
I think if the packets get dropped in Packet traces: section we can clearly see the traces relate to drop. Adding the information here is also acceptable.
Signed-off-by: c8ef <c8ef@outlook.com>
Signed-off-by: c8ef <c8ef@outlook.com>
Signed-off-by: c8ef <c8ef@outlook.com>
|
|
||
| - name: Test | ||
| run: bazel test //targets/simple_switch_grpc/tests/... | ||
| run: | |
There was a problem hiding this comment.
My one request is also to add test support for cmake here. Bazel-only is not great for the wider community
There was a problem hiding this comment.
Since this PR is already huge I suggest this could be done in follow up PRs.
There was a problem hiding this comment.
I prefer to merge this only when it is complete. This PR only changes 19 files, most of which are test files.
There was a problem hiding this comment.
Okay. But I'm not familiar with all these build systems so it might take a while.
With this patch we will have a minimal and workable implementation of packet trace with testcases.