ceph/qa/workunits/rgw/test_rgw_datacache.py
Mark Kogan 31a9255636 rgw: D3N Cache changes for Upstream
Upstreaming / rebase of #24500

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: change io_ctx pool per storage class

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: Changing free() to delete()

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: Addressing review comments

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: Fixing seg fault

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

Moving CacheRequest out of librados

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: cache initialization fix

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: fix missing spawn.hpp compile errors

resolves compilation errors similar to:
```
[ 15%] Building CXX object src/tools/immutable_object_cache/CMakeFiles/ceph_immutable_object_cache_lib.dir/CacheController.cc.o
In file included from /home/jenkins-build/build/workspace/ceph-pull-requests/src/rgw/rgw_common.h:31,
                 from /home/jenkins-build/build/workspace/ceph-pull-requests/src/rgw/rgw_rados.h:17,
                 from /home/jenkins-build/build/workspace/ceph-pull-requests/src/librados/IoCtxImpl.h:30,
                 from /home/jenkins-build/build/workspace/ceph-pull-requests/src/librados/RadosClient.h:35,
                 from /home/jenkins-build/build/workspace/ceph-pull-requests/src/neorados/RADOSImpl.h:27,
                 from /home/jenkins-build/build/workspace/ceph-pull-requests/src/neorados/RADOS.cc:37:
/home/jenkins-build/build/workspace/ceph-pull-requests/src/common/async/yield_context.h:31:10: fatal error: spawn/spawn.hpp: No such file or directory
   31 | #include <spawn/spawn.hpp>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
src/neorados/CMakeFiles/neorados_api_obj.dir/build.make:62: recipe for target 'src/neorados/CMakeFiles/neorados_api_obj.dir/RADOS.cc.o' failed
make[3]: *** [src/neorados/CMakeFiles/neorados_api_obj.dir/RADOS.cc.o] Error 1
```

Signed-off-by: Mark Kogan <mkogan@redhat.com>

Resolving merge conflict

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

Removing all logs and unnecessary comments

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

Cache Read and Write working

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

Initial Commit L1 Cache

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

post re-rebase merge, update fixes

Signed-off-by: Mark Kogan <mkogan@redhat.com>

fixup! post re-rebase merge, update fixes

rgw: continuation of rgwcache branch rebase

Signed-off-by: Mark Kogan <mkogan@redhat.com>

RGW: DataCache: post merge fixes

Signed-off-by: Mark Kogan <mkogan@redhat.com>

fixes of segmentation fault caused by oid

Signed-off-by: E. Ugur Kaynar <ukaynar@bu.edu>

rgw: fixes for segmentation faults and configuration processing

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: data cache first commit

Signed-off-by: Mania Abdi <mania.abdi287@gmail.com>

rgw: cleanup addressing PR comments

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: cleanup addressing PR comments, continuation.

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: pr cleanup addressing second review round

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: Addressing review comments, removing all D3N code from librados

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: for compilation err from removal of mydout() helper

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rge: addressing review comments

rgw: move d3n datacache into separate files
rgw: 1st part of datacache rebranding to d3n

fix forward declaration compile err (only with clang):
../src/rgw/rgw_cache.h:396:4: error: member access into incomplete type 'struct get_obj_data'
  d->data_lock.lock();
   ^
../src/rgw/rgw_cache.h:365:8: note: forward declaration of 'get_obj_data'
struct get_obj_data;
       ^

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: addressing review comments, datacache rebranding to d3n cache

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: Cleaning up unused D3N cache code

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: cont. cleaning up of rgw_obj_data()

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: Removing redundant code, fix for multipart S3 objects

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: fix: incorrect content len on multipart get

in s3tests_boto3.functional.test_s3:test_multipart_copy_versioned
when d3n cache is disabled

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: fix segfault reading from cache

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: fix segfault in multisite

sync on secondary site

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: fix segfault in multisite teuthology tests, cont.

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: Adding drain to wait for all AIO reads to complete

Signed-off-by: Aishwarya Mathuria <amathuri@redhat.com>

rgw: fix for using read() by liabio or posix io per config

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: improve persistent data cache directory handling

on start create the persistent datacache directory if necessary
and add an option to evict it's content if already exists

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: fix possible segfault during eviction

Signed-off-by: Mark Kogan <mkogan@redhat.com>

