-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] [pkg/stanza] Mock time functions for flaky TestExcludeOlderTh…
…anFilter (#34174) **Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Similar to #34128. Mocking the time functions to fix flakiness on windows. **Link to tracking Issue:** <Issue number if applicable> #32838 **Testing:** <Describe what testing was performed and which tests were added.> **Documentation:** <Describe the documentation added.> Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
- Loading branch information
Showing
13 changed files
with
59 additions
and
46 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package time // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/stanza/internal/time" | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/jonboulle/clockwork" | ||
) | ||
|
||
var Now = time.Now | ||
var Since = time.Since | ||
|
||
// Clock where Now() always returns a greater value than the previous return value | ||
type AlwaysIncreasingClock struct { | ||
clockwork.FakeClock | ||
} | ||
|
||
func NewAlwaysIncreasingClock() AlwaysIncreasingClock { | ||
return AlwaysIncreasingClock{ | ||
FakeClock: clockwork.NewFakeClock(), | ||
} | ||
} | ||
|
||
func (c AlwaysIncreasingClock) Now() time.Time { | ||
c.FakeClock.Advance(time.Nanosecond) | ||
return c.FakeClock.Now() | ||
} | ||
|
||
func (c AlwaysIncreasingClock) Since(t time.Time) time.Duration { | ||
// ensure that internal c.FakeClock.Now() will return a greater value | ||
c.FakeClock.Advance(time.Nanosecond) | ||
return c.FakeClock.Since(t) | ||
} |
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