include BenchHelpers bench_log "Runs simple login,clientcreate,clientregister,sync session and validates response" Bench.config do |config| config.concurrency ||= 10 config.iterations ||= 10 config.datasize ||= 100 config.main_marker = 'get-cud' config.user_name = "benchuser" config.password = "password" config.get_test_server @datasize = Bench.datasize @expected = Bench.get_test_data(@datasize) @all_objects = "[{\"version\":3},{\"token\":\"%s\"},{\"count\":%i},{\"progress_count\":0},{\"total_count\":%i},{\"insert\":""}]" @ack_token = "[{\"version\":3},{\"token\":\"\"},{\"count\":0},{\"progress_count\":%i},{\"total_count\":%i},{}]" @api_token = Bench.get_token config.request_logging = false # if this is not a distributed run - reset the app if not Bench.sync_key config.reset_app config.set_server_state("test_db_storage:application:#{config.user_name}",@expected) config.reset_refresh_time('MockAdapter') end end Bench.synchronize do |config| break unless Bench.sync_key while true cur_time = Time.now.to_f sync_time = Bench.get_server_value(Bench.sync_key).to_f if sync_time > 0.0 and cur_time >= sync_time break end sleep(0.010) end puts " we have here #{cur_time}, #{sync_time}" end Bench.test do |config,session| session.post "clientlogin", "#{config.base_url}/clientlogin", :content_type => :json do {:login => config.user_name, :password => config.password}.to_json end session.get "clientcreate", "#{config.base_url}/clientcreate" client_id = JSON.parse(session.last_result.body)['client']['client_id'] session.client_id = client_id session.post "clientregister", "#{config.base_url}/clientregister", :content_type => :json do {:device_type => "Apple", :device_pin => 'somepin123', :device_port => "device_port_111", :phone_id => 'unique_phone_id', :client_id => client_id}.to_json end session.get "get-cud", "#{config.base_url}/query" do {'source_name' => 'MockAdapter', 'client_id' => session.client_id, 'p_size' => @datasize} end token = JSON.parse(session.last_result.body)[1]['token'] session.get "ack-cud", "#{config.base_url}/query" do { 'source_name' => 'MockAdapter', 'client_id' => session.client_id, 'token' => token} end session.last_result.verify_code(200) session.last_result.verify_body([{:version => 3},{:token => ''},{:count => 0}, {:progress_count => @datasize},{:total_count => @datasize},{}].to_json) end