MCPcopy
hub / github.com/cilium/cilium / TestAddRemoveEndpoint

Function TestAddRemoveEndpoint

pkg/mcastmanager/mcastmanager_test.go:16–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestAddRemoveEndpoint(t *testing.T) {
17 logger := hivetest.Logger(t)
18 ifaces, err := safenetlink.LinkList()
19 require.NoError(t, err)
20
21 if len(ifaces) == 0 {
22 t.Skip("no interfaces to test")
23 }
24
25 mgr := New(logger, ifaces[0].Attrs().Name)
26
27 // Add first endpoint
28 mgr.AddAddress(netip.MustParseAddr("f00d::1234"))
29
30 require.Len(t, mgr.state, 1)
31 _, ok := mgr.state[netip.MustParseAddr("ff02::1:ff00:1234")]
32 require.True(t, ok)
33
34 // Add another endpoint that shares the same maddr
35 mgr.AddAddress(netip.MustParseAddr("f00d:aabb::1234"))
36
37 require.Len(t, mgr.state, 1)
38
39 // Remove the first endpoint
40 mgr.RemoveAddress(netip.MustParseAddr("f00d::1234"))
41
42 require.Len(t, mgr.state, 1)
43 _, ok = mgr.state[netip.MustParseAddr("ff02::1:ff00:1234")]
44 require.True(t, ok)
45
46 // Remove the second endpoint
47 mgr.RemoveAddress(netip.MustParseAddr("f00d:aabb::1234"))
48
49 require.Empty(t, mgr.state)
50 _, ok = mgr.state[netip.MustParseAddr("ff02::1:ff00:1234")]
51 require.False(t, ok)
52}
53
54func TestAddRemoveNil(t *testing.T) {
55 logger := hivetest.Logger(t)

Callers

nothing calls this directly

Calls 8

LinkListFunction · 0.92
AttrsMethod · 0.80
AddAddressMethod · 0.80
RemoveAddressMethod · 0.80
NewFunction · 0.70
LoggerMethod · 0.65
LenMethod · 0.65
EmptyMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…