Skip to content

Commit

Permalink
e2e: configurable query convergence delay
Browse files Browse the repository at this point in the history
  • Loading branch information
snormore committed May 9, 2023
1 parent 6608ef5 commit d0d0b2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
15 changes: 8 additions & 7 deletions pkg/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/e2e/test_convergence.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit d0d0b2a

Please sign in to comment.