Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

packetbeat/route: fix test failure on Windows 2022 #39822

Merged
merged 4 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ The list below covers the major changes between 7.0.0-rc2 and main only.
- Fix copy arguments for strict aligned architectures. {pull}36976[36976]
- Fix panic when more than 32767 pipeline clients are active. {issue}38197[38197] {pull}38556[38556]
- Skip flakey metrics test on windows in filebeat httpjson input. {issue}39676[39676] {pull}39678[39678]
- Fix flakey test on Windows 2022 in packetbeat/route. {issue}39698[39698] {pull}39822[39822]

==== Added

Expand Down
1 change: 0 additions & 1 deletion packetbeat/route/route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
)

func TestDefault(t *testing.T) {
t.Skip("Flaky test: https://github.com/elastic/beats/issues/39698")
for _, family := range []int{syscall.AF_INET, syscall.AF_INET6} {
wantIface, wantIndex, wantErr := defaultRoute(family)
if wantErr != nil && wantErr != ErrNotFound {
Expand Down
9 changes: 8 additions & 1 deletion packetbeat/route/route_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func defaultRoute(af int) (name string, index int, err error) {
for inTable := false; sc.Scan(); {
f := strings.Fields(sc.Text())
if len(f) == 0 {
if inTable {
break
}
continue
}
if !inTable {
Expand Down Expand Up @@ -94,6 +97,9 @@ func defaultRoute(af int) (name string, index int, err error) {
for inTable := false; sc.Scan(); {
f := fieldsN(sc.Text(), 5)
if len(f) == 0 {
if inTable {
break
}
continue
}
if !inTable {
Expand Down Expand Up @@ -152,6 +158,7 @@ func fieldsN(s string, n int) []string {
}
var f []string
for s != "" {
l := len(s)
for i, r := range s {
if unicode.IsSpace(r) {
f = append(f, s[:i])
Expand All @@ -165,7 +172,7 @@ func fieldsN(s string, n int) []string {
break
}
}
if len(f) == n-1 {
if len(f) == n-1 || len(s) == l {
break
}
}
Expand Down
Loading