From 2d21931c1f48c5b19c11f8584e255a9a795a2d72 Mon Sep 17 00:00:00 2001 From: yoshifuminakamura Date: Thu, 17 Sep 2026 10:32:21 +0900 Subject: [PATCH] tests: isolate app config fixtures Signed-off-by: yoshifuminakamura --- scripts/tests/test_matrix_generate_filters.sh | 54 +++++++++++++------ scripts/tests/test_scheduler_extra_args.sh | 37 +++++++++++-- 2 files changed, 70 insertions(+), 21 deletions(-) diff --git a/scripts/tests/test_matrix_generate_filters.sh b/scripts/tests/test_matrix_generate_filters.sh index f569f8f..d30e0df 100644 --- a/scripts/tests/test_matrix_generate_filters.sh +++ b/scripts/tests/test_matrix_generate_filters.sh @@ -7,37 +7,59 @@ REPO_DIR=$(cd "${SCRIPT_DIR}/../.." && pwd) TMP_DIR=$(mktemp -d) trap 'rm -rf "${TMP_DIR}"' EXIT -mkdir -p "${TMP_DIR}/project" -ln -s "${REPO_DIR}/config" "${TMP_DIR}/project/config" -ln -s "${REPO_DIR}/programs" "${TMP_DIR}/project/programs" +mkdir -p "${TMP_DIR}/project/config" "${TMP_DIR}/project/programs/filterapp" ln -s "${REPO_DIR}/scripts" "${TMP_DIR}/project/scripts" +cat > "${TMP_DIR}/project/config/system.csv" <<'EOF' +system,mode,tag_build,tag_run,queue,queue_group +FilterSystem,cross,build-tag,run-tag,SLURM_TEST,debug +EOF + +cat > "${TMP_DIR}/project/config/queue.csv" <<'EOF' +queue,submit_cmd,template +SLURM_TEST,sbatch,"-p ${queue_group} -t ${elapse} -N ${nodes} --ntasks-per-node=${numproc_node} --cpus-per-task=${nthreads}" +EOF + +cat > "${TMP_DIR}/project/config/system_info.csv" <<'EOF' +system,name,cpu_name,cpu_per_node,cpu_cores,gpu_name,gpu_per_node,memory,display_order +FilterSystem,FilterSystem,CPU,1,32,GPU,1,64 GB,1 +EOF + +cat > "${TMP_DIR}/project/programs/filterapp/list.csv" <<'EOF' +system,enable,nodes,numproc_node,nthreads,elapse +FilterSystem,yes,1,2,3,0:10:00 +FilterSystem,yes,2,2,3,0:10:00 +FilterSystem,yes,4,2,3,0:10:00 +EOF +printf '#!/bin/bash\n' > "${TMP_DIR}/project/programs/filterapp/build.sh" +printf '#!/bin/bash\n' > "${TMP_DIR}/project/programs/filterapp/run.sh" + pushd "${TMP_DIR}/project" >/dev/null -bash scripts/matrix_generate.sh code=sbd system=RIKYU nodes=1 -grep -q '^sbd_RIKYU_N1_P4_T32_run:' .gitlab-ci.generated.yml +bash scripts/matrix_generate.sh code=filterapp system=FilterSystem nodes=1 +grep -q '^filterapp_FilterSystem_N1_P2_T3_run:' .gitlab-ci.generated.yml grep -q 'name: $CI_COMMIT_BRANCH' .gitlab-ci.generated.yml -if grep -q '^sbd_RIKYU_N2_P4_T32_run:' .gitlab-ci.generated.yml; then - echo "nodes=1 filter must not emit the SBD RIKYU 2-node job" >&2 +if grep -q '^filterapp_FilterSystem_N2_P2_T3_run:' .gitlab-ci.generated.yml; then + echo "nodes=1 filter must not emit the 2-node fixture job" >&2 exit 1 fi -if grep -q '^sbd_RIKYU_N4_P4_T32_run:' .gitlab-ci.generated.yml; then - echo "nodes=1 filter must not emit the SBD RIKYU 4-node job" >&2 +if grep -q '^filterapp_FilterSystem_N4_P2_T3_run:' .gitlab-ci.generated.yml; then + echo "nodes=1 filter must not emit the 4-node fixture job" >&2 exit 1 fi -bash scripts/matrix_generate.sh code=sbd system=RIKYU nodes='2, 4' -if grep -q '^sbd_RIKYU_N1_P4_T32_run:' .gitlab-ci.generated.yml; then - echo "nodes=2,4 filter must not emit the SBD RIKYU 1-node job" >&2 +bash scripts/matrix_generate.sh code=filterapp system=FilterSystem nodes='2, 4' +if grep -q '^filterapp_FilterSystem_N1_P2_T3_run:' .gitlab-ci.generated.yml; then + echo "nodes=2,4 filter must not emit the 1-node fixture job" >&2 exit 1 fi -grep -q '^sbd_RIKYU_N2_P4_T32_run:' .gitlab-ci.generated.yml -grep -q '^sbd_RIKYU_N4_P4_T32_run:' .gitlab-ci.generated.yml +grep -q '^filterapp_FilterSystem_N2_P2_T3_run:' .gitlab-ci.generated.yml +grep -q '^filterapp_FilterSystem_N4_P2_T3_run:' .gitlab-ci.generated.yml -BK_GITLAB_ENVIRONMENT=develop bash scripts/matrix_generate.sh code=sbd system=RIKYU nodes=1 +BK_GITLAB_ENVIRONMENT=develop bash scripts/matrix_generate.sh code=filterapp system=FilterSystem nodes=1 grep -q 'name: "develop"' .gitlab-ci.generated.yml -if BK_GITLAB_ENVIRONMENT='bad scope' bash scripts/matrix_generate.sh code=sbd system=RIKYU nodes=1 >/dev/null 2>&1; then +if BK_GITLAB_ENVIRONMENT='bad scope' bash scripts/matrix_generate.sh code=filterapp system=FilterSystem nodes=1 >/dev/null 2>&1; then echo "invalid BK_GITLAB_ENVIRONMENT must fail matrix generation" >&2 exit 1 fi diff --git a/scripts/tests/test_scheduler_extra_args.sh b/scripts/tests/test_scheduler_extra_args.sh index ff1fb79..beda15f 100644 --- a/scripts/tests/test_scheduler_extra_args.sh +++ b/scripts/tests/test_scheduler_extra_args.sh @@ -33,8 +33,9 @@ test "$(get_scheduler_extra_args RIKYU)" = "--account=global" test "$(get_scheduler_extra_args Fugaku)" = "--account=global" tmpdir="" +project_dir="" estimate_tmpdir=$(mktemp -d) -trap 'rm -rf "$tmpdir" "$estimate_tmpdir"; rm -f "${REPO_DIR}/script.sh"' EXIT +trap 'rm -rf "$tmpdir" "$estimate_tmpdir"' EXIT mkdir -p "$estimate_tmpdir/app" if has_estimate_script "$estimate_tmpdir/app"; then @@ -50,6 +51,30 @@ if has_estimate_script "$estimate_tmpdir/app"; then fi tmpdir=$(mktemp -d) +project_dir="$tmpdir/project" + +mkdir -p "$project_dir/config" "$project_dir/programs/schedulerapp" +ln -s "${REPO_DIR}/scripts" "$project_dir/scripts" + +cat > "$project_dir/config/system.csv" <<'EOF' +system,mode,tag_build,tag_run,queue,queue_group +RC_GH200,native,,,SLURM_RC,gh200 +Fugaku,cross,,,FJ,small +EOF + +cat > "$project_dir/config/system_info.csv" <<'EOF' +system,name,cpu_name,cpu_per_node,cpu_cores,gpu_name,gpu_per_node,memory,display_order +RC_GH200,RC_GH200,CPU,1,72,GPU,1,120 GB,1 +Fugaku,Fugaku,CPU,1,48,-,-,32 GB,2 +EOF + +cat > "$project_dir/programs/schedulerapp/list.csv" <<'EOF' +system,enable,nodes,numproc_node,nthreads,elapse +RC_GH200,yes,1,1,1,0:05:00 +Fugaku,yes,1,2,3,0:05:00 +EOF +printf '#!/bin/bash\n' > "$project_dir/programs/schedulerapp/build.sh" +printf '#!/bin/bash\n' > "$project_dir/programs/schedulerapp/run.sh" cat >"$tmpdir/sbatch" <<'SCRIPT' #!/bin/bash @@ -65,14 +90,15 @@ unset BK_SCHEDULER_EXTRA_ARGS_RIKYU unset BK_SCHEDULER_EXTRA_ARGS_Fugaku unset BK_SCHEDULER_EXTRA_ARGS_RC_GH200 -bash scripts/test_submit_build.sh qws 5 >/dev/null +pushd "$project_dir" >/dev/null +bash scripts/test_submit_build.sh schedulerapp 1 >/dev/null if grep -q -- "--account=rkp00010" "$BK_TEST_SBATCH_ARGS_FILE"; then echo "RC_GH200 must not derive --account from BK_ALLOCATION_PROJECT_ID" >&2 exit 1 fi export BK_SCHEDULER_EXTRA_ARGS_RC_GH200="--account=explicit-rc" -bash scripts/test_submit_build.sh qws 5 >/dev/null +bash scripts/test_submit_build.sh schedulerapp 1 >/dev/null grep -q -- "--account=explicit-rc" "$BK_TEST_SBATCH_ARGS_FILE" cat >"$tmpdir/pjsub" <<'SCRIPT' @@ -86,15 +112,16 @@ export BK_ALLOCATION_PROJECT_ID="ra000009" unset BK_SCHEDULER_EXTRA_ARGS unset BK_SCHEDULER_EXTRA_ARGS_Fugaku -bash scripts/test_submit.sh qws 2 >/dev/null +bash scripts/test_submit.sh schedulerapp 2 >/dev/null grep -q -- "-g ra000009" "$BK_TEST_PJSUB_ARGS_FILE" unset BK_ALLOCATION_PROJECT_ID -bash scripts/test_submit.sh qws 2 >/dev/null +bash scripts/test_submit.sh schedulerapp 2 >/dev/null if grep -q -- "-g" "$BK_TEST_PJSUB_ARGS_FILE"; then echo "Fugaku must not pass -g when BK_ALLOCATION_PROJECT_ID is unset" >&2 exit 1 fi +popd >/dev/null popd >/dev/null