def target_wsgi_application(environ, start_response): status = '200 OK' txn_name = environ.get('txn') if six.PY2: txn_name = txn_name.decode('UTF-8') txn_name = txn_name.split('/', 3) guid = environ.get('guid') old_cat = environ.get('old_cat') == 'True' txn = current_transaction() txn.guid = guid for req in OUTBOUD_REQUESTS: # Change the transaction name before making an outbound call. outgoing_name = req['outboundTxnName'].split('/', 3) if outgoing_name[0] != 'WebTransaction': set_background_task(True) set_transaction_name(outgoing_name[2], group=outgoing_name[1]) expected_outbound_header = obfuscate( json_encode(req['expectedOutboundPayload']), ENCODING_KEY) generated_outbound_header = dict( ExternalTrace.generate_request_headers(txn)) # A 500 error is returned because 'assert' statements in the wsgi app # are ignored. if old_cat: if (expected_outbound_header != generated_outbound_header['X-NewRelic-Transaction']): status = '500 Outbound Headers Check Failed.' else: if 'X-NewRelic-Transaction' in generated_outbound_header: status = '500 Outbound Headers Check Failed.' r = urlopen(environ['server_url']) r.read(10) # Set the final transaction name. if txn_name[0] != 'WebTransaction': set_background_task(True) set_transaction_name(txn_name[2], group=txn_name[1]) text = '<html><head>%s</head><body><p>RESPONSE</p>%s</body></html>' output = (text % (get_browser_timing_header(), get_browser_timing_footer())).encode('UTF-8') response_headers = [('Content-type', 'text/html; charset=utf-8'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]
def test_wt_set_get_delete(): set_background_task(False) client = bmemcached.Client([MEMCACHED_ADDR]) key = MEMCACHED_NAMESPACE + 'key' client.set(key, 'value') value = client.get(key) client.delete(key) assert value == 'value'
def test_bt_set_get_delete(): set_background_task(True) client = pylibmc.Client([MEMCACHED_ADDR]) key = MEMCACHED_NAMESPACE + 'key' client.set(key, 'value') value = client.get(key) client.delete(key) assert value == 'value'
def test_bt_set_get_delete(): set_background_task(True) client = pymemcache.client.Client(MEMCACHED_ADDR) key = MEMCACHED_NAMESPACE + 'key' client.set(key, b'value') value = client.get(key) client.delete(key) assert value == b'value'
def test_wt_set_get_delete(): set_background_task(False) client = umemcache.Client(MEMCACHED_ADDR) client.connect() key = MEMCACHED_NAMESPACE + 'key' client.set(key, 'value') value = client.get(key)[0] client.delete(key) assert value == 'value'
def test_wt_set_incr_decr(): set_background_task(False) client = umemcache.Client(MEMCACHED_ADDR) client.connect() key = MEMCACHED_NAMESPACE + 'key' client.set(key, '667') value = client.get(key)[0] client.incr(key, 1) client.incr(key, 1) client.decr(key, 1) value = client.get(key)[0] assert value == '668' d = client.stats() assert d.has_key('uptime') assert d.has_key('bytes')
def test_transaction_name_default_wt(): set_background_task(False)