Skip to content

Commit

Permalink
[#1883] add http_proxy usage to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trel committed Aug 23, 2019
1 parent dc9da3c commit 9a65f29
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions packaging/test_irods_resource_plugin_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import shutil
import string
import subprocess
import urllib3

from resource_suite_s3_nocache import Test_S3_NoCache_Base

Expand Down Expand Up @@ -51,7 +52,23 @@ def setUp(self):
self.read_aws_keys()

# set up s3 bucket
s3_client = Minio(self.s3endPoint, access_key=self.aws_access_key_id, secret_key=self.aws_secret_access_key)
try:
httpClient = urllib3.poolmanager.ProxyManager(
os.environ['http_proxy'],
timeout=urllib3.Timeout.DEFAULT_TIMEOUT,
cert_reqs='CERT_REQUIRED',
retries=urllib3.Retry(
total=5,
backoff_factor=0.2,
status_forcelist=[500, 502, 503, 504]
)
)
except KeyError:
httpClient = None
s3_client = Minio(self.s3endPoint,
access_key=self.aws_access_key_id,
secret_key=self.aws_secret_access_key,
http_client=httpClient)

self.s3bucketname = 'irods-ci-' + distro_str + datetime.datetime.utcnow().strftime('-%Y-%m-%d.%H-%M-%S-%f-')
self.s3bucketname += ''.join(random.choice(string.letters) for i in xrange(10))
Expand Down Expand Up @@ -89,7 +106,24 @@ def tearDown(self):
super(Test_Compound_With_S3_Resource, self).tearDown()

# delete s3 bucket
s3_client = Minio(self.s3endPoint, access_key=self.aws_access_key_id, secret_key=self.aws_secret_access_key)
try:
httpClient = urllib3.poolmanager.ProxyManager(
os.environ['http_proxy'],
timeout=urllib3.Timeout.DEFAULT_TIMEOUT,
cert_reqs='CERT_REQUIRED',
retries=urllib3.Retry(
total=5,
backoff_factor=0.2,
status_forcelist=[500, 502, 503, 504]
)
)
except KeyError:
httpClient = None
s3_client = Minio(self.s3endPoint,
access_key=self.aws_access_key_id,
secret_key=self.aws_secret_access_key,
http_client=httpClient)

objects = s3_client.list_objects_v2(self.s3bucketname, recursive=True)
s3_client.remove_objects(self.s3bucketname, objects)
s3_client.remove_bucket(self.s3bucketname)
Expand Down

0 comments on commit 9a65f29

Please sign in to comment.