p4c
p4c copied to clipboard
First take at p4tc automated tests
First take at implementing the automated testing code for tc backend. In a nutshell, what it's doing is expanding on the already existing run-tc-test.py script. The expansion consists of:
Compiling the generated C files to eBPF bytecode Extracting a P4TC kernel image from github Compiling P4TC's version of iproute2 Spawning a VM using virtme to boot the P4TC kernel Executing the template script generated by the compiler Loading the generated eBPF parser and control blocks binaries using a TC P4 filter Loading the runtime rules specified in the samples directory (*.rules) Parsing an STF in the samples directory detailing what packets to send/expect Sending the packets using scapy Verifying that the sent packets (and eventual received packets from the p4tc pipeline) and correct according to the STF file Opening it as a draft PR because we still need to see how this works with github actions Locally it's doing fine, however we never know
I created a separate directory for the tests that involve STFs testdata/p4tc_samples_stf/ to make it cleaner However that might've been overkill, I can undo that if reviewers think it's best
The installation might be missing gcc-multilib.
I recommend adding a TC-specific section here: https://github.com/p4lang/p4c/blob/main/tools/ci-build.sh#L170
The installation might be missing
gcc-multilib.I recommend adding a TC-specific section here: https://github.com/p4lang/p4c/blob/main/tools/ci-build.sh#L170
Thank you, will do
The code looks okay from my side, I just have final reservations on the CI process. The installation of the VM etc adds significant overhead to our CI. Maybe we should make this a separate workflow that is optional and only runs on code that touches p4tc parts or PRs tagged with p4tc.
Let me think about how to introduce this.
Approving to unblock things. We should consider putting the TC tests in a separate (nightly) workflow that is also triggered when code in the tc folder changes or when a PR is tagged with p4tc. We have a similar workflow for the sanitizer for example (https://github.com/p4lang/p4c/blob/main/.github/workflows/ci-ubuntu-20-sanitizer-nightly.yml)
Sorry for the delay, we had a busy couple of weeks Will get into that as soon as possible
@fruffy please take another look when you have some time
@fruffy please take another look when you have some time
Any major change from the version I approved or was this just the rebase?
@fruffy please take another look when you have some time
Any major change from the version I approved or was this just the rebase?
The biggest changes are running the more heavy tests only on PRs that target P4TC, and stopping these same tests from being run in other circumstances
@vbnogueira lmk when you want this merged.
@vbnogueira lmk when you want this merged.
If it won't cause any issues, the sooner the better
I am fine if you want to merge these right away, as is.
I will point out that the portions of these tests that use ubuntu-20.04 will start failing intermittently during March, 2025, and deterministically on April 1, 2025.
https://github.com/p4lang/p4c/issues/5155
It seems reasonable to me to remove uses of Ubuntu 20.04 in a later PR, after this one is merged.
I am fine if you want to merge these right away, as is.
I will point out that the portions of these tests that use ubuntu-20.04 will start failing intermittently during March, 2025, and deterministically on April 1, 2025.
#5155
It seems reasonable to me to remove uses of Ubuntu 20.04 in a later PR, after this one is merged.
I am also happy if this PR is merged first, and I will update https://github.com/p4lang/p4c/pull/5156 if necessary.
Going ahead and merging this, given the approval and the submitter's desire to have it merged.