test/plezi_tests.rb in plezi-0.10.9 vs test/plezi_tests.rb in plezi-0.10.10

- old
+ new

@@ -1,10 +1,11 @@ # I started writing tests... but I haven't finished quite yet. lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'open-uri' require 'plezi' +require 'objspace' def report_before_filter(result= true) return true if $before_tested puts(" * Before filter test: #{PleziTestTasks::RESULTS[result]}") $before_tested = true @@ -324,10 +325,11 @@ puts " * Websocket size disconnection test: #{RESULTS[should_disconnect]}" end str = 'a' time_now = Time.now 8.times {|i| str = str * 2**i;puts " * Websocket message size test: sending #{str.bytesize} bytes"; ws << str; } + str.clear to_sleep = (Time.now - time_now)*2 + 1 puts "will now sleep for #{to_sleep} seconds, waiting allowing the server to respond" sleep to_sleep rescue true should_disconnect = true Plezi::Settings.ws_message_size_limit = 1024 @@ -383,12 +385,10 @@ broadcast WSsizeTestCtrl, :_get_uuid, test: true, type: 'broadcast' multicast :_get_uuid, test: true, type: 'multicast' end end end -r = Plezi::Placebo.new PlaceboCtrl -puts " * Create Placebo test: #{PleziTestTasks::RESULTS[r && true]}" PL.create_logger nil # PL::Settings.max_threads = 4 listen port: 3000 @@ -402,9 +402,25 @@ shared_route 'ws/size', WSsizeTestCtrl shared_route '/some/:multi{path|another_path}/(:option){route|test}/(:id)/(:optional)', TestCtrl shared_route '/', TestCtrl + +mem_print_proc = Proc.new do + h = GC.stat.merge ObjectSpace.count_objects_size + ObjectSpace.each_object {|o| h[o.class] = h[o.class].to_i + 1} + puts (h.to_a.map {|i| i.join ': '} .join "\n") + h.clear + GC.start +end +# puts ("\n\n*** GC.stat:\n" + ((GC.stat.merge ObjectSpace.count_objects_size).to_a.map {|i| i.join ': '} .join "\n")) +# mem_print_proc.call +# GR.run_every 30, &mem_print_proc + + + +r = Plezi::Placebo.new PlaceboCtrl +puts " * Create Placebo test: #{PleziTestTasks::RESULTS[r && true]}" Plezi.start_async puts " --- Plezi will ran async, performing some tests that than hang" puts " --- Starting tests"