integrationtest/TestBiolatency: Validate json output
@@ -27,6 +27,7 @@ import (
"time"
. "github.com/inspektor-gadget/inspektor-gadget/integration"
+ bioprofileTypes "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgets/profile/block-io/types"
cpuprofileTypes "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgets/profile/cpu/types"
processCollectorTypes "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgets/snapshot/process/types"
socketCollectorTypes "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgets/snapshot/socket/types"
@@ -371,8 +372,19 @@ func TestBiolatency(t *testing.T) {
commands := []*Command{
{
Name: "RunBiolatencyGadget",
- Cmd: "$KUBECTL_GADGET profile block-io --node $(kubectl get node --no-headers | cut -d' ' -f1 | head -1) --timeout 15",
- ExpectedRegexp: `usecs\s+:\s+count\s+distribution`,
+ Cmd: "$KUBECTL_GADGET profile block-io --node $(kubectl get node --no-headers | cut -d' ' -f1 | head -1) --timeout 15 -o json",
+ ExpectedOutputFn: func(output string) error {
+ expectedEntry := &bioprofileTypes.Report{
+ ValType: "usecs",
+ }
+
+ normalize := func(e *bioprofileTypes.Report) {
+ e.Data = nil
+ e.Time = ""
+ }
+
+ return ExpectEntriesToMatch(output, normalize, expectedEntry)
+ },
},
}
