[ARVADOS] updated: 1.1.1-59-g3a2bac3

Git user git at public.curoverse.com
Thu Nov 30 16:54:48 EST 2017


Summary of changes:
 .../crunch-dispatch-slurm/crunch-dispatch-slurm.go |   2 +-
 .../crunch-dispatch-slurm_test.go                  | 232 ++++++++++++---------
 2 files changed, 137 insertions(+), 97 deletions(-)

       via  3a2bac3f64cd19c11bcfa9b957b7b473ddfb7a55 (commit)
      from  e9ce829350cf4beddc52f0a2c0312151b47b9026 (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 3a2bac3f64cd19c11bcfa9b957b7b473ddfb7a55
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Thu Nov 30 16:54:27 2017 -0500

    12573: Add test for dynamic priority adjustment.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
index f379099..2f30ebf 100644
--- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
+++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm.go
@@ -294,7 +294,7 @@ func run(disp *dispatch.Dispatcher, ctr arvados.Container, status <-chan arvados
 			} else if updated.Priority == 0 {
 				log.Printf("Container %s has state %q, priority %d: cancel slurm job", ctr.UUID, updated.State, updated.Priority)
 				scancel(ctr)
-			} else if niceness(updated.Priority) != sqCheck.GetNiceness(ctr.UUID) {
+			} else if niceness(updated.Priority) != sqCheck.GetNiceness(ctr.UUID) && sqCheck.GetNiceness(ctr.UUID) != -1 {
 				// dynamically adjust priority
 				scontrolUpdate(updated)
 			}
diff --git a/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go b/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go
index 58af4a3..052cdfb 100644
--- a/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go
+++ b/services/crunch-dispatch-slurm/crunch-dispatch-slurm_test.go
@@ -64,6 +64,101 @@ func (s *MockArvadosServerSuite) TearDownTest(c *C) {
 	arvadostest.ResetEnv()
 }
 
+func (s *TestSuite) integrationTest(c *C,
+	newSqueueCmd func() *exec.Cmd,
+	newScancelCmd func(arvados.Container) *exec.Cmd,
+	newSbatchCmd func(arvados.Container) *exec.Cmd,
+	newScontrolCmd func(arvados.Container) *exec.Cmd,
+	sbatchCmdComps []string,
+	runContainer func(*dispatch.Dispatcher, arvados.Container)) arvados.Container {
+	arvadostest.ResetEnv()
+
+	arv, err := arvadosclient.MakeArvadosClient()
+	c.Assert(err, IsNil)
+
+	var sbatchCmdLine []string
+
+	// Override sbatchCmd
+	defer func(orig func(arvados.Container) *exec.Cmd) {
+		sbatchCmd = orig
+	}(sbatchCmd)
+
+	if newSbatchCmd != nil {
+		sbatchCmd = newSbatchCmd
+	} else {
+		sbatchCmd = func(container arvados.Container) *exec.Cmd {
+			sbatchCmdLine = sbatchFunc(container).Args
+			return exec.Command("sh")
+		}
+	}
+
+	// Override squeueCmd
+	defer func(orig func() *exec.Cmd) {
+		squeueCmd = orig
+	}(squeueCmd)
+	squeueCmd = newSqueueCmd
+
+	// Override scancel
+	defer func(orig func(arvados.Container) *exec.Cmd) {
+		scancelCmd = orig
+	}(scancelCmd)
+	scancelCmd = newScancelCmd
+
+	// Override scontrol
+	defer func(orig func(arvados.Container) *exec.Cmd) {
+		scontrolCmd = orig
+	}(scontrolCmd)
+	scontrolCmd = newScontrolCmd
+
+	// There should be one queued container
+	params := arvadosclient.Dict{
+		"filters": [][]string{{"state", "=", "Queued"}},
+	}
+	var containers arvados.ContainerList
+	err = arv.List("containers", params, &containers)
+	c.Check(err, IsNil)
+	c.Check(len(containers.Items), Equals, 1)
+
+	theConfig.CrunchRunCommand = []string{"echo"}
+
+	ctx, cancel := context.WithCancel(context.Background())
+	doneRun := make(chan struct{})
+
+	dispatcher := dispatch.Dispatcher{
+		Arv:        arv,
+		PollPeriod: time.Duration(1) * time.Second,
+		RunContainer: func(disp *dispatch.Dispatcher, ctr arvados.Container, status <-chan arvados.Container) {
+			go func() {
+				runContainer(disp, ctr)
+				doneRun <- struct{}{}
+			}()
+			run(disp, ctr, status)
+			cancel()
+		},
+	}
+
+	sqCheck = &SqueueChecker{Period: 500 * time.Millisecond}
+
+	err = dispatcher.Run(ctx)
+	<-doneRun
+	c.Assert(err, Equals, context.Canceled)
+
+	sqCheck.Stop()
+
+	c.Check(sbatchCmdLine, DeepEquals, sbatchCmdComps)
+
+	// There should be no queued containers now
+	err = arv.List("containers", params, &containers)
+	c.Check(err, IsNil)
+	c.Check(len(containers.Items), Equals, 0)
+
+	// Previously "Queued" container should now be in "Complete" state
+	var container arvados.Container
+	err = arv.Get("containers", "zzzzz-dz642-queuedcontainer", nil, &container)
+	c.Check(err, IsNil)
+	return container
+}
+
 func (s *TestSuite) TestIntegrationNormal(c *C) {
 	done := false
 	container := s.integrationTest(c,
@@ -76,6 +171,7 @@ func (s *TestSuite) TestIntegrationNormal(c *C) {
 		},
 		nil,
 		nil,
+		nil,
 		[]string(nil),
 		func(dispatcher *dispatch.Dispatcher, container arvados.Container) {
 			dispatcher.UpdateState(container.UUID, dispatch.Running)
@@ -109,6 +205,7 @@ func (s *TestSuite) TestIntegrationCancel(c *C) {
 			}
 		},
 		nil,
+		nil,
 		[]string(nil),
 		func(dispatcher *dispatch.Dispatcher, container arvados.Container) {
 			dispatcher.UpdateState(container.UUID, dispatch.Running)
@@ -127,6 +224,7 @@ func (s *TestSuite) TestIntegrationMissingFromSqueue(c *C) {
 		func() *exec.Cmd { return exec.Command("echo") },
 		nil,
 		nil,
+		nil,
 		[]string{"sbatch",
 			fmt.Sprintf("--job-name=%s", "zzzzz-dz642-queuedcontainer"),
 			fmt.Sprintf("--mem=%d", 11445),
@@ -148,6 +246,7 @@ func (s *TestSuite) TestSbatchFail(c *C) {
 		func(container arvados.Container) *exec.Cmd {
 			return exec.Command("false")
 		},
+		nil,
 		[]string(nil),
 		func(dispatcher *dispatch.Dispatcher, container arvados.Container) {
 			dispatcher.UpdateState(container.UUID, dispatch.Running)
@@ -166,102 +265,6 @@ func (s *TestSuite) TestSbatchFail(c *C) {
 	c.Assert(len(ll.Items), Equals, 1)
 }
 
-func (s *TestSuite) integrationTest(c *C,
-	newSqueueCmd func() *exec.Cmd,
-	newScancelCmd func(arvados.Container) *exec.Cmd,
-	newSbatchCmd func(arvados.Container) *exec.Cmd,
-	sbatchCmdComps []string,
-	runContainer func(*dispatch.Dispatcher, arvados.Container)) arvados.Container {
-	arvadostest.ResetEnv()
-
-	arv, err := arvadosclient.MakeArvadosClient()
-	c.Assert(err, IsNil)
-
-	var sbatchCmdLine []string
-
-	// Override sbatchCmd
-	defer func(orig func(arvados.Container) *exec.Cmd) {
-		sbatchCmd = orig
-	}(sbatchCmd)
-
-	if newSbatchCmd != nil {
-		sbatchCmd = newSbatchCmd
-	} else {
-		sbatchCmd = func(container arvados.Container) *exec.Cmd {
-			sbatchCmdLine = sbatchFunc(container).Args
-			return exec.Command("sh")
-		}
-	}
-
-	// Override squeueCmd
-	defer func(orig func() *exec.Cmd) {
-		squeueCmd = orig
-	}(squeueCmd)
-	squeueCmd = newSqueueCmd
-
-	// Override scancel
-	defer func(orig func(arvados.Container) *exec.Cmd) {
-		scancelCmd = orig
-	}(scancelCmd)
-	scancelCmd = newScancelCmd
-
-	// Override scontrol
-	defer func(orig func(arvados.Container) *exec.Cmd) {
-		scontrolCmd = orig
-	}(scontrolCmd)
-	scontrolCmd = func(container arvados.Container) *exec.Cmd {
-		return exec.Command("true")
-	}
-
-	// There should be one queued container
-	params := arvadosclient.Dict{
-		"filters": [][]string{{"state", "=", "Queued"}},
-	}
-	var containers arvados.ContainerList
-	err = arv.List("containers", params, &containers)
-	c.Check(err, IsNil)
-	c.Check(len(containers.Items), Equals, 1)
-
-	theConfig.CrunchRunCommand = []string{"echo"}
-
-	ctx, cancel := context.WithCancel(context.Background())
-	doneRun := make(chan struct{})
-
-	dispatcher := dispatch.Dispatcher{
-		Arv:        arv,
-		PollPeriod: time.Duration(1) * time.Second,
-		RunContainer: func(disp *dispatch.Dispatcher, ctr arvados.Container, status <-chan arvados.Container) {
-			go func() {
-				runContainer(disp, ctr)
-				doneRun <- struct{}{}
-			}()
-			run(disp, ctr, status)
-			cancel()
-		},
-	}
-
-	sqCheck = &SqueueChecker{Period: 500 * time.Millisecond}
-
-	err = dispatcher.Run(ctx)
-	<-doneRun
-	c.Assert(err, Equals, context.Canceled)
-
-	sqCheck.Stop()
-
-	c.Check(sbatchCmdLine, DeepEquals, sbatchCmdComps)
-
-	// There should be no queued containers now
-	err = arv.List("containers", params, &containers)
-	c.Check(err, IsNil)
-	c.Check(len(containers.Items), Equals, 0)
-
-	// Previously "Queued" container should now be in "Complete" state
-	var container arvados.Container
-	err = arv.Get("containers", "zzzzz-dz642-queuedcontainer", nil, &container)
-	c.Check(err, IsNil)
-	return container
-}
-
 func (s *MockArvadosServerSuite) TestAPIErrorGettingContainers(c *C) {
 	apiStubResponses := make(map[string]arvadostest.StubResponse)
 	apiStubResponses["/arvados/v1/api_client_authorizations/current"] = arvadostest.StubResponse{200, `{"uuid":"` + arvadostest.Dispatch1AuthUUID + `"}`}
@@ -415,3 +418,40 @@ func (s *MockArvadosServerSuite) TestSbatchPartition(c *C) {
 
 	c.Check(sbatchCmd.Args, DeepEquals, expected)
 }
+
+func (s *TestSuite) TestIntegrationChangePriority(c *C) {
+	var scontrolCmdLine []string
+	step := 0
+
+	container := s.integrationTest(c,
+		func() *exec.Cmd {
+			if step == 0 {
+				return exec.Command("echo", "zzzzz-dz642-queuedcontainer 999000")
+			} else if step == 1 {
+				return exec.Command("echo", "zzzzz-dz642-queuedcontainer 400000")
+			} else {
+				return exec.Command("echo")
+			}
+		},
+		func(arvados.Container) *exec.Cmd { return exec.Command("true") },
+		nil,
+		func(container arvados.Container) *exec.Cmd {
+			scontrolCmdLine = scontrolFunc(container).Args
+			step = 1
+			return exec.Command("true")
+		},
+		[]string(nil),
+		func(dispatcher *dispatch.Dispatcher, container arvados.Container) {
+			dispatcher.UpdateState(container.UUID, dispatch.Running)
+			time.Sleep(1 * time.Second)
+			dispatcher.Arv.Update("containers", container.UUID,
+				arvadosclient.Dict{
+					"container": arvadosclient.Dict{"priority": 600}},
+				nil)
+			time.Sleep(1 * time.Second)
+			step = 2
+			dispatcher.UpdateState(container.UUID, dispatch.Complete)
+		})
+	c.Check(container.State, Equals, arvados.ContainerStateComplete)
+	c.Check(scontrolCmdLine, DeepEquals, []string{"scontrol", "update", "JobName=zzzzz-dz642-queuedcontainer", "--nice=400000"})
+}

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list