-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* tests: fix flaky TestAgent * Apply suggestions from code review Co-authored-by: Jakub Warczarek <jakub.warczarek@konghq.com> * tests: address review comments, cleanup * tests: don't use assertions in goroutines in TestAgent * tests: don't use assertions in goroutines in TestAgent --------- Co-authored-by: Jakub Warczarek <jakub.warczarek@konghq.com>
- Loading branch information
1 parent
31b1ba2
commit 11d1c90
Showing
8 changed files
with
316 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package clock | ||
|
||
import "time" | ||
|
||
type System struct{} | ||
|
||
func (System) Now() time.Time { return time.Now() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package clock | ||
|
||
import "time" | ||
|
||
const ( | ||
// This is irrelevant for the ticker, but we need to pass something to NewTicker. | ||
// The reason for this is that the ticker is used in the license agent, which | ||
// uses a non trivial logic to determine the polling period based on the state | ||
// of license retrieval. | ||
// This might be changed in the future if it doesn't fit the future needs. | ||
initialTickerDuration = 1000 * time.Hour | ||
) | ||
|
||
func NewTicker() *TimeTicker { | ||
return &TimeTicker{ | ||
ticker: time.NewTicker(initialTickerDuration), | ||
} | ||
} | ||
|
||
type TimeTicker struct { | ||
ticker *time.Ticker | ||
} | ||
|
||
func (t *TimeTicker) Stop() { | ||
t.ticker.Stop() | ||
} | ||
|
||
func (t *TimeTicker) Channel() <-chan time.Time { | ||
return t.ticker.C | ||
} | ||
|
||
func (t *TimeTicker) Reset(d time.Duration) { | ||
t.ticker.Reset(d) | ||
} |
Oops, something went wrong.