Merge pull request #48417 from adams1mon/try-fix-flaky-plugin-client-test

Increase flaky test sleep, replace deprecated assert
This commit is contained in:
Paweł Gronowski
2024-10-22 13:06:51 +02:00
committed by GitHub

View File

@@ -9,7 +9,6 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"os"
"strings"
"testing"
"time"
@@ -169,15 +168,21 @@ func TestNewClientWithTimeout(t *testing.T) {
m := Manifest{[]string{"VolumeDriver", "NetworkDriver"}}
mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) {
time.Sleep(20 * time.Millisecond)
time.Sleep(50 * time.Millisecond)
io.Copy(w, r.Body)
})
timeout := 10 * time.Millisecond
c, _ := NewClientWithTimeout(addr, &tlsconfig.Options{InsecureSkipVerify: true}, timeout)
var output Manifest
err := c.CallWithOptions("Test.Echo", m, &output, func(opts *RequestOpts) { opts.testTimeOut = 1 })
assert.ErrorType(t, err, os.IsTimeout)
var tErr interface {
Timeout() bool
}
if assert.Check(t, errors.As(err, &tErr), "want timeout error, got %T", err) {
assert.Check(t, tErr.Timeout())
}
}
func TestClientStream(t *testing.T) {