MCPcopy
hub / github.com/cilium/cilium / TestDecode_DropNotify

Function TestDecode_DropNotify

pkg/hubble/parser/threefour/parser_test.go:1794–1952  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1792}
1793
1794func TestDecode_DropNotify(t *testing.T) {
1795 parser, err := New(hivetest.Logger(t), defaultEndpointGetter, nil, nil, nil, nil, nil)
1796 require.NoError(t, err)
1797
1798 getTemplate := func(isL3Device bool) *flowpb.Flow {
1799 template := &flowpb.Flow{
1800 EventType: &flowpb.CiliumEventType{Type: 1},
1801 Summary: flowpb.IPVersion_IPv4.String(),
1802 Type: flowpb.FlowType_L3_L4,
1803 Verdict: flowpb.Verdict_DROPPED,
1804 Source: &flowpb.Endpoint{},
1805 Destination: &flowpb.Endpoint{},
1806 Ethernet: &flowpb.Ethernet{
1807 Source: srcMAC.String(),
1808 Destination: dstMAC.String(),
1809 },
1810 IP: &flowpb.IP{
1811 IpVersion: flowpb.IPVersion_IPv4,
1812 Source: localIP.String(),
1813 Destination: remoteIP.String(),
1814 },
1815 }
1816 if isL3Device {
1817 template.Ethernet = nil
1818 }
1819 return template
1820 }
1821
1822 testCases := []struct {
1823 name string
1824 event monitor.DropNotify
1825 ipTuple ipTuple
1826 want *flowpb.Flow
1827 }{
1828 {
1829 name: "drop_unknown",
1830 event: monitor.DropNotify{
1831 Type: byte(monitorAPI.MessageTypeDrop),
1832 File: 2,
1833 Line: 42,
1834 Version: monitor.DropNotifyVersion2,
1835 },
1836 ipTuple: egressTuple,
1837 want: &flowpb.Flow{
1838 Source: &flowpb.Endpoint{ID: 1234},
1839 File: &flowpb.FileInfo{
1840 Name: "bpf_lxc.c",
1841 Line: 42,
1842 },
1843 },
1844 },
1845 {
1846 name: "drop_egress",
1847 event: monitor.DropNotify{
1848 Type: byte(monitorAPI.MessageTypeDrop),
1849 Source: localEP,
1850 File: 6,
1851 Line: 12,

Callers

nothing calls this directly

Calls 13

CreateL3L4PayloadFunction · 0.92
NewFunction · 0.70
LoggerMethod · 0.65
StringMethod · 0.65
RunMethod · 0.65
DecodeMethod · 0.65
IsL3DeviceMethod · 0.45
AsSliceMethod · 0.45
CloneMethod · 0.45
MergeMethod · 0.45
FatalfMethod · 0.45
DiffMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…