Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <jcai@gitlab.com>2022-05-18 17:03:04 +0300
committerJohn Cai <jcai@gitlab.com>2022-05-18 17:03:04 +0300
commitb34bf8dde1ae11c809225826e6fe20cf8b425a78 (patch)
treef1d506b570f7f0d2d3f0e33dda201b7023fe676b
parent03a411532099f31aabf477b49adc031c2a049b78 (diff)
parent83d9978d8003b0b30ad7e8b0c2a904cf8a9729a0 (diff)
Merge branch 'pks-commandstatshandler-flake' into 'master'
commandstatshandler: Fix flaky test caused by Git version check Closes #4239 See merge request gitlab-org/gitaly!4568
-rw-r--r--internal/middleware/commandstatshandler/commandstatshandler_test.go3
-rw-r--r--internal/testhelper/testhelper.go4
2 files changed, 5 insertions, 2 deletions
diff --git a/internal/middleware/commandstatshandler/commandstatshandler_test.go b/internal/middleware/commandstatshandler/commandstatshandler_test.go
index 9369cbb8e..fbc61b6ed 100644
--- a/internal/middleware/commandstatshandler/commandstatshandler_test.go
+++ b/internal/middleware/commandstatshandler/commandstatshandler_test.go
@@ -85,6 +85,8 @@ func TestInterceptor(t *testing.T) {
require.NoError(t, err)
}()
+ ctx := testhelper.Context(t)
+
tests := []struct {
name string
performRPC func(ctx context.Context, client gitalypb.RefServiceClient)
@@ -135,7 +137,6 @@ func TestInterceptor(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
hook.Reset()
- ctx := testhelper.Context(t)
conn, err := grpc.DialContext(ctx, "", grpc.WithContextDialer(getBufDialer(listener)), grpc.WithInsecure())
require.NoError(t, err)
diff --git a/internal/testhelper/testhelper.go b/internal/testhelper/testhelper.go
index f3a917c70..309c03bad 100644
--- a/internal/testhelper/testhelper.go
+++ b/internal/testhelper/testhelper.go
@@ -160,7 +160,9 @@ func Context(t testing.TB, opts ...ContextOpt) context.Context {
func ContextWithoutCancel(opts ...ContextOpt) context.Context {
ctx := context.Background()
- rnd := mrand.New(mrand.NewSource(time.Now().Unix()))
+ t := time.Now()
+
+ rnd := mrand.New(mrand.NewSource(t.Unix() + int64(t.Nanosecond())))
// Enable use of explicit feature flags. Each feature flag which is checked must have been
// explicitly injected into the context, or otherwise we panic. This is a sanity check to