p4c icon indicating copy to clipboard operation
p4c copied to clipboard

First take at p4tc automated tests

Open vbnogueira opened this issue 1 year ago • 4 comments

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

vbnogueira avatar Nov 11 '24 20:11 vbnogueira

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

fruffy avatar Nov 11 '24 22:11 fruffy

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

vbnogueira avatar Nov 12 '24 13:11 vbnogueira

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.

fruffy avatar Dec 18 '24 12:12 fruffy

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

vbnogueira avatar Jan 07 '25 12:01 vbnogueira

@fruffy please take another look when you have some time

vbnogueira avatar Feb 26 '25 10:02 vbnogueira

@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 avatar Feb 27 '25 00:02 fruffy

@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 avatar Feb 27 '25 00:02 vbnogueira

@vbnogueira lmk when you want this merged.

fruffy avatar Mar 03 '25 19:03 fruffy

@vbnogueira lmk when you want this merged.

If it won't cause any issues, the sooner the better

vbnogueira avatar Mar 03 '25 20:03 vbnogueira

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.

jafingerhut avatar Mar 03 '25 20:03 jafingerhut

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.

jafingerhut avatar Mar 03 '25 20:03 jafingerhut

Going ahead and merging this, given the approval and the submitter's desire to have it merged.

jafingerhut avatar Mar 04 '25 03:03 jafingerhut