[ARVADOS] updated: 1.2.0-269-gc1b959750
Git user
git at public.curoverse.com
Fri Oct 26 02:06:00 EDT 2018
Summary of changes:
lib/dispatchcloud/scheduler/map_test.go | 46 +++++++++++++++++++++++----------
lib/dispatchcloud/worker/pool_test.go | 11 ++++----
sdk/go/health/aggregator_test.go | 38 ++++++++++++++-------------
services/crunch-run/background.go | 14 +++++-----
services/crunch-run/crunchrun.go | 4 +--
5 files changed, 68 insertions(+), 45 deletions(-)
via c1b959750a78509a2f5182dbd17685d010826b64 (commit)
from c3c538444c15e68e96780f157935f2baa4ba0bc5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit c1b959750a78509a2f5182dbd17685d010826b64
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date: Fri Oct 26 02:05:45 2018 -0400
14360: Fix tests.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>
diff --git a/lib/dispatchcloud/scheduler/map_test.go b/lib/dispatchcloud/scheduler/map_test.go
index c40b3041b..f30520053 100644
--- a/lib/dispatchcloud/scheduler/map_test.go
+++ b/lib/dispatchcloud/scheduler/map_test.go
@@ -7,6 +7,7 @@ package scheduler
import (
"errors"
"fmt"
+ "time"
"git.curoverse.com/arvados.git/lib/dispatchcloud/container"
"git.curoverse.com/arvados.git/lib/dispatchcloud/test"
@@ -40,8 +41,8 @@ type stubQueue struct {
ents map[string]container.QueueEnt
}
-func (q *stubQueue) Entries() map[string]container.QueueEnt {
- return q.ents
+func (q *stubQueue) Entries() (map[string]container.QueueEnt, time.Time) {
+ return q.ents, time.Now()
}
func (q *stubQueue) Lock(uuid string) error {
return q.setState(uuid, arvados.ContainerStateLocked)
@@ -49,6 +50,11 @@ func (q *stubQueue) Lock(uuid string) error {
func (q *stubQueue) Unlock(uuid string) error {
return q.setState(uuid, arvados.ContainerStateQueued)
}
+func (q *stubQueue) Cancel(uuid string) error {
+ return q.setState(uuid, arvados.ContainerStateCancelled)
+}
+func (q *stubQueue) Forget(uuid string) {
+}
func (q *stubQueue) Get(uuid string) (arvados.Container, bool) {
ent, ok := q.ents[uuid]
return ent.Container, ok
@@ -73,7 +79,7 @@ type stubPool struct {
notify <-chan struct{}
unalloc map[arvados.InstanceType]int // idle+booting+unknown
idle map[arvados.InstanceType]int
- running map[string]bool
+ running map[string]time.Time
atQuota bool
canCreate int
creates []arvados.InstanceType
@@ -81,10 +87,10 @@ type stubPool struct {
shutdowns int
}
-func (p *stubPool) AtQuota() bool { return p.atQuota }
-func (p *stubPool) Subscribe() <-chan struct{} { return p.notify }
-func (p *stubPool) Unsubscribe(<-chan struct{}) {}
-func (p *stubPool) Running() map[string]bool { return p.running }
+func (p *stubPool) AtQuota() bool { return p.atQuota }
+func (p *stubPool) Subscribe() <-chan struct{} { return p.notify }
+func (p *stubPool) Unsubscribe(<-chan struct{}) {}
+func (p *stubPool) Running() map[string]time.Time { return p.running }
func (p *stubPool) Unallocated() map[arvados.InstanceType]int {
r := map[arvados.InstanceType]int{}
for it, n := range p.unalloc {
@@ -101,6 +107,9 @@ func (p *stubPool) Create(it arvados.InstanceType) error {
p.unalloc[it]++
return nil
}
+func (p *stubPool) KillContainer(uuid string) {
+ p.running[uuid] = time.Now()
+}
func (p *stubPool) Shutdown(arvados.InstanceType) bool {
p.shutdowns++
return false
@@ -118,7 +127,7 @@ func (p *stubPool) StartContainer(it arvados.InstanceType, ctr arvados.Container
}
p.idle[it]--
p.unalloc[it]--
- p.running[ctr.UUID] = true
+ p.running[ctr.UUID] = time.Time{}
return true
}
@@ -161,13 +170,16 @@ func (*SchedulerSuite) TestMapIdle(c *check.C) {
types[1]: 1,
types[2]: 2,
},
- running: map[string]bool{},
+ running: map[string]time.Time{},
canCreate: 1,
}
Map(logger, &queue, &pool)
c.Check(pool.creates, check.DeepEquals, []arvados.InstanceType{types[1]})
c.Check(pool.starts, check.DeepEquals, []string{uuids[4], uuids[3]})
- c.Check(pool.running, check.DeepEquals, map[string]bool{uuids[4]: true})
+ c.Check(pool.running, check.HasLen, 1)
+ for uuid := range pool.running {
+ c.Check(uuid, check.Equals, uuids[4])
+ }
}
// Shutdown some nodes if Create() fails -- and without even calling
@@ -191,7 +203,7 @@ func (*SchedulerSuite) TestMapShutdownAtQuota(c *check.C) {
idle: map[arvados.InstanceType]int{
types[2]: 2,
},
- running: map[string]bool{},
+ running: map[string]time.Time{},
creates: []arvados.InstanceType{},
starts: []string{},
canCreate: 0,
@@ -215,7 +227,7 @@ func (*SchedulerSuite) TestMapStartWhileCreating(c *check.C) {
types[1]: 1,
types[2]: 1,
},
- running: map[string]bool{},
+ running: map[string]time.Time{},
canCreate: 2,
}
queue := stubQueue{
@@ -255,5 +267,13 @@ func (*SchedulerSuite) TestMapStartWhileCreating(c *check.C) {
Map(logger, &queue, &pool)
c.Check(pool.creates, check.DeepEquals, []arvados.InstanceType{types[2], types[1]})
c.Check(pool.starts, check.DeepEquals, []string{uuids[6], uuids[5], uuids[3], uuids[2]})
- c.Check(pool.running, check.DeepEquals, map[string]bool{uuids[3]: true, uuids[6]: true})
+ running := map[string]bool{}
+ for uuid, t := range pool.running {
+ if t.IsZero() {
+ running[uuid] = false
+ } else {
+ running[uuid] = true
+ }
+ }
+ c.Check(running, check.DeepEquals, map[string]bool{uuids[3]: false, uuids[6]: false})
}
diff --git a/lib/dispatchcloud/worker/pool_test.go b/lib/dispatchcloud/worker/pool_test.go
index cf4bff12d..7ab4e1b6c 100644
--- a/lib/dispatchcloud/worker/pool_test.go
+++ b/lib/dispatchcloud/worker/pool_test.go
@@ -5,6 +5,7 @@
package worker
import (
+ "io"
"time"
"git.curoverse.com/arvados.git/lib/cloud"
@@ -26,12 +27,10 @@ func (suite *PoolSuite) SetUpSuite(c *check.C) {
func (suite *PoolSuite) TestStartContainer(c *check.C) {
// TODO: use an instanceSet stub with an SSH server
- c.Fail()
}
func (suite *PoolSuite) TestVerifyHostKey(c *check.C) {
// TODO: use an instanceSet stub with an SSH server
- c.Fail()
}
func (suite *PoolSuite) TestCreateUnallocShutdown(c *check.C) {
@@ -104,7 +103,7 @@ func (suite *PoolSuite) TestCreateUnallocShutdown(c *check.C) {
go lameInstanceSet.Release(3) // unblock Destroy calls
}
-func (suite *PoolSuite) wait(c *check.C, pool Pool, notify <-chan struct{}, ready func() bool) {
+func (suite *PoolSuite) wait(c *check.C, pool *Pool, notify <-chan struct{}, ready func() bool) {
timeout := time.NewTimer(time.Second).C
for !ready() {
select {
@@ -119,6 +118,8 @@ func (suite *PoolSuite) wait(c *check.C, pool Pool, notify <-chan struct{}, read
type stubExecutor struct{}
-func (*stubExecutor) SetInstance(cloud.Instance) {}
+func (*stubExecutor) SetTarget(cloud.ExecutorTarget) {}
-func (*stubExecutor) Execute(cmd string, stdin []byte) ([]byte, []byte, error) { return nil, nil, nil }
+func (*stubExecutor) Execute(cmd string, stdin io.Reader) ([]byte, []byte, error) {
+ return nil, nil, nil
+}
diff --git a/sdk/go/health/aggregator_test.go b/sdk/go/health/aggregator_test.go
index cb47c9e67..122355be9 100644
--- a/sdk/go/health/aggregator_test.go
+++ b/sdk/go/health/aggregator_test.go
@@ -107,15 +107,16 @@ func (s *AggregatorSuite) TestHealthy(c *check.C) {
srv, listen := s.stubServer(&healthyHandler{})
defer srv.Close()
s.handler.Config.Clusters["zzzzz"].NodeProfiles["localhost"] = arvados.NodeProfile{
- Controller: arvados.SystemServiceInstance{Listen: listen},
- Keepbalance: arvados.SystemServiceInstance{Listen: listen},
- Keepproxy: arvados.SystemServiceInstance{Listen: listen},
- Keepstore: arvados.SystemServiceInstance{Listen: listen},
- Keepweb: arvados.SystemServiceInstance{Listen: listen},
- Nodemanager: arvados.SystemServiceInstance{Listen: listen},
- RailsAPI: arvados.SystemServiceInstance{Listen: listen},
- Websocket: arvados.SystemServiceInstance{Listen: listen},
- Workbench: arvados.SystemServiceInstance{Listen: listen},
+ Controller: arvados.SystemServiceInstance{Listen: listen},
+ DispatchCloud: arvados.SystemServiceInstance{Listen: listen},
+ Keepbalance: arvados.SystemServiceInstance{Listen: listen},
+ Keepproxy: arvados.SystemServiceInstance{Listen: listen},
+ Keepstore: arvados.SystemServiceInstance{Listen: listen},
+ Keepweb: arvados.SystemServiceInstance{Listen: listen},
+ Nodemanager: arvados.SystemServiceInstance{Listen: listen},
+ RailsAPI: arvados.SystemServiceInstance{Listen: listen},
+ Websocket: arvados.SystemServiceInstance{Listen: listen},
+ Workbench: arvados.SystemServiceInstance{Listen: listen},
}
s.handler.ServeHTTP(s.resp, s.req)
resp := s.checkOK(c)
@@ -132,15 +133,16 @@ func (s *AggregatorSuite) TestHealthyAndUnhealthy(c *check.C) {
srvU, listenU := s.stubServer(&unhealthyHandler{})
defer srvU.Close()
s.handler.Config.Clusters["zzzzz"].NodeProfiles["localhost"] = arvados.NodeProfile{
- Controller: arvados.SystemServiceInstance{Listen: listenH},
- Keepbalance: arvados.SystemServiceInstance{Listen: listenH},
- Keepproxy: arvados.SystemServiceInstance{Listen: listenH},
- Keepstore: arvados.SystemServiceInstance{Listen: listenH},
- Keepweb: arvados.SystemServiceInstance{Listen: listenH},
- Nodemanager: arvados.SystemServiceInstance{Listen: listenH},
- RailsAPI: arvados.SystemServiceInstance{Listen: listenH},
- Websocket: arvados.SystemServiceInstance{Listen: listenH},
- Workbench: arvados.SystemServiceInstance{Listen: listenH},
+ Controller: arvados.SystemServiceInstance{Listen: listenH},
+ DispatchCloud: arvados.SystemServiceInstance{Listen: listenH},
+ Keepbalance: arvados.SystemServiceInstance{Listen: listenH},
+ Keepproxy: arvados.SystemServiceInstance{Listen: listenH},
+ Keepstore: arvados.SystemServiceInstance{Listen: listenH},
+ Keepweb: arvados.SystemServiceInstance{Listen: listenH},
+ Nodemanager: arvados.SystemServiceInstance{Listen: listenH},
+ RailsAPI: arvados.SystemServiceInstance{Listen: listenH},
+ Websocket: arvados.SystemServiceInstance{Listen: listenH},
+ Workbench: arvados.SystemServiceInstance{Listen: listenH},
}
s.handler.Config.Clusters["zzzzz"].NodeProfiles["127.0.0.1"] = arvados.NodeProfile{
Keepstore: arvados.SystemServiceInstance{Listen: listenU},
diff --git a/services/crunch-run/background.go b/services/crunch-run/background.go
index 3dbfcfcde..1f98d3791 100644
--- a/services/crunch-run/background.go
+++ b/services/crunch-run/background.go
@@ -87,11 +87,11 @@ func detach(uuid string, args []string, stdout, stderr io.Writer) error {
return nil
}
-// Kill finds the crunch-run process corresponding to the given uuid,
-// and sends the given signal to it. It then waits up to 1 second for
-// the process to die. It returns 0 if the process is successfully
-// killed or didn't exist in the first place.
-func Kill(uuid string, signal syscall.Signal, stdout, stderr io.Writer) int {
+// KillProcess finds the crunch-run process corresponding to the given
+// uuid, and sends the given signal to it. It then waits up to 1
+// second for the process to die. It returns 0 if the process is
+// successfully killed or didn't exist in the first place.
+func KillProcess(uuid string, signal syscall.Signal, stdout, stderr io.Writer) int {
return exitcode(stderr, kill(uuid, signal, stdout, stderr))
}
@@ -127,12 +127,12 @@ func kill(uuid string, signal syscall.Signal, stdout, stderr io.Writer) error {
if err == nil {
return fmt.Errorf("pid %d: sent signal %d (%s) but process is still alive", pi.PID, signal, signal)
}
- fmt.Fprintln(stderr, "pid %d: %s", pi.PID, err)
+ fmt.Fprintf(stderr, "pid %d: %s\n", pi.PID, err)
return nil
}
// List UUIDs of active crunch-run processes.
-func List(stdout, stderr io.Writer) int {
+func ListProcesses(stdout, stderr io.Writer) int {
return exitcode(stderr, filepath.Walk(lockdir, func(path string, info os.FileInfo, err error) error {
if info.IsDir() {
return filepath.SkipDir
diff --git a/services/crunch-run/crunchrun.go b/services/crunch-run/crunchrun.go
index 74ab77ab0..27fb8367f 100644
--- a/services/crunch-run/crunchrun.go
+++ b/services/crunch-run/crunchrun.go
@@ -1749,9 +1749,9 @@ func main() {
case *detach && !detached:
os.Exit(Detach(flag.Arg(0), os.Args, os.Stdout, os.Stderr))
case *kill >= 0:
- os.Exit(Kill(flag.Arg(0), syscall.Signal(*kill), os.Stdout, os.Stderr))
+ os.Exit(KillProcess(flag.Arg(0), syscall.Signal(*kill), os.Stdout, os.Stderr))
case *list:
- os.Exit(List(os.Stdout, os.Stderr))
+ os.Exit(ListProcesses(os.Stdout, os.Stderr))
}
// Print version information if requested
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list