Merge branch 'master' into 15572-new-install-docs
[arvados.git] / lib / dispatchcloud / worker / worker_test.go
index 3bc33b62c9fee896f107278a564b859d1448366e..4f8f77bff6de95f820ca38d81a0151f31a3bf86d 100644 (file)
@@ -9,10 +9,10 @@ import (
        "io"
        "time"
 
-       "git.curoverse.com/arvados.git/lib/cloud"
-       "git.curoverse.com/arvados.git/lib/dispatchcloud/test"
-       "git.curoverse.com/arvados.git/sdk/go/arvados"
-       "git.curoverse.com/arvados.git/sdk/go/ctxlog"
+       "git.arvados.org/arvados.git/lib/cloud"
+       "git.arvados.org/arvados.git/lib/dispatchcloud/test"
+       "git.arvados.org/arvados.git/sdk/go/arvados"
+       "git.arvados.org/arvados.git/sdk/go/ctxlog"
        check "gopkg.in/check.v1"
 )
 
@@ -25,7 +25,8 @@ func (suite *WorkerSuite) TestProbeAndUpdate(c *check.C) {
        bootTimeout := time.Minute
        probeTimeout := time.Second
 
-       is, err := (&test.StubDriver{}).InstanceSet(nil, "", logger)
+       ac := arvados.NewClientFromEnv()
+       is, err := (&test.StubDriver{}).InstanceSet(nil, "test-instance-set-id", nil, logger)
        c.Assert(err, check.IsNil)
        inst, err := is.Create(arvados.InstanceType{}, "", nil, "echo InitCommand", nil)
        c.Assert(err, check.IsNil)
@@ -192,6 +193,7 @@ func (suite *WorkerSuite) TestProbeAndUpdate(c *check.C) {
                        "crunch-run --list": trial.respRun,
                }
                wp := &Pool{
+                       arvClient:        ac,
                        newExecutor:      func(cloud.Instance) Executor { return exr },
                        bootProbeCommand: "bootprobe",
                        timeoutBooting:   bootTimeout,
@@ -209,12 +211,17 @@ func (suite *WorkerSuite) TestProbeAndUpdate(c *check.C) {
                        busy:     ctime,
                        probed:   ctime,
                        updated:  ctime,
+                       running:  map[string]*remoteRunner{},
+                       starting: map[string]*remoteRunner{},
+                       probing:  make(chan struct{}, 1),
                }
                if trial.running > 0 {
-                       wkr.running = map[string]struct{}{"zzzzz-dz642-abcdefghijklmno": struct{}{}}
+                       uuid := "zzzzz-dz642-abcdefghijklmno"
+                       wkr.running = map[string]*remoteRunner{uuid: newRemoteRunner(uuid, wkr)}
                }
                if trial.starting > 0 {
-                       wkr.starting = map[string]struct{}{"zzzzz-dz642-abcdefghijklmno": struct{}{}}
+                       uuid := "zzzzz-dz642-bcdefghijklmnop"
+                       wkr.starting = map[string]*remoteRunner{uuid: newRemoteRunner(uuid, wkr)}
                }
                wkr.probeAndUpdate()
                c.Check(wkr.state, check.Equals, trial.expectState)