9898: Code cleanup.
authorTom Clegg <tom@curoverse.com>
Thu, 8 Sep 2016 20:15:11 +0000 (16:15 -0400)
committerTom Clegg <tom@curoverse.com>
Thu, 8 Sep 2016 20:15:11 +0000 (16:15 -0400)
services/api/test/functional/arvados/v1/containers_controller_test.rb
services/crunch-dispatch-slurm/crunch-dispatch-slurm.go

index 45149b21d9fab05c927e2f72759edce2edebbaf5..3a22de82f25029d89ce0781e4603558c6f6cc181 100644 (file)
@@ -50,8 +50,7 @@ class Arvados::V1::ContainersControllerTest < ActionController::TestCase
     assert_nil json_response['auth']
   end
 
-  test "lock and unlock container" do
-    # lock container
+  test "lock container" do
     authorize_with :dispatch1
     post :lock, {id: containers(:queued).uuid}
     assert_response :success
@@ -59,12 +58,11 @@ class Arvados::V1::ContainersControllerTest < ActionController::TestCase
     assert_equal 'Locked', container.state
     assert_not_nil container.locked_by_uuid
     assert_not_nil container.auth_uuid
+  end
 
-    # unlock container
-    @test_counter = 0  # Reset executed action counter
-    @controller = Arvados::V1::ContainersController.new
+  test "unlock container" do
     authorize_with :dispatch1
-    post :unlock, {id: container.uuid}
+    post :unlock, {id: containers(:locked).uuid}
     assert_response :success
     container = Container.where(uuid: container.uuid).first
     assert_equal 'Queued', container.state
index ac776445d25d51e0c9d10361f023d255869f4992..b33dc64e7bd7bf7b854fde1a55d0a388b32407db 100644 (file)
@@ -260,14 +260,13 @@ func monitorSubmitOrCancel(dispatcher *dispatch.Dispatcher, container arvados.Co
                                log.Printf("Error getting final container state: %v", err)
                        }
 
-                       var st arvados.ContainerState
                        switch con.State {
                        case dispatch.Locked:
                                log.Printf("Container %s in state %v but missing from slurm queue, changing to %v.",
                                        container.UUID, con.State, dispatch.Queued)
                                dispatcher.Unlock(container.UUID)
                        case dispatch.Running:
-                               st = dispatch.Cancelled
+                               st := dispatch.Cancelled
                                log.Printf("Container %s in state %v but missing from slurm queue, changing to %v.",
                                        container.UUID, con.State, st)
                                dispatcher.UpdateState(container.UUID, st)