From d0d0b2a20ecef50d3bc8fb692439af1c913a12a7 Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Tue, 9 May 2023 09:59:39 -0400 Subject: [PATCH] e2e: configurable query convergence delay --- pkg/e2e/e2e.go | 15 ++++++++------- pkg/e2e/test_convergence.go | 8 +++----- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/e2e/e2e.go b/pkg/e2e/e2e.go index dc943d77..d0c4f0ab 100644 --- a/pkg/e2e/e2e.go +++ b/pkg/e2e/e2e.go @@ -27,13 +27,14 @@ type E2E struct { } type Options struct { - APIURLs []string `long:"api-url" env:"XMTP_API_URLS" description:"XMTP node API URLs" default:"http://localhost"` - ClientsPerURL int `long:"clients-per-url" description:"Number of clients for each API URL" default:"1"` - MessagePerClient int `long:"messages-per-client" description:"Number of messages to publish for each client" default:"3"` - Continuous bool `long:"continuous" description:"Run continuously"` - ExitOnError bool `long:"exit-on-error" description:"Exit on error if running continuously"` - RunDelay time.Duration `long:"delay" description:"Delay between runs (in seconds)" default:"5s"` - AdminPort uint `long:"admin-port" description:"Admin HTTP server listen port" default:"7777"` + APIURLs []string `long:"api-url" env:"XMTP_API_URLS" description:"XMTP node API URLs" default:"http://localhost"` + ClientsPerURL int `long:"clients-per-url" description:"Number of clients for each API URL" default:"1"` + MessagePerClient int `long:"messages-per-client" description:"Number of messages to publish for each client" default:"3"` + Continuous bool `long:"continuous" description:"Run continuously"` + ExitOnError bool `long:"exit-on-error" description:"Exit on error if running continuously"` + RunDelay time.Duration `long:"delay" description:"Delay between runs" default:"5s"` + AdminPort uint `long:"admin-port" description:"Admin HTTP server listen port" default:"7777"` + QueryConvergenceDelay time.Duration `long:"query-convergence-delay" description:"Delay between query convergence checks" default:"10ms"` GitCommit string } diff --git a/pkg/e2e/test_convergence.go b/pkg/e2e/test_convergence.go index 8f9bdd93..7d4a3371 100644 --- a/pkg/e2e/test_convergence.go +++ b/pkg/e2e/test_convergence.go @@ -180,7 +180,7 @@ func (e *E2E) testConvergence(name string) error { go func() { defer queryGroup.Done() - err := expectQueryMessagesEventually(ctx, client, []string{topic}, envs) + err := e.expectQueryMessagesEventually(ctx, client, []string{topic}, envs) if err != nil { duration := time.Since(publishStart) e.log.Error("error querying", zap.Error(err), zap.Duration("duration", duration)) @@ -238,10 +238,8 @@ func isErrClosedConnection(err error) bool { return errors.Is(err, io.EOF) || strings.Contains(err.Error(), "closed network connection") || strings.Contains(err.Error(), "response body closed") } -func expectQueryMessagesEventually(ctx context.Context, client apiclient.Client, contentTopics []string, expectedEnvs []*messagev1.Envelope) error { +func (e *E2E) expectQueryMessagesEventually(ctx context.Context, client apiclient.Client, contentTopics []string, expectedEnvs []*messagev1.Envelope) error { timeout := 10 * time.Second - delay := 10 * time.Millisecond - // TODO: higher delay for production? started := time.Now() for { envs, err := query(ctx, client, contentTopics) @@ -262,7 +260,7 @@ func expectQueryMessagesEventually(ctx context.Context, client apiclient.Client, } return fmt.Errorf("timeout waiting for query expectation with no diff") } - time.Sleep(delay) + time.Sleep(e.opts.QueryConvergenceDelay) } return nil }