Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr committed Jan 8, 2025
1 parent 4c444b2 commit b436b44
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
3 changes: 1 addition & 2 deletions warehouse/router/identities.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

"github.com/rudderlabs/rudder-server/rruntime"
"github.com/rudderlabs/rudder-server/utils/misc"
"github.com/rudderlabs/rudder-server/utils/timeutil"
warehouseutils "github.com/rudderlabs/rudder-server/warehouse/utils"
)

Expand Down Expand Up @@ -309,7 +308,7 @@ func (r *Router) initPrePopulateDestIdentitiesUpload(warehouse model.Warehouse)
RETURNING id
`, warehouseutils.WarehouseUploadsTable)

now := timeutil.Now()
now := r.now()
row := r.db.QueryRow(
sqlStatement,
warehouse.Source.ID,
Expand Down
2 changes: 1 addition & 1 deletion warehouse/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func (r *Router) handlePriorityForWaitingUploads(ctx context.Context, warehouse

func (r *Router) uploadStartAfterTime() time.Time {
if r.config.enableJitterForSyncs.Load() {
return timeutil.Now().Add(time.Duration(rand.Intn(15)) * time.Second)
return r.now().Add(time.Duration(rand.Intn(15)) * time.Second)
}
return r.now()
}
Expand Down
3 changes: 2 additions & 1 deletion warehouse/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/rudderlabs/rudder-server/services/notifier"
migrator "github.com/rudderlabs/rudder-server/services/sql-migrator"
"github.com/rudderlabs/rudder-server/utils/pubsub"
"github.com/rudderlabs/rudder-server/utils/timeutil"
"github.com/rudderlabs/rudder-server/warehouse/bcm"
"github.com/rudderlabs/rudder-server/warehouse/encoding"
sqlmiddleware "github.com/rudderlabs/rudder-server/warehouse/integrations/middleware/sqlquerywrapper"
Expand Down Expand Up @@ -143,7 +144,7 @@ func TestRouter(t *testing.T) {

db := sqlmiddleware.New(pgResource.DB)

now := time.Now()
now := timeutil.Now()

repoUpload := repo.NewUploads(db, repo.WithNow(func() time.Time {
return now
Expand Down
11 changes: 6 additions & 5 deletions warehouse/router/scheduling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

backendConfig "github.com/rudderlabs/rudder-server/backend-config"
migrator "github.com/rudderlabs/rudder-server/services/sql-migrator"
"github.com/rudderlabs/rudder-server/utils/timeutil"
sqlmiddleware "github.com/rudderlabs/rudder-server/warehouse/integrations/middleware/sqlquerywrapper"
"github.com/rudderlabs/rudder-server/warehouse/internal/model"
"github.com/rudderlabs/rudder-server/warehouse/internal/repo"
Expand Down Expand Up @@ -235,7 +236,7 @@ func TestRouter_CanCreateUpload(t *testing.T) {
Identifier: "test_identifier_upload_frequency_exceeded",
}

now := time.Now()
now := timeutil.Now()

r := Router{}
r.conf = config.New()
Expand All @@ -260,7 +261,7 @@ func TestRouter_CanCreateUpload(t *testing.T) {
Identifier: "test_identifier_upload_frequency_exceeded",
}

now := time.Now()
now := timeutil.Now()

r := Router{}
r.conf = config.New()
Expand Down Expand Up @@ -316,7 +317,7 @@ func TestRouter_CanCreateUpload(t *testing.T) {
},
}

now := time.Now()
now := timeutil.Now()

r := Router{}
r.conf = config.New()
Expand Down Expand Up @@ -344,7 +345,7 @@ func TestRouter_CanCreateUpload(t *testing.T) {
},
}

now := time.Now()
now := timeutil.Now()

r := Router{}
r.conf = config.New()
Expand Down Expand Up @@ -453,7 +454,7 @@ func TestRouter_CanCreateUpload(t *testing.T) {
return tc.now
}

r.updateCreateJobMarker(w, time.Now())
r.updateCreateJobMarker(w, now)

err := r.canCreateUpload(context.Background(), w)
if tc.wantErr != nil {
Expand Down
2 changes: 1 addition & 1 deletion warehouse/router/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
// If the upload has not reached the terminal state, then we send a gauge metric with value 1 else 0
func (r *Router) cronTracker(ctx context.Context) error {
for {
execTime := time.Now()
execTime := r.now()
r.stats.cronTrackerExecTimestamp.Gauge(execTime.Unix())

for _, warehouse := range r.copyWarehouses() {
Expand Down
5 changes: 3 additions & 2 deletions warehouse/router/tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

backendconfig "github.com/rudderlabs/rudder-server/backend-config"
migrator "github.com/rudderlabs/rudder-server/services/sql-migrator"
"github.com/rudderlabs/rudder-server/utils/timeutil"
sqlmiddleware "github.com/rudderlabs/rudder-server/warehouse/integrations/middleware/sqlquerywrapper"
"github.com/rudderlabs/rudder-server/warehouse/internal/model"
"github.com/rudderlabs/rudder-server/warehouse/internal/repo"
Expand Down Expand Up @@ -50,7 +51,7 @@ func TestRouter_CronTrack(t *testing.T) {
r := Router{
conf: config.New(),
destType: whutils.POSTGRES,
now: time.Now,
now: timeutil.Now,
statsFactory: statsStore,
logger: logger.NOP,
}
Expand Down Expand Up @@ -136,7 +137,7 @@ func TestRouter_CronTrack(t *testing.T) {
r := Router{
conf: config.New(),
destType: whutils.POSTGRES,
now: time.Now,
now: timeutil.Now,
statsFactory: statsStore,
db: db,
logger: logger.NOP,
Expand Down

0 comments on commit b436b44

Please sign in to comment.