Skip to content

Commit

Permalink
Add tests for latest ipv6 related fixes
Browse files Browse the repository at this point in the history
Add tests for elastic#4442
  • Loading branch information
exekias committed Jun 8, 2017
1 parent 1426260 commit 33a1e5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions packetbeat/procs/procs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,7 @@ func TestFindSocketsOfPid(t *testing.T) {
}

func TestParse_Proc_Net_Tcp(t *testing.T) {
file, err := os.Open("../tests/files/proc_net_tcp.txt")
if err != nil {
t.Fatalf("Opening ../tests/files/proc_net_tcp.txt: %s", err)
}
socketInfo, err := parseProcNetTCP(file, false)
socketInfo, err := socketsFromProc("../tests/files/proc_net_tcp.txt", false)
if err != nil {
t.Fatalf("Parse_Proc_Net_Tcp: %s", err)
}
Expand All @@ -229,11 +225,7 @@ func TestParse_Proc_Net_Tcp(t *testing.T) {
}

func TestParse_Proc_Net_Tcp6(t *testing.T) {
file, err := os.Open("../tests/files/proc_net_tcp6.txt")
if err != nil {
t.Fatalf("Opening ../tests/files/proc_net_tcp6.txt: %s", err)
}
socketInfo, err := parseProcNetTCP(file, true)
socketInfo, err := socketsFromProc("../tests/files/proc_net_tcp6.txt", true)
if err != nil {
t.Fatalf("Parse_Proc_Net_Tcp: %s", err)
}
Expand All @@ -243,8 +235,10 @@ func TestParse_Proc_Net_Tcp6(t *testing.T) {
if socketInfo[5].srcIP.String() != "::" {
t.Error("Failed to parse source IP address ::, got instead", socketInfo[5].srcIP.String())
}
// TODO add an example of a 'real' IPv6 address
if socketInfo[5].srcPort != 59497 {
t.Error("Failed to parse source port 59497, got instead", socketInfo[5].srcPort)
}
if socketInfo[4].srcIP.String() != "2001:db8::123:ffff:89ab:cdef" {
t.Error("Failed to parse source IP address 2001:db8::123:ffff:89ab:cdef, got instead", socketInfo[4].srcIP.String())
}
}
2 changes: 1 addition & 1 deletion packetbeat/tests/files/proc_net_tcp6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
1: 00000000000000000000000001000000:0277 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 3465486 1 ffff88041a77aa40 100 0 0 10 0
2: 00000000000000000000000001000000:1538 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 131 0 25936 1 ffff8800c541c080 100 0 0 10 0
3: 00000000000000000000000001000000:0019 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 23925 1 ffff8800c541c900 100 0 0 10 0
4: 00000000000000000000000000000000:445C 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 33807 1 ffff88041a77a1c0 100 0 0 10 0
4: B80D012000000000FFFF2301EFCDAB89:445C 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 33807 1 ffff88041a77a1c0 100 0 0 10 0
5: 00000000000000000000000000000000:E869 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 104 0 15881 1 ffff8800c541d180 100 0 0 10 0

0 comments on commit 33a1e5d

Please sign in to comment.