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

Fix integration test timeouts on Windows #3949

Merged
merged 14 commits into from
Jan 22, 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
4 changes: 3 additions & 1 deletion pkg/core/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ func (i *Info) StopWait() error {
return err
}

// Wait returns a channel that will send process state once it exits.
// Wait returns a channel that will send process state once it exits. Each
// call to Wait() creates a goroutine. Failure to read from the returned
// channel will leak this goroutine.
func (i *Info) Wait() <-chan *os.ProcessState {
ch := make(chan *os.ProcessState)

Expand Down
23 changes: 13 additions & 10 deletions pkg/testing/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,10 @@ func (f *Fixture) RunBeat(ctx context.Context) error {
return fmt.Errorf("failed to spawn %s: %w", f.binaryName, err)
}

procWaitCh := proc.Wait()
killProc := func() {
_ = proc.Kill()
<-proc.Wait()
<-procWaitCh
}

var doneChan <-chan time.Time
Expand All @@ -328,7 +329,7 @@ func (f *Fixture) RunBeat(ctx context.Context) error {
case <-ctx.Done():
killProc()
return ctx.Err()
case ps := <-proc.Wait():
case ps := <-procWaitCh:
if stopping {
return nil
}
Expand Down Expand Up @@ -384,9 +385,10 @@ func RunProcess(t *testing.T,
return fmt.Errorf("failed to spawn %q: %w", processPath, err)
}

procWaitCh := proc.Wait()
killProc := func() {
_ = proc.Kill()
<-proc.Wait()
<-procWaitCh
}

var doneChan <-chan time.Time
Expand All @@ -400,7 +402,7 @@ func RunProcess(t *testing.T,
case <-ctx.Done():
killProc()
return ctx.Err()
case ps := <-proc.Wait():
case ps := <-procWaitCh:
if stopping {
return nil
}
Expand Down Expand Up @@ -503,11 +505,6 @@ func (f *Fixture) RunWithClient(ctx context.Context, shouldWatchState bool, stat
return fmt.Errorf("failed to spawn %s: %w", f.binaryName, err)
}

killProc := func() {
_ = proc.Kill()
<-proc.Wait()
}

if shouldWatchState {
agentClient = client.New(client.WithAddress(cAddr))
f.setClient(agentClient)
Expand All @@ -520,13 +517,19 @@ func (f *Fixture) RunWithClient(ctx context.Context, shouldWatchState bool, stat
doneChan = time.After(f.runLength)
}

procWaitCh := proc.Wait()
killProc := func() {
_ = proc.Kill()
<-procWaitCh
}

stopping := false
for {
select {
case <-ctx.Done():
killProc()
return ctx.Err()
case ps := <-proc.Wait():
case ps := <-procWaitCh:
if stopping {
return nil
}
Expand Down
7 changes: 0 additions & 7 deletions testing/integration/apm_propagation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"fmt"
"io"
"net/http"
"runtime"
"strings"
"testing"
"text/template"
Expand Down Expand Up @@ -57,12 +56,6 @@ func TestAPMConfig(t *testing.T) {
Group: Default,
Stack: &define.Stack{},
})

if runtime.GOOS == "windows" {
// This test hangs indefinitely on Windows. Root cause is TBD.
t.Skip("Flaky test: https://github.com/elastic/ingest-dev/issues/2668")
}

f, err := define.NewFixture(t, define.Version())
require.NoError(t, err)

Expand Down
Loading