[ARVADOS] updated: 6f6aeb54fd6841bb74a5ea01f1231dc8d48c0490

git at public.curoverse.com git at public.curoverse.com
Wed Jan 20 12:34:16 EST 2016


Summary of changes:
 .../crunch-dispatch-local/crunch-dispatch-local.go | 22 +++++++++-------------
 .../crunch-dispatch-local_test.go                  |  6 +++---
 2 files changed, 12 insertions(+), 16 deletions(-)

       via  6f6aeb54fd6841bb74a5ea01f1231dc8d48c0490 (commit)
      from  993d923b3c6310bffb71e2ab50c0cb2833408b08 (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 6f6aeb54fd6841bb74a5ea01f1231dc8d48c0490
Author: radhika <radhika at curoverse.com>
Date:   Wed Jan 20 12:33:16 2016 -0500

    8028: Update the stub based test to use waitGroup.Wait() instead of sleep.

diff --git a/services/crunch-dispatch-local/crunch-dispatch-local.go b/services/crunch-dispatch-local/crunch-dispatch-local.go
index 0255831..be1fef8 100644
--- a/services/crunch-dispatch-local/crunch-dispatch-local.go
+++ b/services/crunch-dispatch-local/crunch-dispatch-local.go
@@ -176,19 +176,15 @@ func run(uuid string, crunchRunCommand string, priorityPollInterval int) {
 	// A goroutine to terminate the runner if container priority becomes zero
 	priorityTicker := time.NewTicker(time.Duration(priorityPollInterval) * time.Second)
 	go func() {
-		for {
-			select {
-			case <-priorityTicker.C:
-				var container Container
-				err := arv.Get("containers", uuid, nil, &container)
-				if err != nil {
-					log.Printf("Error getting container info for %v: %q", uuid, err)
-				} else {
-					if container.Priority == 0 {
-						priorityTicker.Stop()
-						cmd.Process.Signal(os.Interrupt)
-						return
-					}
+		for _ = range priorityTicker.C {
+			var container Container
+			err := arv.Get("containers", uuid, nil, &container)
+			if err != nil {
+				log.Printf("Error getting container info for %v: %q", uuid, err)
+			} else {
+				if container.Priority == 0 {
+					priorityTicker.Stop()
+					cmd.Process.Signal(os.Interrupt)
 				}
 			}
 		}
diff --git a/services/crunch-dispatch-local/crunch-dispatch-local_test.go b/services/crunch-dispatch-local/crunch-dispatch-local_test.go
index ef8cb83..3ec1e2e 100644
--- a/services/crunch-dispatch-local/crunch-dispatch-local_test.go
+++ b/services/crunch-dispatch-local/crunch-dispatch-local_test.go
@@ -145,14 +145,14 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
 	log.SetOutput(tempfile)
 
 	go func() {
-		time.Sleep(1 * time.Second)
+		time.Sleep(2 * time.Second)
 		sigChan <- syscall.SIGTERM
 	}()
 
 	runQueuedContainers(1, 1, crunchCmd)
 
-	// Give some time for run goroutine to complete
-	time.Sleep(5 * time.Second)
+	// Wait for all running crunch jobs to complete / terminate
+	waitGroup.Wait()
 
 	buf, _ := ioutil.ReadFile(tempfile.Name())
 	c.Check(strings.Contains(string(buf), expected), Equals, true)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list