Merge branch '10690-config-dump'
[arvados.git] / services / crunch-dispatch-slurm / crunch-dispatch-slurm_test.go
index 39ec15dd0e7817147239f844b2c23e4bddc718a3..40461031e214486f1dbed9feeda6aae0d97fb76c 100644 (file)
@@ -81,7 +81,8 @@ func (s *TestSuite) TestIntegrationCancel(c *C) {
                return exec.Command("echo")
        }
 
-       container := s.integrationTest(c, func() *exec.Cmd { return exec.Command("echo", "zzzzz-dz642-queuedcontainer") },
+       container := s.integrationTest(c,
+               func() *exec.Cmd { return exec.Command("echo", "zzzzz-dz642-queuedcontainer") },
                []string(nil),
                func(dispatcher *dispatch.Dispatcher, container arvados.Container) {
                        dispatcher.UpdateState(container.UUID, dispatch.Running)
@@ -134,7 +135,7 @@ func (s *TestSuite) integrationTest(c *C,
        }(squeueCmd)
        squeueCmd = newSqueueCmd
 
-       // There should be no queued containers now
+       // There should be one queued container
        params := arvadosclient.Dict{
                "filters": [][]string{{"state", "=", "Queued"}},
        }
@@ -193,7 +194,7 @@ func testWithServerStub(c *C, apiStubResponses map[string]arvadostest.StubRespon
        api := httptest.NewServer(&apiStub)
        defer api.Close()
 
-       arv := arvadosclient.ArvadosClient{
+       arv := &arvadosclient.ArvadosClient{
                Scheme:    "http",
                ApiServer: api.URL[7:],
                ApiToken:  "abc123",
@@ -305,13 +306,25 @@ func (s *MockArvadosServerSuite) TestSbatchFuncWithConfigArgs(c *C) {
 func testSbatchFuncWithArgs(c *C, args []string) {
        theConfig.SbatchArguments = append(theConfig.SbatchArguments, args...)
 
-       container := arvados.Container{UUID: "123", RuntimeConstraints: arvados.RuntimeConstraints{RAM: 1000000, VCPUs: 2}}
+       container := arvados.Container{UUID: "123", RuntimeConstraints: arvados.RuntimeConstraints{RAM: 250000000, VCPUs: 2}}
        sbatchCmd := sbatchFunc(container)
 
        var expected []string
        expected = append(expected, "sbatch", "--share")
        expected = append(expected, theConfig.SbatchArguments...)
-       expected = append(expected, "--job-name=123", "--mem-per-cpu=1", "--cpus-per-task=2")
+       expected = append(expected, "--job-name=123", "--mem-per-cpu=120", "--cpus-per-task=2")
+
+       c.Check(sbatchCmd.Args, DeepEquals, expected)
+}
+
+func (s *MockArvadosServerSuite) TestSbatchPartition(c *C) {
+       theConfig.SbatchArguments = nil
+       container := arvados.Container{UUID: "123", RuntimeConstraints: arvados.RuntimeConstraints{RAM: 250000000, VCPUs: 1}, SchedulingParameters: arvados.SchedulingParameters{Partitions: []string{"blurb", "b2"}}}
+       sbatchCmd := sbatchFunc(container)
+
+       var expected []string
+       expected = append(expected, "sbatch", "--share")
+       expected = append(expected, "--job-name=123", "--mem-per-cpu=239", "--cpus-per-task=1", "--partition=blurb,b2")
 
        c.Check(sbatchCmd.Args, DeepEquals, expected)
 }