diff --git a/pkg/api/config_test.go b/pkg/api/config_test.go index f691085983f5a..a2f7fd1378d50 100644 --- a/pkg/api/config_test.go +++ b/pkg/api/config_test.go @@ -8,8 +8,7 @@ import ( "testing" "github.com/go-openapi/spec" - - "github.com/cilium/cilium/pkg/checker" + "github.com/stretchr/testify/require" ) func TestParseSpecPaths(t *testing.T) { @@ -110,9 +109,7 @@ func TestParseSpecPaths(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { got := parseSpecPaths(tc.paths) - if ok, msg := checker.DeepEqual(got, tc.expected); !ok { - t.Errorf("case %q failed:\n%s", tc.name, msg) - } + require.Equalf(t, tc.expected, got, "case %q failed", tc.name) }) } } @@ -179,12 +176,8 @@ func TestAllowedFlagsToDeniedPaths(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { got, err := generateDeniedAPIEndpoints(sampleFlags, tc.allowed) - if ok, msg := checker.DeepEqual(got, tc.expected); !ok { - t.Errorf("case %q failed:\n%s", tc.name, msg) - } - if ok, msg := checker.DeepEqual(errors.Unwrap(err), tc.expectedErr); !ok { - t.Errorf("case %q error mismatch:\n%s", tc.name, msg) - } + require.Equalf(t, tc.expected, got, "case %q failed", tc.name) + require.Equalf(t, tc.expectedErr, errors.Unwrap(err), "case %q failed", tc.name) }) } diff --git a/pkg/hubble/parser/sock/parser_test.go b/pkg/hubble/parser/sock/parser_test.go index 4afdd02d28551..f22298a71d8ee 100644 --- a/pkg/hubble/parser/sock/parser_test.go +++ b/pkg/hubble/parser/sock/parser_test.go @@ -14,11 +14,11 @@ import ( "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" flowpb "github.com/cilium/cilium/api/v1/flow" "github.com/cilium/cilium/pkg/byteorder" cgroupManager "github.com/cilium/cilium/pkg/cgroups/manager" - "github.com/cilium/cilium/pkg/checker" parserErrors "github.com/cilium/cilium/pkg/hubble/parser/errors" "github.com/cilium/cilium/pkg/hubble/parser/getters" "github.com/cilium/cilium/pkg/hubble/testutils" @@ -418,8 +418,7 @@ func TestDecodeSockEvent(t *testing.T) { assert.ErrorContains(t, err, tc.errMsg) } else { assert.Nil(t, err) - ok, msg := checker.DeepEqual(flow, tc.flow) - assert.True(t, ok, msg) + require.EqualValues(t, tc.flow, flow) } }) } diff --git a/pkg/policy/mapstate_test.go b/pkg/policy/mapstate_test.go index 6b006375518b1..ba8850336294c 100644 --- a/pkg/policy/mapstate_test.go +++ b/pkg/policy/mapstate_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/cilium/cilium/pkg/checker" "github.com/cilium/cilium/pkg/identity" "github.com/cilium/cilium/pkg/identity/cache" "github.com/cilium/cilium/pkg/labels" @@ -2013,7 +2012,7 @@ func TestMapState_AddVisibilityKeys(t *testing.T) { } tt.ms.ForEach(func(k Key, v MapStateEntry) bool { if v2, ok := old.Old[k]; ok { - if equals, _ := checker.DeepEqual(v2, v); !equals { + if !assert.ObjectsAreEqual(v2, v) { if !v.DatapathEqual(&v2) { wantAdds[k] = struct{}{} } diff --git a/test/runtime/fqdn.go b/test/runtime/fqdn.go index 6b9730cbd4343..ef2026826d23b 100644 --- a/test/runtime/fqdn.go +++ b/test/runtime/fqdn.go @@ -13,9 +13,9 @@ import ( "time" . "github.com/onsi/gomega" + "github.com/stretchr/testify/assert" "github.com/cilium/cilium/api/v1/models" - "github.com/cilium/cilium/pkg/checker" . "github.com/cilium/cilium/test/ginkgo-ext" "github.com/cilium/cilium/test/helpers" "github.com/cilium/cilium/test/helpers/constants" @@ -1125,8 +1125,8 @@ var _ = Describe("RuntimeAgentFQDNPolicies", func() { ipcacheAfter, err := vm.BpfIPCacheList(true) Expect(err).To(BeNil(), "ipcache can not be dumped") GinkgoPrint(fmt.Sprintf("Local scope identities in IP cache after Cilium restart: %v", ipcacheAfter)) - equal, diff := checker.DeepEqual(ipcacheBefore, ipcacheAfter) - Expect(equal).To(BeTrue(), "CIDR identities were not restored correctly: %s", diff) + equal := assert.ObjectsAreEqualValues(ipcacheBefore, ipcacheAfter) + Expect(equal).To(BeTrue(), "CIDR identities were not restored correctly") // Reapply FQDN policy and check that selectors still have same ids _, err = vm.PolicyRenderAndImport(policy) @@ -1141,8 +1141,9 @@ var _ = Describe("RuntimeAgentFQDNPolicies", func() { By("Dumping IP cache after the DNS policy is imported after restart") ipcacheAfterDNSPolicy, err := vm.BpfIPCacheList(true) Expect(err).To(BeNil(), "ipcache can not be dumped") - equal, diff = checker.DeepEqual(ipcacheBefore, ipcacheAfterDNSPolicy) - Expect(equal).To(BeTrue(), "CIDR identities changed after policy import: %s", diff) + equal = assert.ObjectsAreEqualValues(ipcacheBefore, ipcacheAfterDNSPolicy) + Expect(equal).To(BeTrue(), "CIDR identities changed after policy import") + GinkgoPrint(fmt.Sprintf("Local scope identities in IP cache after re-import of DNS policy: %v", ipcacheAfterDNSPolicy)) })