Merge branch 'master' into 6588-split-manage-account
[arvados.git] / services / api / test / integration / websocket_test.rb
index a4133ba5fee9878f29df3ba34ce19d247842dd30..c4d6d5eb7e6eb54eaba2c830035321656668aa33 100644 (file)
@@ -84,7 +84,7 @@ class WebsocketTest < ActionDispatch::IntegrationTest
     assert_equal 200, status
   end
 
-  test "connect, subscribe, get event" do
+  def subscribe_test
     state = 1
     spec = nil
     ev_uuid = nil
@@ -115,6 +115,10 @@ class WebsocketTest < ActionDispatch::IntegrationTest
     assert_equal spec.uuid, ev_uuid
   end
 
+  test "connect, subscribe, get event" do
+    subscribe_test()
+  end
+
   test "connect, subscribe, get two events" do
     state = 1
     spec = nil
@@ -655,6 +659,7 @@ class WebsocketTest < ActionDispatch::IntegrationTest
 
     ws_helper :admin do |ws|
       ws.on :open do |event|
+        # test that #6451 is fixed (invalid filter crashes websockets)
         ws.send ({method: 'subscribe', filters: [['object_blarg', 'is_a', 'arvados#human']]}.to_json)
       end
 
@@ -677,22 +682,11 @@ class WebsocketTest < ActionDispatch::IntegrationTest
 
     end
 
-    # Try connecting again, test that #6451 is fixed
-    # (invalid filter crashes websockets)
-    status = nil
-    ws_helper :admin do |ws|
-      ws.on :open do |event|
-        ws.send ({method: 'subscribe'}.to_json)
-      end
-
-      ws.on :message do |event|
-        d = Oj.load event.data
-        status = d["status"]
-        ws.close
-      end
-    end
+    assert_equal 3, state
 
-    assert_equal 200, status
+    # Try connecting again, ensure that websockets server is still running and
+    # didn't crash per #6451
+    subscribe_test()
 
   end