From f2a84540bc148a1084f1bbd6ccffc4e12e1af2ee Mon Sep 17 00:00:00 2001 From: Samarah Date: Fri, 1 Mar 2024 17:15:36 +0000 Subject: [PATCH] qa/d4n: Start redis up before rgw Signed-off-by: Samarah --- qa/suites/rgw/d4n/tasks/rgw_d4ntests.yaml | 2 + qa/tasks/d4ntests.py | 42 ------------ qa/tasks/redis.py | 84 +++++++++++++++++++++++ 3 files changed, 86 insertions(+), 42 deletions(-) create mode 100644 qa/tasks/redis.py diff --git a/qa/suites/rgw/d4n/tasks/rgw_d4ntests.yaml b/qa/suites/rgw/d4n/tasks/rgw_d4ntests.yaml index 893119e82d5d9..ed63bc2fc895e 100644 --- a/qa/suites/rgw/d4n/tasks/rgw_d4ntests.yaml +++ b/qa/suites/rgw/d4n/tasks/rgw_d4ntests.yaml @@ -5,6 +5,8 @@ tasks: deb: ['s3cmd', 'redis'] rpm: ['s3cmd', 'redis'] - ceph: +- redis: + client.0: - rgw: [client.0] - tox: [client.0] - exec: diff --git a/qa/tasks/d4ntests.py b/qa/tasks/d4ntests.py index 9a7b6a1f6d6a1..d943bf962f104 100644 --- a/qa/tasks/d4ntests.py +++ b/qa/tasks/d4ntests.py @@ -7,13 +7,6 @@ from teuthology.packaging import remove_package log = logging.getLogger(__name__) -def get_toxvenv_dir(ctx): - return ctx.tox.venv_path - -def toxvenv_sh(ctx, remote, args, **kwargs): - activate = get_toxvenv_dir(ctx) + '/bin/activate' - return remote.sh(['source', activate, run.Raw('&&')] + args, **kwargs) - display_name='Foo' email='foo@foo.com' access_key='test3' @@ -50,14 +43,11 @@ class D4NTests(Task): log.debug('D4N Tests: Host is: {host}'.format(host=host)) self.create_user() - self.redis_startup() def end(self): super(D4NTests, self).end() log.info('D4N Tests: END') - self.redis_shutdown() - for client in self.all_clients: self.remove_packages(client) self.delete_user(client) @@ -92,41 +82,9 @@ class D4NTests(Task): ], ) - def redis_startup(self): - try: - for client in self.all_clients: - self.ctx.cluster.only(client).run( - args=[ - 'sudo', - 'redis-server', - '--daemonize', - 'yes' - ], - ) - - except Exception as err: - log.debug('D4N Tests: Error starting up a Redis server') - log.debug(err) - - def redis_shutdown(self): - try: - for client in self.all_clients: - self.ctx.cluster.only(client).run( - args=[ - 'sudo', - 'redis-cli', - 'shutdown', - ], - ) - - except Exception as err: - log.debug('D4N Tests: Error shutting down a Redis server') - log.debug(err) - def remove_packages(self, client): (remote,) = self.ctx.cluster.only(client).remotes.keys() remove_package('s3cmd', remote) - remove_package('redis', remote) def delete_user(self, client): log.info("D4N Tests: Deleting S3 user...") diff --git a/qa/tasks/redis.py b/qa/tasks/redis.py new file mode 100644 index 0000000000000..1124f6026c08b --- /dev/null +++ b/qa/tasks/redis.py @@ -0,0 +1,84 @@ +import logging + +from teuthology import misc as teuthology +from teuthology.task import Task +from teuthology.orchestra import run +from teuthology.packaging import remove_package + +log = logging.getLogger(__name__) + +class Redis(Task): + + def __init__(self, ctx, config): + super(Redis, self).__init__(ctx, config) + self.log = log + log.info('Redis Task: __INIT__ ') + + clients = ['client.{id}'.format(id=id_) + for id_ in teuthology.all_roles_of_type(self.ctx.cluster, 'client')] + self.all_clients = [] + for client in clients: + if client in self.config: + self.all_clients.extend([client]) + if self.all_clients is None: + self.all_clients = 'client.0' + + def setup(self): + super(Redis, self).setup() + log.info('Redis Task: SETUP') + + def begin(self): + super(Redis, self).begin() + log.info('Redis Task: BEGIN') + + for (host, roles) in self.ctx.cluster.remotes.items(): + log.debug('Redis Task: Cluster config is: {cfg}'.format(cfg=roles)) + log.debug('Redis Task: Host is: {host}'.format(host=host)) + + self.redis_startup() + + def end(self): + super(Redis, self).end() + log.info('Redis Task: END') + + self.redis_shutdown() + + for client in self.all_clients: + self.remove_redis_package(client) + + def redis_startup(self): + try: + for client in self.all_clients: + self.ctx.cluster.only(client).run( + args=[ + 'sudo', + 'redis-server', + '--daemonize', + 'yes' + ], + ) + + except Exception as err: + log.debug('Redis Task: Error starting up a Redis server') + log.debug(err) + + def redis_shutdown(self): + try: + for client in self.all_clients: + self.ctx.cluster.only(client).run( + args=[ + 'sudo', + 'redis-cli', + 'shutdown', + ], + ) + + except Exception as err: + log.debug('Redis Task: Error shutting down a Redis server') + log.debug(err) + + def remove_redis_package(self, client): + (remote,) = self.ctx.cluster.only(client).remotes.keys() + remove_package('redis', remote) + +task = Redis -- 2.39.5