From e6d54e7d7914a68fe0311b14202b25ec1a97b708 Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Tue, 5 Jan 2021 16:08:02 -0500 Subject: [PATCH] rgw_file: add librgw unit test arguments Also adjust some unit test files to avoid trivial failures. Fixes missing commit after rgw_write(), as well as conditional cleanup. Signed-off-by: Matt Benjamin --- qa/workunits/rgw/test_librgw_file.sh | 50 +++++++++++++++++++++++----- src/test/librgw_file_aw.cc | 2 +- src/test/librgw_file_cd.cc | 2 +- src/test/librgw_file_gp.cc | 25 +++++++++++++- src/test/librgw_file_nfsns.cc | 2 +- 5 files changed, 68 insertions(+), 13 deletions(-) diff --git a/qa/workunits/rgw/test_librgw_file.sh b/qa/workunits/rgw/test_librgw_file.sh index ab4b67eb040..7eed6ad8726 100755 --- a/qa/workunits/rgw/test_librgw_file.sh +++ b/qa/workunits/rgw/test_librgw_file.sh @@ -1,19 +1,51 @@ #!/bin/sh -e -export AWS_ACCESS_KEY_ID=`openssl rand -base64 20` -export AWS_SECRET_ACCESS_KEY=`openssl rand -base64 40` -radosgw-admin user create --uid ceph-test-librgw-file \ +if [ -z ${AWS_ACCESS_KEY_ID} ] +then + export AWS_ACCESS_KEY_ID=`openssl rand -base64 20` + export AWS_SECRET_ACCESS_KEY=`openssl rand -base64 40` + + radosgw-admin user create --uid ceph-test-librgw-file \ --access-key $AWS_ACCESS_KEY_ID \ --secret $AWS_SECRET_ACCESS_KEY \ --display-name "librgw test user" \ --email librgw@example.com || echo "librgw user exists" +fi + +# nfsns is the main suite + +# create herarchy, and then list it +echo "phase 1.1" +ceph_test_librgw_file_nfsns --hier1 --dirs1 --create --rename --verbose + +# the older librgw_file can consume the namespace +echo "phase 1.2" +ceph_test_librgw_file_nfsns --getattr --verbose + +# and delete the hierarchy +echo "phase 1.3" +ceph_test_librgw_file_nfsns --hier1 --dirs1 --delete --verbose + +# bulk create/delete buckets +echo "phase 2.1" +ceph_test_librgw_file_cd --create --multi --verbose +echo "phase 2.2" +ceph_test_librgw_file_cd --delete --multi --verbose + +# write continuation test +echo "phase 3.1" +ceph_test_librgw_file_aw --create --delete --large --verify + +# continued readdir +echo "phase 4.1" +ceph_test_librgw_file_marker --create --marker1 --marker2 --nobjs=100 --verbose -ceph_test_librgw_file -ceph_test_librgw_file_aw -ceph_test_librgw_file_cd -ceph_test_librgw_file_gp -ceph_test_librgw_file_marker -ceph_test_librgw_file_nfsns +# advanced i/o--but skip readv/writev for now--split delete from +# create and stat ops to avoid fault in sysobject cache +echo "phase 5.1" +ceph_test_librgw_file_gp --get --stat --put --create +echo "phase 5.2" +ceph_test_librgw_file_gp --delete exit 0 diff --git a/src/test/librgw_file_aw.cc b/src/test/librgw_file_aw.cc index fc494fe5a00..1dfe9f1d1a8 100644 --- a/src/test/librgw_file_aw.cc +++ b/src/test/librgw_file_aw.cc @@ -47,7 +47,7 @@ namespace { bool do_verify = false; bool do_hexdump = false; - string bucket_name = "sorry_dave"; + string bucket_name = "sorrydave"; string object_name = "jocaml"; struct rgw_file_handle *bucket_fh = nullptr; diff --git a/src/test/librgw_file_cd.cc b/src/test/librgw_file_cd.cc index c4edecafc39..ff0bd1fbde2 100644 --- a/src/test/librgw_file_cd.cc +++ b/src/test/librgw_file_cd.cc @@ -41,7 +41,7 @@ namespace { bool do_multi = false; int multi_cnt = 10; - string bucket_name = "sorry_dave"; + string bucket_name = "sorrydave"; struct { int argc; diff --git a/src/test/librgw_file_gp.cc b/src/test/librgw_file_gp.cc index c274a82706f..bde68fb4b9e 100644 --- a/src/test/librgw_file_gp.cc +++ b/src/test/librgw_file_gp.cc @@ -44,13 +44,18 @@ namespace { bool do_readv = false; bool do_verify = false; bool do_get = false; + bool do_create = false; bool do_delete = false; bool do_stat = false; // stat objects (not buckets) bool do_hexdump = false; bool object_open = false; - string bucket_name = "sorry_dave"; + uint32_t owner_uid = 867; + uint32_t owner_gid = 5309; + uint32_t create_mask = RGW_SETATTR_UID | RGW_SETATTR_GID | RGW_SETATTR_MODE; + + string bucket_name = "blastoff"; string object_name = "jocaml"; struct rgw_file_handle *bucket_fh = nullptr; @@ -184,6 +189,21 @@ TEST(LibRGW, MOUNT) { ASSERT_NE(fs, nullptr); } +TEST(LibRGW, CREATE_BUCKET) { + if (do_create) { + struct stat st; + struct rgw_file_handle *fh; + + st.st_uid = owner_uid; + st.st_gid = owner_gid; + st.st_mode = 755; + + int ret = rgw_mkdir(fs, fs->root_fh, bucket_name.c_str(), &st, create_mask, + &fh, RGW_MKDIR_FLAG_NONE); + ASSERT_EQ(ret, 0); + } +} + TEST(LibRGW, LOOKUP_BUCKET) { int ret = rgw_lookup(fs, fs->root_fh, bucket_name.c_str(), &bucket_fh, nullptr, 0, RGW_LOOKUP_FLAG_NONE); @@ -474,6 +494,9 @@ int main(int argc, char *argv[]) } else if (ceph_argparse_flag(args, arg_iter, "--prelist", (char*) nullptr)) { do_pre_list = true; + } else if (ceph_argparse_flag(args, arg_iter, "--create", + (char*) nullptr)) { + do_create = true; } else if (ceph_argparse_flag(args, arg_iter, "--hexdump", (char*) nullptr)) { do_hexdump = true; diff --git a/src/test/librgw_file_nfsns.cc b/src/test/librgw_file_nfsns.cc index ecc3198c021..bc4c0a4a251 100644 --- a/src/test/librgw_file_nfsns.cc +++ b/src/test/librgw_file_nfsns.cc @@ -520,7 +520,7 @@ TEST(LibRGW, RGW_SETUP_RENAME1) { st.st_mode = 755; for (int b_ix : {0, 1}) { - std::string bname{"brename_" + to_string(b_ix)}; + std::string bname{"brename" + to_string(b_ix)}; obj_rec brec{bname, nullptr, nullptr, nullptr}; (void) rgw_lookup(fs, fs->root_fh, brec.name.c_str(), &brec.fh, nullptr, 0, RGW_LOOKUP_FLAG_NONE); -- 2.39.5