From 31f3e1c64ce6e1b94498d51ab2744047454cc93d Mon Sep 17 00:00:00 2001 From: Yoshifumi Nakamura Date: Tue, 28 Jul 2026 08:49:15 +0900 Subject: [PATCH] Make copied send results writable Signed-off-by: Yoshifumi Nakamura --- .github/workflows/result-server-tests.yml | 3 + .../result_server/process_and_send_results.sh | 1 + .../tests/test_process_and_send_results.sh | 62 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 scripts/tests/test_process_and_send_results.sh diff --git a/.github/workflows/result-server-tests.yml b/.github/workflows/result-server-tests.yml index a1271bb..5c7ef42 100644 --- a/.github/workflows/result-server-tests.yml +++ b/.github/workflows/result-server-tests.yml @@ -18,6 +18,7 @@ on: - "scripts/tests/fixtures/**" - "scripts/tests/test_genesis_gpu_mlp_estimation.sh" - "scripts/tests/test_result_profile_data.sh" + - "scripts/tests/test_process_and_send_results.sh" - "scripts/tests/test_send_estimate_artifacts.sh" - "scripts/tests/test_send_results_profile_data.sh" - "scripts/test_estimate_submit.sh" @@ -49,6 +50,7 @@ on: - "scripts/tests/fixtures/**" - "scripts/tests/test_genesis_gpu_mlp_estimation.sh" - "scripts/tests/test_result_profile_data.sh" + - "scripts/tests/test_process_and_send_results.sh" - "scripts/tests/test_send_estimate_artifacts.sh" - "scripts/tests/test_send_results_profile_data.sh" - "scripts/test_estimate_submit.sh" @@ -127,6 +129,7 @@ jobs: bash scripts/tests/test_bk_profiler.sh bash scripts/tests/test_ncu_plan_generation.sh bash scripts/tests/test_result_profile_data.sh + bash scripts/tests/test_process_and_send_results.sh bash scripts/tests/test_send_results_profile_data.sh bash scripts/tests/test_send_estimate_artifacts.sh bash scripts/tests/test_estimation_gpu_kernel_ensemble_average.sh diff --git a/scripts/result_server/process_and_send_results.sh b/scripts/result_server/process_and_send_results.sh index 1f95f73..b2eb9d4 100644 --- a/scripts/result_server/process_and_send_results.sh +++ b/scripts/result_server/process_and_send_results.sh @@ -12,6 +12,7 @@ work_dir="${project_dir}/send_results_workspace" rm -rf "$work_dir" mkdir -p "$work_dir" cp -R results "$work_dir/results" +chmod -R u+rwX "$work_dir/results" cd "$work_dir" bash "$project_dir/scripts/collect_timing.sh" diff --git a/scripts/tests/test_process_and_send_results.sh b/scripts/tests/test_process_and_send_results.sh new file mode 100644 index 0000000..ab6874a --- /dev/null +++ b/scripts/tests/test_process_and_send_results.sh @@ -0,0 +1,62 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +REPO_DIR=$(cd "${SCRIPT_DIR}/../.." && pwd) + +if ! command -v jq >/dev/null 2>&1; then + echo "jq not found; skipping process_and_send_results test" + exit 0 +fi + +TMP_DIR=$(mktemp -d) +trap 'chmod -R u+rwX "${TMP_DIR}" 2>/dev/null || true; rm -rf "${TMP_DIR}"' EXIT + +mkdir -p "${TMP_DIR}/project/scripts/result_server" "${TMP_DIR}/project/results" "${TMP_DIR}/bin" +cp "${REPO_DIR}/scripts/collect_timing.sh" "${TMP_DIR}/project/scripts/collect_timing.sh" +cp "${REPO_DIR}/scripts/result.sh" "${TMP_DIR}/project/scripts/result.sh" +cp "${REPO_DIR}/scripts/result_server/send_results.sh" "${TMP_DIR}/project/scripts/result_server/send_results.sh" +cp "${REPO_DIR}/scripts/result_server/process_and_send_results.sh" "${TMP_DIR}/project/scripts/result_server/process_and_send_results.sh" + +cat > "${TMP_DIR}/project/results/result" <<'EOF' +FOM:1.25 FOM_unit:s FOM_version:test Exp:CASE0 node_count:1 numproc_node:2 nthreads:3 +EOF + +printf '%s\n' 100 > "${TMP_DIR}/project/results/build_start" +printf '%s\n' 105 > "${TMP_DIR}/project/results/build_end" +printf '%s\n' 110 > "${TMP_DIR}/project/results/run_start" +printf '%s\n' 120 > "${TMP_DIR}/project/results/run_end" + +cat > "${TMP_DIR}/bin/curl" <<'EOF' +#!/bin/bash +set -euo pipefail +if printf '%s\n' "$*" | grep -q '/api/ingest/result'; then + printf '%s\n' '{"id":"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee","timestamp":"20260728_070000"}' + exit 0 +fi +printf '%s\n' '{"status":"ok"}' +EOF +chmod +x "${TMP_DIR}/bin/curl" + +chmod -R a-w "${TMP_DIR}/project/results" +chmod -R a+rX "${TMP_DIR}/project/results" + +export PATH="${TMP_DIR}/bin:${PATH}" +export RESULT_SERVER="https://example.invalid" +export RESULT_SERVER_KEY="dummy" + +pushd "${TMP_DIR}/project" >/dev/null +bash scripts/result_server/process_and_send_results.sh qws Fugaku cross qws_Fugaku_build qws_Fugaku_N1_P2_T3_run 12345 +popd >/dev/null + +test ! -f "${TMP_DIR}/project/results/result0.json" +test -f "${TMP_DIR}/project/send_results_workspace/results/result0.json" +test -f "${TMP_DIR}/project/send_results_workspace/results/server_result_meta.json" +test -f "${TMP_DIR}/project/send_results_workspace/results/pipeline_timing.json" + +jq -e '._server_uuid == "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"' \ + "${TMP_DIR}/project/send_results_workspace/results/result0.json" >/dev/null +jq -e '."result0.json".uuid == "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"' \ + "${TMP_DIR}/project/send_results_workspace/results/server_result_meta.json" >/dev/null + +echo "process_and_send_results read-only artifact test passed"