Skip to content
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

CI: Verifier tests: Keep generated object files and logs on test failure #25862

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests-datapath-verifier.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ jobs:
if: ${{ !success() }}
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: datapath-verifier
name: datapath-verifier_${{ matrix.kernel }}
path: datapath-verifier
retention-days: 5

Expand Down
23 changes: 16 additions & 7 deletions test/verifier/verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ func TestVerifier(t *testing.T) {
kernelVersion, source := getCIKernelVersion(t)
t.Logf("CI kernel version: %s (%s)", kernelVersion, source)

cmd := exec.Command("make", "-C", "bpf/", "clean")
cmd.Dir = *ciliumBasePath
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("Failed to clean bpf objects: %v\ncommand output: %s", err, out)
}

for _, bpfProgram := range []struct {
name string
macroName string
Expand All @@ -112,6 +118,8 @@ func TestVerifier(t *testing.T) {
macroName: "MAX_LB_OPTIONS",
},
} {
initObjFile := path.Join(*ciliumBasePath, "bpf", fmt.Sprintf("%s.o", bpfProgram.name))

file, err := os.Open(getDatapathConfigFile(t, kernelVersion, bpfProgram.name))
if err != nil {
t.Fatalf("Unable to open list of datapath configurations for %s: %v", bpfProgram.name, err)
Expand All @@ -124,12 +132,6 @@ func TestVerifier(t *testing.T) {

name := fmt.Sprintf("%s_%d", bpfProgram.name, i)
t.Run(name, func(t *testing.T) {
cmd := exec.Command("make", "-C", "bpf/", "clean")
cmd.Dir = *ciliumBasePath
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("Failed to clean bpf objects: %v\ncommand output: %s", err, out)
}

cmd = exec.Command("make", "-C", "bpf", fmt.Sprintf("%s.o", bpfProgram.name))
cmd.Dir = *ciliumBasePath
cmd.Env = append(cmd.Env,
Expand All @@ -140,8 +142,15 @@ func TestVerifier(t *testing.T) {
t.Fatalf("Failed to compile %s bpf objects: %v\ncommand output: %s", bpfProgram.name, err, out)
}

objFile := path.Join(*ciliumBasePath, "bpf", name+".o")
// Rename object file to avoid subsequent runs to overwrite it,
// so we can keep it for CI's artifact upload.
if err = os.Rename(initObjFile, objFile); err != nil {
t.Fatalf("Failed to rename %s to %s: %v", initObjFile, objFile, err)
}

// Parse the compiled object into a CollectionSpec.
spec, err := bpf.LoadCollectionSpec(path.Join(*ciliumBasePath, "bpf", fmt.Sprintf("%s.o", bpfProgram.name)))
spec, err := bpf.LoadCollectionSpec(objFile)
if err != nil {
t.Fatal(err)
}
Expand Down