Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: introduce DAOS dtx tests + cmd_requires_cwd (opt-in) #6116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/daos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024, Intel Corporation
#

name: DAOS

on:
push:

permissions: {}

jobs:
clear_caches:
name: Clear caches
runs-on: ubuntu-latest
strategy:
matrix:
ref: [master, release/2.6]
permissions:
actions: write
steps:
- run: |
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/pmem/pmdk/actions/caches?key=opt_daos-${{ matrix.ref }}"
daos_tests:
name: DAOS
needs: clear_caches
strategy:
matrix:
ref: [master, release/2.6]
uses: pmem/pmdk/.github/workflows/daos_tests.yml@DAOS-tests
with:
DAOS_REF: ${{ matrix.ref }}
159 changes: 159 additions & 0 deletions .github/workflows/daos_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024, Intel Corporation
#

name: DAOS tests

on:
workflow_call:
inputs:
DAOS_REF:
required: true
type: string
workflow_dispatch:
inputs:
DAOS_REF:
description: DAOS ref
required: true
type: string

permissions: {}

env:
DAOS_PATH: /opt/daos

jobs:
daos_test:
name: DAOS tests
runs-on: ubuntu-latest
steps:
- name: Generate a safe ref
id: safe_ref
run: |
ref=${{ inputs.DAOS_REF }}
safe_ref=${ref//\//_}
echo "value=$safe_ref" >> $GITHUB_OUTPUT

- name: Clone the DAOS repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: daos-stack/daos
ref: ${{ inputs.DAOS_REF }}
path: daos

- name: Clone the PMDK repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: pmem/pmdk
path: pmdk

- name: Restore ${{ env.DAOS_PATH }} from cache
id: cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.DAOS_PATH }}
key: opt_daos-${{ inputs.DAOS_REF }}
fail-on-cache-miss: false

