mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-01-07 14:05:50 +00:00
Fix a bug in the e2e tests
When the test was going to fail, a goroutine would accidentally block on writing to an unbuffered channel, and the spawnTestGoroutine helper would wait for that goroutine to end on cleanup, causing the test to hang forever while it was trying to fail.
This commit is contained in:
@@ -181,7 +181,7 @@ func TestE2EFullIntegration(t *testing.T) { // nolint:gocyclo
|
||||
})
|
||||
|
||||
// Start a background goroutine to read stderr from the CLI and parse out the login URL.
|
||||
loginURLChan := make(chan string)
|
||||
loginURLChan := make(chan string, 1)
|
||||
spawnTestGoroutine(t, func() (err error) {
|
||||
defer func() {
|
||||
closeErr := stderrPipe.Close()
|
||||
@@ -198,7 +198,7 @@ func TestE2EFullIntegration(t *testing.T) { // nolint:gocyclo
|
||||
for scanner.Scan() {
|
||||
loginURL, err := url.Parse(strings.TrimSpace(scanner.Text()))
|
||||
if err == nil && loginURL.Scheme == "https" {
|
||||
loginURLChan <- loginURL.String()
|
||||
loginURLChan <- loginURL.String() // this channel is buffered so this will not block
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@ func TestE2EFullIntegration(t *testing.T) { // nolint:gocyclo
|
||||
})
|
||||
|
||||
// Start a background goroutine to read stdout from kubectl and return the result as a string.
|
||||
kubectlOutputChan := make(chan string)
|
||||
kubectlOutputChan := make(chan string, 1)
|
||||
spawnTestGoroutine(t, func() (err error) {
|
||||
defer func() {
|
||||
closeErr := stdoutPipe.Close()
|
||||
@@ -222,7 +222,7 @@ func TestE2EFullIntegration(t *testing.T) { // nolint:gocyclo
|
||||
return err
|
||||
}
|
||||
t.Logf("kubectl output:\n%s\n", output)
|
||||
kubectlOutputChan <- string(output)
|
||||
kubectlOutputChan <- string(output) // this channel is buffered so this will not block
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user