Fix missing timeouts in vsphere input (#4840)
This commit is contained in:
committed by
Daniel Nelson
parent
bde73d8328
commit
c117ed624d
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -229,6 +230,27 @@ func TestWorkerPool(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTimeout(t *testing.T) {
|
||||
m, s, err := createSim()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer m.Remove()
|
||||
defer s.Close()
|
||||
|
||||
var acc testutil.Accumulator
|
||||
v := defaultVSphere()
|
||||
v.Vcenters = []string{s.URL.String()}
|
||||
v.Timeout = internal.Duration{Duration: 1 * time.Nanosecond}
|
||||
require.NoError(t, v.Start(nil)) // We're not using the Accumulator, so it can be nil.
|
||||
defer v.Stop()
|
||||
require.NoError(t, v.Gather(&acc))
|
||||
|
||||
// The accumulator must contain exactly one error and it must be a deadline exceeded.
|
||||
require.Equal(t, 1, len(acc.Errors))
|
||||
require.True(t, strings.Contains(acc.Errors[0].Error(), "context deadline exceeded"))
|
||||
}
|
||||
|
||||
func TestAll(t *testing.T) {
|
||||
m, s, err := createSim()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user