Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit 42600ad

Browse files
author
Mangled Deutz
committed
Partly fix workflow test, and fix travis build
Docker-DCO-1.1-Signed-off-by: Mangled Deutz <[email protected]> (github: dmp42)
1 parent d4b9054 commit 42600ad

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

tests/workflow.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import os
33

44
import requests
5+
sess = requests.Session()
6+
adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100)
7+
sess.mount('https://', adapter)
8+
requests = sess
59

610
from docker_registry.lib import checksums
711
from docker_registry.lib import config
@@ -15,6 +19,8 @@
1519

1620
cfg = config.load()
1721

22+
ua = 'docker/1.0.0 registry test pretending to be docker'
23+
1824

1925
class TestWorkflow(base.TestCase):
2026

@@ -32,7 +38,7 @@ class TestWorkflow(base.TestCase):
3238

3339
def generate_chunk(self, data):
3440
bufsize = 1024
35-
io = StringIO.StringIO(data)
41+
io = StringIO(data)
3642
while True:
3743
buf = io.read(bufsize)
3844
if not buf:
@@ -60,14 +66,16 @@ def upload_image(self, image_id, parent_id, token):
6066
self.registry_endpoint, image_id),
6167
data=json_data,
6268
headers={'Authorization': 'Token ' + token,
69+
'User-Agent': ua,
6370
'X-Docker-Checksum': layer_checksum},
6471
cookies=self.cookies)
6572
self.assertEqual(resp.status_code, 200, resp.text)
6673
self.update_cookies(resp)
6774
resp = requests.put('{0}/v1/images/{1}/layer'.format(
6875
self.registry_endpoint, image_id),
6976
data=self.generate_chunk(layer),
70-
headers={'Authorization': 'Token ' + token},
77+
headers={'Authorization': 'Token ' + token,
78+
'User-Agent': ua},
7179
cookies=self.cookies)
7280
self.assertEqual(resp.status_code, 200, resp.text)
7381
self.update_cookies(resp)
@@ -94,7 +102,8 @@ def docker_push(self):
94102
resp = requests.put('{0}/v1/repositories/{1}/{2}/'.format(
95103
self.index_endpoint, namespace, repos),
96104
auth=tuple(self.user_credentials),
97-
headers={'X-Docker-Token': 'true'},
105+
headers={'X-Docker-Token': 'true',
106+
'User-Agent': ua},
98107
data=images_json)
99108
self.assertEqual(resp.status_code, 200, resp.text)
100109
token = resp.headers.get('x-docker-token')
@@ -108,7 +117,8 @@ def docker_push(self):
108117
resp = requests.put('{0}/v1/repositories/{1}/{2}/images'.format(
109118
self.index_endpoint, namespace, repos),
110119
auth=tuple(self.user_credentials),
111-
headers={'X-Endpoints': self.registry_endpoint},
120+
headers={'X-Endpoints': self.registry_endpoint,
121+
'User-Agent': ua},
112122
data=json.dumps(images_json))
113123
self.assertEqual(resp.status_code, 204)
114124
return (namespace, repos)
@@ -160,7 +170,7 @@ def docker_pull(self, namespace, repos):
160170
json_data, checksum, blob = self.fetch_image(image_id)
161171
# check queried checksum and local computed checksum from the image
162172
# are the same
163-
tmpfile = StringIO.StringIO()
173+
tmpfile = StringIO()
164174
tmpfile.write(blob)
165175
tmpfile.seek(0)
166176
computed_checksum = checksums.compute_simple(tmpfile, json_data)

0 commit comments

Comments
 (0)