X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/41887dd213cfa165925e94d4f3bb120edeb1a30d..ddc1f6b0c54b72df395cfef26e0dc4eb8f65463d:/services/api/test/integration/websocket_test.rb diff --git a/services/api/test/integration/websocket_test.rb b/services/api/test/integration/websocket_test.rb index fbc18c50c7..7780ccb87c 100644 --- a/services/api/test/integration/websocket_test.rb +++ b/services/api/test/integration/websocket_test.rb @@ -603,4 +603,47 @@ class WebsocketTest < ActionDispatch::IntegrationTest end + test "connect, subscribe, lots of events" do + state = 1 + event_count = 0 + log_start = Log.order(:id).last.id + + authorize_with :admin + + ws_helper :admin, false do |ws| + EM::Timer.new 45 do + # Needs a longer timeout than the default + ws.close + end + + ws.on :open do |event| + ws.send ({method: 'subscribe'}.to_json) + end + + ws.on :message do |event| + d = Oj.load event.data + case state + when 1 + assert_equal 200, d["status"] + ActiveRecord::Base.transaction do + (1..202).each do + spec = Specimen.create + end + end + state = 2 + when 2 + event_count += 1 + assert_equal d['id'], event_count+log_start + if event_count == 202 + ws.close + end + end + end + + end + + assert_equal 202, event_count + end + + end