From 982a99db42bcf969ac5ff926e273f87bdb5f6488 Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Wed, 14 Jan 2026 10:53:30 +0200 Subject: [PATCH] Sort IPProfile pools in integration test would randomly fail due to how csv loads ippools (by storing into a map first) --- general_tests/ips_it_test.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/general_tests/ips_it_test.go b/general_tests/ips_it_test.go index 3e9193bee..f5157ce4c 100644 --- a/general_tests/ips_it_test.go +++ b/general_tests/ips_it_test.go @@ -21,8 +21,10 @@ along with this program. If not, see package general_tests import ( + "cmp" "net/netip" "reflect" + "slices" "testing" "time" @@ -215,6 +217,9 @@ cgrates.org,IPs2,*string:~*req.Account:1002,,2s,false,20,POOL1,*string:~*req.Des if err != nil { t.Fatal(err) } + slices.SortFunc(profile.Pools, func(a, b *engine.IPPool) int { + return cmp.Compare(a.ID, b.ID) + }) verifyIPProfile(t, &profile, expectedIPs1Profile) err = client.Call(context.Background(), utils.APIerSv1GetIPProfile, @@ -494,11 +499,11 @@ func getIPAllocations(t *testing.T, client *birpc.Client, profileID string) *eng return &allocs } -func verifyAllocatedIP(t *testing.T, got, expected *engine.AllocatedIP) { +func verifyAllocatedIP(t *testing.T, got, want *engine.AllocatedIP) { t.Helper() - if !reflect.DeepEqual(got, expected) { - t.Fatalf("AllocatedIP mismatch:\nExpected: %s\nGot: %s", - utils.ToIJSON(expected), utils.ToIJSON(got)) + if !reflect.DeepEqual(got, want) { + t.Fatalf("AllocatedIP mismatch:\nwant: %s\ngot: %s", + utils.ToJSON(want), utils.ToJSON(got)) } } @@ -543,10 +548,10 @@ func verifyIPAllocation(t *testing.T, client *birpc.Client, profileID, allocID, } } -func verifyIPProfile(t *testing.T, got, expected *engine.IPProfile) { +func verifyIPProfile(t *testing.T, got, want *engine.IPProfile) { t.Helper() - if !reflect.DeepEqual(got, expected) { + if !reflect.DeepEqual(got, want) { t.Fatalf("Profile mismatch:\nwant: %s\ngot: %s", - utils.ToIJSON(expected), utils.ToIJSON(got)) + utils.ToJSON(want), utils.ToJSON(got)) } }