From 0bbc5df5bf4a85d1c44db11afcd1e2e7c2dc52d4 Mon Sep 17 00:00:00 2001 From: Julie Qiu Date: Mon, 1 Jun 2020 11:45:41 -0400 Subject: cmd,internal: move taskIDChangeInterval to config At the moment, taskIDChangeInterval is a hardcoded value in internal/queue. However, we will soon have two task queues running, which require different change intervals, so this value is now set in internal/config. Additionally, the taskIDChangeInterval for the worker is changed to 3 hours. Change-Id: I498abefce6543005463be7da99a5a778f3a6e973 Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/758919 CI-Result: Cloud Build Reviewed-by: Jonathan Amsterdam --- internal/queue/queue_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'internal/queue/queue_test.go') diff --git a/internal/queue/queue_test.go b/internal/queue/queue_test.go index 3933325b..429e8017 100644 --- a/internal/queue/queue_test.go +++ b/internal/queue/queue_test.go @@ -12,18 +12,18 @@ import ( func TestNewTaskID(t *testing.T) { // Verify that the task ID is the same within taskIDChangeInterval and changes // afterwards. - const ( - module = "mod" - version = "ver" + var ( + module = "mod" + version = "ver" + taskIDChangeInterval = 3 * time.Hour ) - tm := time.Now().Truncate(taskIDChangeInterval) - id1 := newTaskID(module, version, tm) - id2 := newTaskID(module, version, tm.Add(taskIDChangeInterval/2)) + id1 := newTaskID(module, version, tm, taskIDChangeInterval) + id2 := newTaskID(module, version, tm.Add(taskIDChangeInterval/2), taskIDChangeInterval) if id1 != id2 { t.Error("wanted same task ID, got different") } - id3 := newTaskID(module, version, tm.Add(taskIDChangeInterval+1)) + id3 := newTaskID(module, version, tm.Add(taskIDChangeInterval+1), taskIDChangeInterval) if id1 == id3 { t.Error("wanted different task ID, got same") } -- cgit v1.3