Co-authored-by: Mania Abdi <mania.abdi287@gmail.com>
Co-authored-by: E. Ugur Kaynar <ukaynar@bu.edu>
Co-authored-by: Aishwarya Mathuria <amathuri@redhat.com>
Co-authored-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: addressing latest review comments

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: add debug logs for cache in/out flow

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: move the L2 cache functionality to separate PR

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: addressing review comments

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: address java_s3tests teuthology issues

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: do not handle compressed objects fro now

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: l2 cleanup and log fixups + post dpp

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: thread dpp thru get_obj_iterate_cb() and related

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: bypass reading versioned objects from cache

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: cleanup and fix s3tests

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: allow to enable cache only on beast

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: delete the content of the cache directory on rgw start

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: re-enable d3n cache with civetweb frontend

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: rebase post zipper 10

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: address teuthoogy valgrind leaks detected

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: mitigating valgrind leaks

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: remove rgw_d3n_l1_libaio_read option

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: wip segfault fix

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: mitigate libaio SIGEV_THREAD cb race

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: change libaio signaling mechanism

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: wip cont. libaio cb thread race

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: wip libaio cb thread race

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: libaio cleanups and edge case handling fixes

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: narrow the libaio locking scope

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: add libaio req ordering mechanism

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: fix lock regression

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: addressing reviwe comments and cleasnup

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: libaio locks cleanup

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: refactor libaio abstraction to share the ioc implementation

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: addressing latest review comments and cleanup

Signed-off-by: Mark Kogan <mkogan@redhat.com>

rgw: d3n: address review comments, cont.

Signed-off-by: Mark Kogan <mkogan@redhat.com>
Co-authored-by: Mania Abdi <mania.abdi287@gmail.com>
Co-authored-by: E. Ugur Kaynar <ukaynar@bu.edu>
Co-authored-by: Aishwarya Mathuria <amathuri@redhat.com>
Co-authored-by: Ali Maredia <amaredia@redhat.com>
Co-authored-by: Feng Hualong <hualong.feng@intel.com>
2021-07-06 21:36:06 +03:00

212 lines
6.8 KiB
Python
Executable File