- name: Apply DAOS patches
if: steps.cache.outputs.cache-hit != 'true'
working-directory: daos
run: git apply ../pmdk/src/test/daos_dtx/*.patch

# It seems necessary for both building and running.
- name: Install DAOS' dependencies
working-directory: daos
run: |
sudo pip install -r requirements-build.txt
sudo utils/scripts/install-ubuntu.sh

# https://go.dev/doc/install
- name: Update the golang package
if: steps.cache.outputs.cache-hit != 'true'
env:
GOLANG_VER: go1.23.1 # >= 1.21 because of https://go.dev/doc/toolchain
run: |
sudo apt-get remove golang-go
wget https://go.dev/dl/${{ env.GOLANG_VER }}.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf ${{ env.GOLANG_VER }}.linux-amd64.tar.gz

- name: Install Valgrind
working-directory: pmdk/utils/docker/images/
run: sudo ./install-valgrind.sh

- name: Generate ${{ env.OPTS_FILE }}
if: steps.cache.outputs.cache-hit != 'true'
working-directory: daos
env:
OPTS_FILE: daos.conf
run: |
cat <<-EOF >> ${{ env.OPTS_FILE }}
BUILD_TYPE = 'debug'
TARGET_TYPE = 'debug'
PREFIX = '${{ env.DAOS_PATH }}'
GO_BIN = '/usr/local/go/bin/go'
EOF
cat ${{ env.OPTS_FILE }}

- name: Build DAOS
if: steps.cache.outputs.cache-hit != 'true'
working-directory: daos
run: |
git submodule init
git submodule update
scons install -j16 --build-deps=yes

- name: Save ${{ env.DAOS_PATH }} as cache
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: ${{ env.DAOS_PATH }}
key: opt_daos-${{ inputs.DAOS_REF }}

- name: Install PMDK's dependencies
run: sudo apt-get install libndctl-dev libdaxctl-dev pandoc

- name: Build PMDK
working-directory: pmdk
env:
PMDK_BUILD_DAOS_TESTS: y
DAOS_INSTALL_PATH: ${{ env.DAOS_PATH }}
run: |
export DAOS_SRC_PATH=$(realpath ../daos)
utils/gha-runners/build-pmdk.sh

- name: Create testconfig files
working-directory: pmdk
env:
PMEM_FS_DIR: /dev/shm
PMEM_FS_DIR_FORCE_PMEM: 1
run: |
utils/create-testconfig.sh
for testconfig in src/test/testconfig.{sh,py}; do
echo "$testconfig"
cat $testconfig
echo
done

- name: Run daos_dtx tests (1/2)
working-directory: pmdk/src/test
env:
LD_LIBRARY_PATH: ${{ env.DAOS_PATH }}/prereq/debug/ofi/lib
run: |
export PATH=${{ env.DAOS_PATH }}/bin:$PATH
./RUNTESTS.py daos_dtx

- name: Run daos_dtx tests (2/2)
working-directory: pmdk/src/test
env:
PMEMOBJ_CONF: sds.at_create=0
run: |
export PATH=${{ env.DAOS_PATH }}/bin:$PATH
./RUNTESTS.sh daos_dtx 2> daos_dtx/err.log

- name: Upload test results as artifact
if: success() || failure()
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: daos_dtx-${{ steps.safe_ref.outputs.value }}
path: pmdk/src/test/daos_dtx
1 change: 1 addition & 0 deletions src/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ OTHER_TESTS = \
compat_incompat_features\
ctl_prefault\
ctl_cow\
daos_dtx\
magic\
out_err\
out_err_mt\
Expand Down
1 change: 1 addition & 0 deletions src/test/daos_dtx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
daos_dtx
172 changes: 172 additions & 0 deletions src/test/daos_dtx/00_harmonize_VOS_pool_path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
diff --git a/src/vos/tests/vts_common.c b/src/vos/tests/vts_common.c
index 618f9feddd..7452ba2a34 100644
--- a/src/vos/tests/vts_common.c
+++ b/src/vos/tests/vts_common.c
@@ -52,11 +52,22 @@ vts_file_exists(const char *filename)
}

int
-vts_alloc_gen_fname(char **fname)
+vts_alloc_gen_fname(char *po_uuid_str, char **fname)
{
int rc;

- rc = asprintf(fname, "%s/vpool.%d", vos_path, gc++);
+ assert(*fname == NULL);
+ rc = asprintf(fname, "%s/%s/", vos_path, po_uuid_str);
+ if (rc < 0) {
+ *fname = NULL;
+ print_error("Failed to allocate memory for fname: rc = %d\n", rc);
+ return rc;
+ }
+ rc = mkdir(*fname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+ assert(rc == 0 || errno == EEXIST);
+ free(*fname);
+
+ rc = asprintf(fname, "%s/%s/vpool.%d", vos_path, po_uuid_str, gc++);
if (rc < 0) {
*fname = NULL;
print_error("Failed to allocate memory for fname: rc = %d\n", rc);
@@ -71,9 +82,9 @@ vts_pool_fallocate(char **fname)
{
int ret = 0, fd;

- ret = vts_alloc_gen_fname(fname);
- if (ret)
- return ret;
+ // ret = vts_alloc_gen_fname(fname);
+ // if (ret)
+ // return ret;

fd = open(*fname, O_CREAT | O_TRUNC | O_RDWR, 0666);
if (fd < 0) {
@@ -92,10 +103,17 @@ int
vts_ctx_init(struct vos_test_ctx *tcx, size_t psize)
{
int rc;
+ char uuid_str[] = "dd6728be-696a-11ef-a059-a4bf0165c389";
+ char uuid_str2[] = "591d19e4-69fe-11ef-b13d-a4bf0165c389";

memset(tcx, 0, sizeof(*tcx));
+
+ uuid_parse(uuid_str, tcx->tc_po_uuid);
+ // uuid_generate_time_safe(tcx->tc_po_uuid);
+ // uuid_unparse(tcx->tc_po_uuid, uuid_str);
+
oid_cnt = 0;
- rc = vts_alloc_gen_fname(&tcx->tc_po_name);
+ rc = vts_alloc_gen_fname(uuid_str, &tcx->tc_po_name);
assert_int_equal(rc, 0);

if (vts_file_exists(tcx->tc_po_name)) {
@@ -103,8 +121,8 @@ vts_ctx_init(struct vos_test_ctx *tcx, size_t psize)
assert_int_equal(rc, 0);
}

- uuid_generate_time_safe(tcx->tc_po_uuid);
- uuid_generate_time_safe(tcx->tc_co_uuid);
+ // uuid_generate_time_safe(tcx->tc_co_uuid);
+ uuid_parse(uuid_str2, tcx->tc_co_uuid);

/* specify @psize as both NVMe size and SCM size */
rc = vos_pool_create(tcx->tc_po_name, tcx->tc_po_uuid, psize, psize, 0, 0 /* version */,
@@ -155,14 +173,14 @@ vts_ctx_fini(struct vos_test_ctx *tcx)
assert_rc_equal(rc, 0);
/* fallthrough */
case TCX_CO_CREATE:
- rc = vos_cont_destroy(tcx->tc_po_hdl, tcx->tc_co_uuid);
- assert_rc_equal(rc, 0);
+ // rc = vos_cont_destroy(tcx->tc_po_hdl, tcx->tc_co_uuid);
+ // assert_rc_equal(rc, 0);
/* fallthrough */
case TCX_PO_CREATE_OPEN:
rc = vos_pool_close(tcx->tc_po_hdl);
assert_rc_equal(rc, 0);
- rc = vos_pool_destroy(tcx->tc_po_name, tcx->tc_po_uuid);
- assert_rc_equal(rc, 0);
+ // rc = vos_pool_destroy(tcx->tc_po_name, tcx->tc_po_uuid);
+ // assert_rc_equal(rc, 0);
free(tcx->tc_po_name);
/* fallthrough */
}
diff --git a/src/vos/tests/vts_common.h b/src/vos/tests/vts_common.h
index 2a08cbd8ff..b7dc09dcfe 100644
--- a/src/vos/tests/vts_common.h
+++ b/src/vos/tests/vts_common.h
@@ -83,7 +83,7 @@ bool
vts_file_exists(const char *filename);

