Skip to content

Commit

Permalink
Adding auth support in testDispatcher
Browse files Browse the repository at this point in the history
Change-Id: Ie2fd56884dc73d6464000b58773e6ac8f58cda41
Reviewed-on: https://review.couchbase.org/c/testrunner/+/175458
Tested-by: Bharath G P <bharath.gp@couchbase.com>
Reviewed-by: Bharath G P <bharath.gp@couchbase.com>
  • Loading branch information
ashwin2002 authored and bharath-gp committed May 30, 2022
1 parent 3708c28 commit 0b98155
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/testDispatcher.py
@@ -1,3 +1,4 @@
import base64
import sys
import urllib.request, urllib.error, urllib.parse
import urllib.request, urllib.parse, urllib.error
Expand Down Expand Up @@ -685,7 +686,7 @@ def main():
descriptor = testsToLaunch[i]['component'] + '-' + testsToLaunch[i]['subcomponent'] + '-' + time.strftime('%b-%d-%X') + '-' + options.version

if options.serverType == GCP:
# GCP labels are limited to 63 characters which might be too small.
# GCP labels are limited to 63 characters which might be too small.
# Must also start with a lowercase letter. Just use a UUID which is 32 characters.
descriptor = "testrunner-" + str(uuid4())
elif options.serverType == AWS:
Expand Down Expand Up @@ -840,7 +841,19 @@ def main():
else:
release_servers(options, descriptor)
else:
response, content = httplib2.Http(timeout=TIMEOUT).request(url, 'GET')
doc = cb.get("jenkins_cred")
if not doc.success:
raise Exception(
"Cred doc missing in QE_Test-Suites bucket")
doc = doc.value
credentials = "%s:%s" % (doc["username"], doc["password"])
auth = base64.encodebytes(credentials.encode('utf-8'))
auth = auth.decode('utf-8').rstrip('\n')
header = {'Content-Type': 'application/json',
'Authorization': 'Basic %s' % auth,
'Accept': '*/*'}
response, content = httplib2.Http(timeout=TIMEOUT)\
.request(url, 'GET', headers=header)
print("Response is: {0}".format(str(response)))
print("Content is: {0}".format(str(content)))
if int(response['status'])>=400:
Expand Down

0 comments on commit 0b98155

Please sign in to comment.