def test_slow_streaming(): """ TEST THAT THE app ACTUALLY STREAMS. WE SHOULD GET A RESPONSE BEFORE THE SERVER FINISHES DELIVERING """ slow_server_thread = Thread.run("run slow server", run_slow_server) proxy_thread = Thread.run("run proxy", run_proxy) try: proxy_is_ready.wait_for_go() server_is_ready.wait_for_go() start = time.clock() response = requests.get("http://localhost:" + str(PROXY_PORT) + PATH, stream=True) for i, data in enumerate(stream(response.raw)): Log.note("CLIENT GOT RESPONSE:\n{{data|indent}}", {"data": data}) end = time.clock() if i == 0 and end - start > 10: # IF WE GET DATA BEFORE 10sec, THEN WE KNOW WE ARE STREAMING Log.error("should have something by now") if response.status_code != 200: Log.error("Expecting a positive response") except Exception, e: Log.error("Not expected", e)
def octoberfest(): for bb in range(99, 2, -1): yield ("0" * 65535) + "\n" # ENOUGH TO FILL THE INCOMING BUFFER Thread.sleep(1.0 / RATE) yield CNV.unicode2utf8( expand_template( "{{num}} bottles of beer on the wall! {{num}} bottles of beer! Take one down, pass it around! {{less}} bottles of beer on he wall!\n", {"num": bb, "less": bb - 1}, ) ) yield ("0" * 65535) + "\n" # ENOUGH TO FILL THE INCOMING BUFFER yield CNV.unicode2utf8( u"2 bottles of beer on the wall! 2 bottles of beer! Take one down, pass it around! 1 bottle of beer on he wall!\n" ) yield ("0" * 65535) + "\n" # ENOUGH TO FILL THE INCOMING BUFFER yield CNV.unicode2utf8( u"1 bottle of beer on the wall! 1 bottle of beer! Take one down, pass it around! 0 bottles of beer on he wall.\n" )
def main(): url = "http://localhost:9292" thread = Thread.run("run app", run_app) try: server_is_ready.wait_for_go() all_tests(url) finally: thread.please_stop.go() Log.stop()
def octoberfest(): for bb in range(99, 2, -1): yield ("0" * 65535) + "\n" # ENOUGH TO FILL THE INCOMING BUFFER Thread.sleep(1.0 / RATE) yield CNV.unicode2utf8( expand_template( "{{num}} bottles of beer on the wall! {{num}} bottles of beer! Take one down, pass it around! {{less}} bottles of beer on he wall!\n", { "num": bb, "less": bb - 1 })) yield ("0" * 65535) + "\n" # ENOUGH TO FILL THE INCOMING BUFFER yield CNV.unicode2utf8( u"2 bottles of beer on the wall! 2 bottles of beer! Take one down, pass it around! 1 bottle of beer on he wall!\n" ) yield ("0" * 65535) + "\n" # ENOUGH TO FILL THE INCOMING BUFFER yield CNV.unicode2utf8( u"1 bottle of beer on the wall! 1 bottle of beer! Take one down, pass it around! 0 bottles of beer on he wall.\n" )