Created
March 24, 2014 19:44
-
-
Save dpgoetz/9747591 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import httplib | |
import json | |
import sys | |
if len(sys.argv) < 3: | |
print 'example: slob_test.py /v1/AUTH_dfg AUTH_tk81f3f8d0c2f34f706c48c' | |
sys.exit() | |
reset_conn = False | |
acc_path = sys.argv[1] | |
token = sys.argv[2] | |
h = httplib.HTTPConnection('127.0.0.1:8080') | |
h.request("PUT", acc_path + '/hat', | |
headers={'X-Auth-Token': token}) | |
resp = h.getresponse() | |
resp.read() | |
outer_manifest = [] | |
#first subman | |
manifest = [] | |
for i in range(5): | |
h.request("PUT", '%s/hat/%s' % (acc_path, i), | |
body=str(i)*5, | |
headers={'X-Auth-Token': token}) | |
resp = h.getresponse() | |
resp.read() | |
hdrs = dict(resp.getheaders()) | |
manifest.append( | |
{'path': 'hat/%s' % i, "etag": hdrs['etag'], 'size_bytes': 5}) | |
h.request("PUT", "%s/hat/sub1?multipart-manifest=put" % acc_path, | |
body=json.dumps(manifest), | |
headers={'X-Auth-Token': token}) | |
resp = h.getresponse() | |
resp.read() | |
hdrs = dict(resp.getheaders()) | |
outer_manifest.append( | |
{'path': 'hat/sub1', "etag": hdrs['etag'].strip('"'), 'size_bytes': 25}) | |
#next subman | |
manifest = [] | |
for i in range(5,10): | |
h.request("PUT", '%s/hat/%s' % (acc_path, i), | |
body=str(i)*5, | |
headers={'X-Auth-Token': token}) | |
resp = h.getresponse() | |
resp.read() | |
hdrs = dict(resp.getheaders()) | |
manifest.append( | |
{'path': 'hat/%s' % i, "etag": hdrs['etag'], 'size_bytes': 5}) | |
h.request("PUT", "%s/hat/sub2?multipart-manifest=put" % acc_path, | |
body=json.dumps(manifest), | |
headers={'X-Auth-Token': token}) | |
resp = h.getresponse() | |
resp.read() | |
hdrs = dict(resp.getheaders()) | |
outer_manifest.append( | |
{'path': 'hat/sub2', "etag": hdrs['etag'].strip('"'), 'size_bytes': 25}) | |
#outer man | |
h.request("PUT", "%s/hat/man?multipart-manifest=put" % acc_path, | |
body=json.dumps(outer_manifest), | |
headers={'X-Auth-Token': token}) | |
resp = h.getresponse() | |
resp.read() | |
h.close() | |
########### START TEST ################# | |
h = httplib.HTTPConnection('127.0.0.1:8080') | |
test_path = acc_path + '/hat/man' | |
h.request("GET", test_path, | |
headers={'X-Auth-Token': token, | |
'Range': 'bytes=0-4'}) | |
resp = h.getresponse() | |
print '5 0s: %s: %s: %s' % (resp.status, resp.read(), dict(resp.getheaders())) | |
if reset_conn: | |
h.close() | |
h = httplib.HTTPConnection('127.0.0.1:8080') | |
h.request("GET", test_path, | |
headers={'X-Auth-Token': token, | |
'Range': 'bytes=5-9'}) | |
resp = h.getresponse() | |
print '5 1s: %s: %s: %s' % (resp.status, resp.read(), dict(resp.getheaders())) | |
if reset_conn: | |
h.close() | |
h = httplib.HTTPConnection('127.0.0.1:8080') | |
h.request("GET", test_path, | |
headers={'X-Auth-Token': token, | |
'Range': 'bytes=10-14'}) | |
resp = h.getresponse() | |
print '5 2s: %s: %s: %s' % (resp.status, resp.read(), dict(resp.getheaders())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this runs fine if
reset_conn = True
and
reset_conn = False
test_path = acc_path + '/hat/sub1'