From 06e6013ec1ed59c0f1137510d90d4c8af1d3db49 Mon Sep 17 00:00:00 2001 From: Shilpa Jagannath Date: Tue, 5 May 2020 12:07:45 +0530 Subject: [PATCH] qa/rgw: add ssl option in reshard tests Signed-off-by: Shilpa Jagannath --- qa/workunits/rgw/run-reshard.sh | 1 + qa/workunits/rgw/test_rgw_reshard.py | 39 +++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/qa/workunits/rgw/run-reshard.sh b/qa/workunits/rgw/run-reshard.sh index 42c97ce9d02a2..89ebc41062dce 100755 --- a/qa/workunits/rgw/run-reshard.sh +++ b/qa/workunits/rgw/run-reshard.sh @@ -2,6 +2,7 @@ set -ex #assume working ceph environment (radosgw-admin in path) and rgw on localhost:80 +# localhost::443 for ssl mydir=`dirname $0` diff --git a/qa/workunits/rgw/test_rgw_reshard.py b/qa/workunits/rgw/test_rgw_reshard.py index c69b305e98281..14f4fe5099469 100755 --- a/qa/workunits/rgw/test_rgw_reshard.py +++ b/qa/workunits/rgw/test_rgw_reshard.py @@ -4,6 +4,7 @@ import logging as log import time import subprocess import json +import boto3 """ Rgw manual and dynamic resharding testing against a running instance @@ -20,7 +21,6 @@ log.getLogger('botocore').setLevel(log.CRITICAL) log.getLogger('boto3').setLevel(log.CRITICAL) log.getLogger('urllib3').setLevel(log.CRITICAL) - """ Constants """ USER = 'tester' DISPLAY_NAME = 'Testing' @@ -29,7 +29,6 @@ SECRET_KEY = 'LnEsqNNqZIpkzauboDcLXLcYaWwLQ3Kop0zAnKIn' BUCKET_NAME1 = 'myfoo' BUCKET_NAME2 = 'mybar' VER_BUCKET_NAME = 'myver' -ENDPOINT = 'http://localhost:80' def exec_cmd(cmd): @@ -48,7 +47,13 @@ def exec_cmd(cmd): return False -import boto3 +def get_radosgw_port(): + out = exec_cmd('sudo netstat -nltp | grep radosgw') + log.debug('output: %s' % out) + x = out.decode('utf8').split(" ") + port = [i for i in x if ':' in i][0].split(':')[1] + log.info('radosgw port: %s' % port) + return port class BucketStats: @@ -100,17 +105,27 @@ def main(): execute manual and dynamic resharding commands """ # create user - cmd = exec_cmd('radosgw-admin user create --uid %s --display-name %s --access-key %s --secret %s' + exec_cmd('radosgw-admin user create --uid %s --display-name %s --access-key %s --secret %s' % (USER, DISPLAY_NAME, ACCESS_KEY, SECRET_KEY)) - connection = boto3.resource('s3', - aws_access_key_id=ACCESS_KEY, - aws_secret_access_key=SECRET_KEY, - use_ssl=False, - endpoint_url=ENDPOINT, - verify=False, - config=None, - ) + def boto_connect(portnum, ssl, proto): + endpoint = proto + '://localhost:' + portnum + conn = boto3.resource('s3', + aws_access_key_id=ACCESS_KEY, + aws_secret_access_key=SECRET_KEY, + use_ssl=ssl, + endpoint_url=endpoint, + verify=False, + config=None, + ) + return conn + + port = get_radosgw_port() + + if port == '80': + connection = boto_connect(port, ssl=False, proto='http') + elif port == '443': + connection = boto_connect(port, ssl=True, proto='https') # create a bucket bucket1 = connection.create_bucket(Bucket=BUCKET_NAME1) -- 2.39.5