(t *testing.T)
| 1792 | } |
| 1793 | |
| 1794 | func 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, |
nothing calls this directly
no test coverage detected
searching dependent graphs…