]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/rgw: add class for rgw endpoints
authorCasey Bodley <cbodley@redhat.com>
Wed, 21 Feb 2018 16:19:48 +0000 (11:19 -0500)
committerCasey Bodley <cbodley@redhat.com>
Fri, 9 Mar 2018 21:31:32 +0000 (16:31 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
qa/tasks/radosgw_admin.py
qa/tasks/ragweed.py
qa/tasks/rgw.py
qa/tasks/rgw_multisite.py
qa/tasks/s3tests.py
qa/tasks/swift.py

index f23a3b9ef409202299a8a045d4eaeecb492282fd..8686f7ad21fc33e79e86baea128fffecca0cf5bd 100644 (file)
@@ -279,7 +279,7 @@ def task(ctx, config):
 
     # once the client is chosen, pull the host name and  assigned port out of
     # the role_endpoints that were assigned by the rgw task
-    (remote_host, remote_port) = ctx.rgw.role_endpoints[client]
+    endpoint = ctx.rgw.role_endpoints[client]
 
     ##
     user1='foo'
@@ -305,16 +305,16 @@ def task(ctx, config):
         aws_access_key_id=access_key,
         aws_secret_access_key=secret_key,
         is_secure=False,
-        port=remote_port,
-        host=remote_host,
+        port=endpoint.port,
+        host=endpoint.hostname,
         calling_format=boto.s3.connection.OrdinaryCallingFormat(),
         )
     connection2 = boto.s3.connection.S3Connection(
         aws_access_key_id=access_key2,
         aws_secret_access_key=secret_key2,
         is_secure=False,
-        port=remote_port,
-        host=remote_host,
+        port=endpoint.port,
+        host=endpoint.hostname,
         calling_format=boto.s3.connection.OrdinaryCallingFormat(),
         )
 
index b1586914f029d2a8bda1828bebc8d778cac8b030..2080ccbd9acb9d9149f776a76fbd4077b5cb3058 100644 (file)
@@ -308,6 +308,7 @@ def task(ctx, config):
             client.1:
               extra_args: ['--exclude', 'test_100_continue']
     """
+    assert hasattr(ctx, 'rgw'), 'ragweed must run after the rgw task'
     assert config is None or isinstance(config, list) \
         or isinstance(config, dict), \
         "task ragweed only supports a list or dictionary for configuration"
@@ -330,12 +331,15 @@ def task(ctx, config):
 
     ragweed_conf = {}
     for client in clients:
+        endpoint = ctx.rgw.role_endpoints.get(client)
+        assert endpoint, 'ragweed: no rgw endpoint for {}'.format(client)
+
         ragweed_conf[client] = ConfigObj(
             indent_type='',
             infile={
                 'rgw':
                     {
-                    'port'      : 7280,
+                    'port'      : endpoint.port,
                     'is_secure' : 'no',
                     },
                 'fixtures' : {},
index 54c281a5a46247e0231497080d1f3042c88ce5c1..4ba7bf9383120cd3e474ecb3435276ed894866c5 100644 (file)
@@ -13,6 +13,7 @@ from teuthology.orchestra import run
 from teuthology import misc as teuthology
 from teuthology import contextutil
 from teuthology.orchestra.run import CommandFailedError
+from util import get_remote_for_role
 from util.rgw import rgwadmin, wait_for_radosgw
 from util.rados import (rados, create_ec_pool,
                                         create_replicated_pool,
@@ -20,6 +21,14 @@ from util.rados import (rados, create_ec_pool,
 
 log = logging.getLogger(__name__)
 
+class RGWEndpoint:
+    def __init__(self, hostname=None, port=None):
+        self.hostname = hostname
+        self.port = port
+
+    def url(self):
+        return 'http://{hostname}:{port}/'.format(hostname=self.hostname, port=self.port)
+
 @contextlib.contextmanager
 def start_rgw(ctx, config, clients):
     """
@@ -50,10 +59,10 @@ def start_rgw(ctx, config, clients):
 
         log.info("Using %s as radosgw frontend", ctx.rgw.frontend)
 
-        host, port = ctx.rgw.role_endpoints[client]
+        endpoint = ctx.rgw.role_endpoints[client]
         frontends = \
             '{frontend} port={port}'.format(frontend=ctx.rgw.frontend,
-                                            port=port)
+                                            port=endpoint.port)
         frontend_prefix = client_config.get('frontend_prefix', None)
         if frontend_prefix:
             frontends += ' prefix={pfx}'.format(pfx=frontend_prefix)
@@ -73,8 +82,8 @@ def start_rgw(ctx, config, clients):
         if keystone_role is not None:
             if not ctx.keystone:
                 raise ConfigError('rgw must run after the keystone task')
-            url = 'http://{host}:{port}/v1/KEY_$(tenant_id)s'.format(host=host,
-                                                                     port=port)
+            url = 'http://{host}:{port}/v1/KEY_$(tenant_id)s'.format(host=endpoint.hostname,
+                                                                     port=endpoint.port)
             ctx.keystone.create_endpoint(ctx, keystone_role, 'swift', url)
 
             keystone_host, keystone_port = \
@@ -117,10 +126,10 @@ def start_rgw(ctx, config, clients):
 
     # XXX: add_daemon() doesn't let us wait until radosgw finishes startup
     for client in config.keys():
