mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-21 15:45:01 +00:00
attempt to fix flaky TestClientProxyReadOk (#6899)
Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
95bafc8caf
commit
f586082520
1 changed files with 19 additions and 7 deletions
|
@ -3,6 +3,7 @@ package promscrape
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
@ -133,18 +134,29 @@ func TestClientProxyReadOk(t *testing.T) {
|
||||||
defer ps.Close()
|
defer ps.Close()
|
||||||
|
|
||||||
c, err := newClient(ctx, &ScrapeWork{
|
c, err := newClient(ctx, &ScrapeWork{
|
||||||
ScrapeURL: backend.URL,
|
ScrapeURL: backend.URL,
|
||||||
ProxyURL: proxy.MustNewURL(ps.URL),
|
ProxyURL: proxy.MustNewURL(ps.URL),
|
||||||
ScrapeTimeout: 2 * time.Second,
|
// bump timeout for slow CIs
|
||||||
AuthConfig: newTestAuthConfig(t, isBackendTLS, backendAuth),
|
ScrapeTimeout: 5 * time.Second,
|
||||||
ProxyAuthConfig: newTestAuthConfig(t, isProxyTLS, proxyAuth),
|
// force connection re-creating to avoid broken conns in slow CIs
|
||||||
MaxScrapeSize: 16000,
|
DisableKeepAlive: true,
|
||||||
|
AuthConfig: newTestAuthConfig(t, isBackendTLS, backendAuth),
|
||||||
|
ProxyAuthConfig: newTestAuthConfig(t, isProxyTLS, proxyAuth),
|
||||||
|
MaxScrapeSize: 16000,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to create client: %s", err)
|
t.Fatalf("failed to create client: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var bb bytesutil.ByteBuffer
|
var bb bytesutil.ByteBuffer
|
||||||
if err := c.ReadData(&bb); err != nil {
|
err = c.ReadData(&bb)
|
||||||
|
if errors.Is(err, io.EOF) {
|
||||||
|
bb.Reset()
|
||||||
|
// EOF could occur in slow envs, like CI
|
||||||
|
err = c.ReadData(&bb)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
t.Fatalf("unexpected error at ReadData: %s", err)
|
t.Fatalf("unexpected error at ReadData: %s", err)
|
||||||
}
|
}
|
||||||
got, err := io.ReadAll(bb.NewReader())
|
got, err := io.ReadAll(bb.NewReader())
|
||||||
|
|
Loading…
Reference in a new issue