1
0

Other: Increase integration test timeouts

This commit is contained in:
James Houlahan
2022-10-20 14:14:08 +02:00
parent 1729c085c7
commit c20143c212
3 changed files with 16 additions and 26 deletions

View File

@ -20,7 +20,6 @@ package tests
import ( import (
"fmt" "fmt"
"strings" "strings"
"time"
"github.com/bradenaw/juniper/iterator" "github.com/bradenaw/juniper/iterator"
"github.com/bradenaw/juniper/xslices" "github.com/bradenaw/juniper/xslices"
@ -161,11 +160,9 @@ func (s *scenario) imapClientSeesTheFollowingMailboxInfo(clientID string, table
} }
func (s *scenario) imapClientEventuallySeesTheFollowingMailboxInfo(clientID string, table *godog.Table) error { func (s *scenario) imapClientEventuallySeesTheFollowingMailboxInfo(clientID string, table *godog.Table) error {
return eventually( return eventually(func() error {
func() error { return s.imapClientSeesTheFollowingMailboxInfo(clientID, table) }, return s.imapClientSeesTheFollowingMailboxInfo(clientID, table)
5*time.Second, })
100*time.Millisecond,
)
} }
func (s *scenario) imapClientSeesTheFollowingMailboxInfoForMailbox(clientID, mailbox string, table *godog.Table) error { func (s *scenario) imapClientSeesTheFollowingMailboxInfoForMailbox(clientID, mailbox string, table *godog.Table) error {
@ -299,11 +296,9 @@ func (s *scenario) imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox
} }
func (s *scenario) imapClientEventuallySeesTheFollowingMessagesInMailbox(clientID, mailbox string, table *godog.Table) error { func (s *scenario) imapClientEventuallySeesTheFollowingMessagesInMailbox(clientID, mailbox string, table *godog.Table) error {
return eventually( return eventually(func() error {
func() error { return s.imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox, table) }, return s.imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox, table)
5*time.Second, })
500*time.Millisecond,
)
} }
func (s *scenario) imapClientSeesMessagesInMailbox(clientID string, count int, mailbox string) error { func (s *scenario) imapClientSeesMessagesInMailbox(clientID string, count int, mailbox string) error {
@ -322,11 +317,9 @@ func (s *scenario) imapClientSeesMessagesInMailbox(clientID string, count int, m
} }
func (s *scenario) imapClientEventuallySeesMessagesInMailbox(clientID string, count int, mailbox string) error { func (s *scenario) imapClientEventuallySeesMessagesInMailbox(clientID string, count int, mailbox string) error {
return eventually( return eventually(func() error {
func() error { return s.imapClientSeesMessagesInMailbox(clientID, count, mailbox) }, return s.imapClientSeesMessagesInMailbox(clientID, count, mailbox)
5*time.Second, })
500*time.Millisecond,
)
} }
func (s *scenario) imapClientMarksMessageAsDeleted(clientID string, seq int) error { func (s *scenario) imapClientMarksMessageAsDeleted(clientID string, seq int) error {

View File

@ -166,19 +166,19 @@ func matchMailboxes(have, want []Mailbox) error {
return nil return nil
} }
func eventually(condition func() error, waitFor, tick time.Duration) error { //nolint:unparam func eventually(condition func() error) error {
ch := make(chan error, 1) ch := make(chan error, 1)
timer := time.NewTimer(waitFor) timer := time.NewTimer(10 * time.Second)
defer timer.Stop() defer timer.Stop()
ticker := time.NewTicker(tick) ticker := time.NewTicker(100 * time.Millisecond)
defer ticker.Stop() defer ticker.Stop()
for tick := ticker.C; ; { for tick := ticker.C; ; {
select { select {
case <-timer.C: case <-timer.C:
return fmt.Errorf("timed out after %v", waitFor) return fmt.Errorf("timed out")
case <-tick: case <-tick:
tick = nil tick = nil

View File

@ -21,7 +21,6 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"time"
"github.com/cucumber/godog" "github.com/cucumber/godog"
"github.com/google/uuid" "github.com/google/uuid"
@ -222,11 +221,9 @@ func (s *scenario) userIsListedAndConnected(username string) error {
} }
func (s *scenario) userIsEventuallyListedAndConnected(username string) error { func (s *scenario) userIsEventuallyListedAndConnected(username string) error {
return eventually( return eventually(func() error {
func() error { return s.userIsListedAndConnected(username) }, return s.userIsListedAndConnected(username)
5*time.Second, })
100*time.Millisecond,
)
} }
func (s *scenario) userIsListedButNotConnected(username string) error { func (s *scenario) userIsListedButNotConnected(username string) error {