-        host, port = ctx.rgw.role_endpoints[client]
-        endpoint = 'http://{host}:{port}/'.format(host=host, port=port)
-        log.info('Polling {client} until it starts accepting connections on {endpoint}'.format(client=client, endpoint=endpoint))
-        wait_for_radosgw(endpoint)
+        endpoint = ctx.rgw.role_endpoints[client]
+        url = endpoint.url()
+        log.info('Polling {client} until it starts accepting connections on {url}'.format(client=client, url=url))
+        wait_for_radosgw(url)
 
     try:
         yield
@@ -139,17 +148,18 @@ def start_rgw(ctx, config, clients):
                     ],
                 )
 
-def assign_ports(ctx, config):
+def assign_endpoints(ctx, config):
     """
-    Assign port numberst starting with port 7280.
+    Assign port numbers starting with port 7280.
     """
     port = 7280
     role_endpoints = {}
-    for remote, roles_for_host in ctx.cluster.remotes.iteritems():
-        for role in roles_for_host:
-            if role in config:
-                role_endpoints[role] = (remote.name.split('@')[1], port)
-                port += 1
+
+    for role, client_config in config.iteritems():
+        client_config = client_config or {}
+        remote = get_remote_for_role(ctx, role)
+        role_endpoints[role] = RGWEndpoint(remote.hostname, port)
+        port += 1
 
     return role_endpoints
 
@@ -236,9 +246,7 @@ def task(ctx, config):
     overrides = ctx.config.get('overrides', {})
     teuthology.deep_merge(config, overrides.get('rgw', {}))
 
-    role_endpoints = assign_ports(ctx, config)
     ctx.rgw = argparse.Namespace()
-    ctx.rgw.role_endpoints = role_endpoints
 
     ctx.rgw.ec_data_pool = bool(config.pop('ec-data-pool', False))
     ctx.rgw.erasure_code_profile = config.pop('erasure_code_profile', {})
@@ -249,6 +257,9 @@ def task(ctx, config):
 
     log.debug("config is {}".format(config))
     log.debug("client list is {}".format(clients))
+
+    ctx.rgw.role_endpoints = assign_endpoints(ctx, config)
+
     subtasks = [
         lambda: create_pools(ctx=ctx, clients=clients),
     ]
index 668696b63b47114ee5d063838b12a4d61070be31..a3697278ac26ed48a4c7034ebb3261732cbe2add 100644 (file)
@@ -236,7 +236,7 @@ def extract_clusters_and_gateways(ctx, role_endpoints):
     """ create cluster and gateway instances for all of the radosgw roles """
     clusters = {}
     gateways = {}
-    for role, (host, port) in role_endpoints.iteritems():
+    for role, endpoint in role_endpoints.iteritems():
         cluster_name, daemon_type, client_id = misc.split_role(role)
         # find or create the cluster by name
         cluster = clusters.get(cluster_name)
@@ -249,7 +249,8 @@ def extract_clusters_and_gateways(ctx, role_endpoints):
             raise ConfigError('no daemon for role=%s cluster=%s type=rgw id=%s' % \
                               (role, cluster_name, client_id))
         (remote,) = ctx.cluster.only(role).remotes.keys()
-        gateways[role] = Gateway(role, remote, daemon, host, port, cluster)
+        gateways[role] = Gateway(role, remote, daemon, endpoint.hostname,
+                endpoint.port, cluster)
     return clusters, gateways
 
 def create_realm(cluster, config):
index 00bc6b4e34aef12e2ed8a59633a9ca27b3ce055d..2068711c68245f2b77954a8f8a3e6fe0e5468117 100644 (file)
@@ -335,6 +335,7 @@ def task(ctx, config):
             client.1:
               extra_args: ['--exclude', 'test_100_continue']
     """
+    assert hasattr(ctx, 'rgw'), 's3tests must run after the rgw task'
     assert config is None or isinstance(config, list) \
         or isinstance(config, dict), \
         "task s3tests only supports a list or dictionary for configuration"
@@ -357,12 +358,15 @@ def task(ctx, config):
 
     s3tests_conf = {}
     for client in clients:
+        endpoint = ctx.rgw.role_endpoints.get(client)
+        assert endpoint, 's3tests: no rgw endpoint for {}'.format(client)
+
         s3tests_conf[client] = ConfigObj(
             indent_type='',
             infile={
                 'DEFAULT':
                     {
-                    'port'      : 7280,
+                    'port'      : endpoint.port,
                     'is_secure' : 'no',
                     },
                 'fixtures' : {},
index 28f75dd0afde99135ffb621f3c88e5e56331a4be..81d686b0f0b1dd2cbda51274d062b44f119b40bd 100644 (file)
@@ -220,6 +220,7 @@ def task(ctx, config):
             client.1:
               extra_args: ['--exclude', 'TestFile']
     """
+    assert hasattr(ctx, 'rgw'), 'swift must run after the rgw task'
     assert config is None or isinstance(config, list) \
         or isinstance(config, dict), \
         "task testswift only supports a list or dictionary for configuration"
@@ -235,12 +236,15 @@ def task(ctx, config):
 
     testswift_conf = {}
     for client in clients:
+        endpoint = ctx.rgw.role_endpoints.get(client)
+        assert endpoint, 'swift: no rgw endpoint for {}'.format(client)
+
         testswift_conf[client] = ConfigObj(
                 indent_type='',
                 infile={
                     'func_test':
                         {
-                        'auth_port'      : 7280,
+                        'auth_port'      : endpoint.port,
                         'auth_ssl' : 'no',
                         'auth_prefix' : '/auth/',
                         },