#!/usr/bin/python3
import logging as log
from configobj import ConfigObj
import subprocess
import json
import os
"""
Runs a test against a rgw with the data cache enabled. A client must be
set in the config for this task. This client must be the same client
that is in the config for the `rgw` task.
In the `overrides` section `datacache` and `datacache` must be configured for
the `rgw` task and the ceph conf overrides must contain the below config
variables in the client section.
`s3cmd` must be added as an extra_package to the install task.
In the `workunit` task, `- rgw/run-datacache.sh` must be set for the client that
is in the config for the `rgw` task. The `RGW_DATACACHE_PATH` variable must be
set in the workunit's `env` and it must match the `datacache_path` given to the
`rgw` task in `overrides`.
Ex:
- install:
extra_packages:
deb: ['s3cmd']
rpm: ['s3cmd']
- overrides:
rgw:
datacache: true
datacache_path: /tmp/rgw_datacache
install:
extra_packages:
deb: ['s3cmd']
rpm: ['s3cmd']
ceph:
conf:
client:
rgw d3n l1 datacache persistent path: /tmp/rgw_datacache/
rgw d3n l1 datacache size: 10737417240
rgw d3n l1 local datacache enabled: true
rgw enable ops log: true
- rgw:
client.0:
- workunit:
clients:
client.0:
- rgw/run-datacache.sh
env:
RGW_DATACACHE_PATH: /tmp/rgw_datacache
cleanup: true
"""
log.basicConfig(level=log.DEBUG)
""" Constants """
USER = 'rgw_datacache_user'
DISPLAY_NAME = 'DatacacheUser'
ACCESS_KEY = 'NX5QOQKC6BH2IDN8HC7A'
SECRET_KEY = 'LnEsqNNqZIpkzauboDcLXLcYaWwLQ3Kop0zAnKIn'
BUCKET_NAME = 'datacachebucket'
FILE_NAME = '7M.dat'
GET_FILE_NAME = '7M-get.dat'
def exec_cmd(cmd):
log.debug("exec_cmd(%s)", cmd)
try:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
out, err = proc.communicate()
if proc.returncode == 0:
log.info('command succeeded')
if out is not None: log.info(out)
return out
else:
raise Exception("error: %s \nreturncode: %s" % (err, proc.returncode))
except Exception as e:
log.error('command failed')
log.error(e)
return False
def get_radosgw_endpoint():
out = exec_cmd('sudo netstat -nltp | egrep "rados|valgr"') # short for radosgw/valgrind
x = out.decode('utf8').split(" ")
port = [i for i in x if ':' in i][0].split(':')[1]
log.info('radosgw port: %s' % port)
proto = "http"
hostname = 'localhost'
if port == '443':
proto = "https"
out = exec_cmd('hostname')
hostname = get_cmd_output(out)
hostname = hostname + ".front.sepia.ceph.com"
endpoint = proto + "://" + hostname + ":" + port
log.info("radosgw endpoint is: %s", endpoint)
return endpoint, proto
def create_s3cmd_config(path, proto):
"""
Creates a minimal config file for s3cmd
"""
log.info("Creating s3cmd config...")
use_https_config = "False"
log.info("proto for s3cmd config is %s", proto)
if proto == "https":
use_https_config = "True"
s3cmd_config = ConfigObj(
indent_type='',
infile={
'default':
{
'host_bucket': 'no.way.in.hell',
'use_https': use_https_config,
},
}
)
f = open(path, 'wb')
s3cmd_config.write(f)
f.close()
log.info("s3cmd config written")
def get_cmd_output(cmd_out):
out = cmd_out.decode('utf8')
out = out.strip('\n')
return out
def main():
"""
execute the datacache test
"""
# setup for test
cache_dir = os.environ['RGW_DATACACHE_PATH']
log.debug("datacache dir from config is: %s", cache_dir)
out = exec_cmd('pwd')
pwd = get_cmd_output(out)
log.debug("pwd is: %s", pwd)
endpoint, proto = get_radosgw_endpoint()
# create 7M file to put
outfile = pwd + '/' + FILE_NAME
exec_cmd('dd if=/dev/urandom of=%s bs=1M count=7' % (outfile))
# create user
exec_cmd('radosgw-admin user create --uid %s --display-name %s --access-key %s --secret %s'
% (USER, DISPLAY_NAME, ACCESS_KEY, SECRET_KEY))
# create s3cmd config
s3cmd_config_path = pwd + '/s3cfg'
create_s3cmd_config(s3cmd_config_path, proto)
# create a bucket
exec_cmd('s3cmd --access_key=%s --secret_key=%s --config=%s --host=%s mb s3://%s'
% (ACCESS_KEY, SECRET_KEY, s3cmd_config_path, endpoint, BUCKET_NAME))
# put an object in the bucket
exec_cmd('s3cmd --access_key=%s --secret_key=%s --config=%s --host=%s put %s s3://%s'
% (ACCESS_KEY, SECRET_KEY, s3cmd_config_path, endpoint, outfile, BUCKET_NAME))
# get object from bucket
get_file_path = pwd + '/' + GET_FILE_NAME
exec_cmd('s3cmd --access_key=%s --secret_key=%s --config=%s --host=%s get s3://%s/%s %s --force'
% (ACCESS_KEY, SECRET_KEY, s3cmd_config_path, endpoint, BUCKET_NAME, FILE_NAME, get_file_path))
# get info of object
out = exec_cmd('radosgw-admin object stat --bucket=%s --object=%s' % (BUCKET_NAME, FILE_NAME))
json_op = json.loads(out)
cached_object_name = json_op['manifest']['prefix']
log.debug("Cached object name is: %s", cached_object_name)
# check that the cache is enabled (does the cache directory empty)
out = exec_cmd('find %s -type f | wc -l' % (cache_dir))
chk_cache_dir = int(get_cmd_output(out))
log.debug("Check cache dir content: %s", chk_cache_dir)
if chk_cache_dir == 0:
log.info("NOTICE: datacache test object not found, inspect if datacache was bypassed or disabled during this check.")
return
# list the files in the cache dir for troubleshooting
out = exec_cmd('ls -l %s' % (cache_dir))
# get name of cached object and check if it exists in the cache
out = exec_cmd('find %s -name "*%s*"' % (cache_dir, cached_object_name))
cached_object_path = get_cmd_output(out)
log.debug("Path of file in datacache is: %s", cached_object_path)
out = exec_cmd('basename %s' % (cached_object_path))
basename_cmd_out = get_cmd_output(out)
log.debug("Name of file in datacache is: %s", basename_cmd_out)
# check to see if the cached object is in Ceph
out = exec_cmd('rados ls -p default.rgw.buckets.data')
rados_ls_out = get_cmd_output(out)
log.debug("rados ls output is: %s", rados_ls_out)
assert(basename_cmd_out in rados_ls_out)
log.debug("RGW Datacache test SUCCESS")
# remove datacache dir
#cmd = exec_cmd('rm -rf %s' % (cache_dir))
#log.debug("RGW Datacache dir deleted")
#^ commenting for future refrence - the work unit will continue running tests and if the cache_dir is removed
# all the writes to cache will fail with errno 2 ENOENT No such file or directory.
main()
log.info("Completed Datacache tests")