int
-vts_alloc_gen_fname(char **fname);
+vts_alloc_gen_fname(char *po_uuid, char **fname);

int
vts_pool_fallocate(char **fname);
diff --git a/src/vos/tests/vts_io.c b/src/vos/tests/vts_io.c
index 5ec1bb08f7..abc269b1f6 100644
--- a/src/vos/tests/vts_io.c
+++ b/src/vos/tests/vts_io.c
@@ -956,7 +956,7 @@ io_obj_cache_test(void **state)
struct vos_object *obj1, *obj2;
daos_epoch_range_t epr = {0, 1};
daos_unit_oid_t oids[2];
- char *po_name;
+ char *po_name = "";
uuid_t pool_uuid;
daos_handle_t l_poh, l_coh;
struct daos_lru_cache *old_cache;
@@ -970,8 +970,8 @@ io_obj_cache_test(void **state)
old_cache = tls->vtl_ocache;
tls->vtl_ocache = occ;

- rc = vts_alloc_gen_fname(&po_name);
- assert_int_equal(rc, 0);
+ // rc = vts_alloc_gen_fname(&po_name);
+ // assert_int_equal(rc, 0);

uuid_generate_time_safe(pool_uuid);
rc = vos_pool_create(po_name, pool_uuid, VPOOL_256M, 0, 0, 0 /* version */, &l_poh);
@@ -1105,7 +1105,7 @@ io_obj_cache_test(void **state)
assert_rc_equal(rc, 0);
vos_obj_cache_destroy(occ);
tls->vtl_ocache = old_cache;
- free(po_name);
+ // free(po_name);
}

static void
diff --git a/src/vos/tests/vts_pool.c b/src/vos/tests/vts_pool.c
index acfd4e46a8..8e2fe3742c 100644
--- a/src/vos/tests/vts_pool.c
+++ b/src/vos/tests/vts_pool.c
@@ -49,7 +49,7 @@ static int
pool_file_setup(void **state)
{
struct vp_test_args *arg = *state;
- int ret = 0;
+ // int ret = 0;

D_ALLOC(arg->fname, sizeof(char *));
assert_ptr_not_equal(arg->fname, NULL);
@@ -57,8 +57,8 @@ pool_file_setup(void **state)
D_ALLOC_ARRAY(arg->poh, 10);
assert_ptr_not_equal(arg->poh, NULL);

- ret = vts_alloc_gen_fname(&arg->fname[0]);
- assert_int_equal(ret, 0);
+ // ret = vts_alloc_gen_fname(&arg->fname[0]);
+ // assert_int_equal(ret, 0);
return 0;
}

@@ -153,8 +153,8 @@ pool_ops_run(void **state)
VPOOL_TEST_WAL_SZ, 0,
0 /* version */, poh);
} else {
- ret = vts_alloc_gen_fname(&arg->fname[j]);
- assert_int_equal(ret, 0);
+ // ret = vts_alloc_gen_fname(&arg->fname[j]);
+ // assert_int_equal(ret, 0);
ret = vos_pool_create_ex(arg->fname[j], arg->uuid[j],
VPOOL_256M, 0, VPOOL_TEST_WAL_SZ,
0, 0 /* version */, poh);
Loading
Loading