Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
simulated-test-with-php-data-collection/rtc-test-cookies.txt
simulated-test-with-php-data-collection/rtc-test.env
/rtc-test-cookies.txt

test-results-[0-9]*.log
submit-response-[0-9]*.log
23 changes: 20 additions & 3 deletions rtc-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,19 @@ function rtctest_register_routes() {
'callback' => 'rtctest_rest_report_all',
'permission_callback' => $cap_check,
'args' => array(
'poll_delay' => array(
'poll_delay' => array(
'required' => false,
'type' => 'integer',
),
'update_size' => array(
'update_size' => array(
'required' => false,
'type' => 'string',
),
'save_results' => array(
'required' => false,
'type' => 'boolean',
'default' => false,
),
),
)
);
Expand Down Expand Up @@ -875,7 +880,15 @@ function rtctest_rest_report_all( WP_REST_Request $request ) {
}
}

return rest_ensure_response( array( 'text' => ltrim( $out ) ) );
$report_text = ltrim( $out );

if ( $request->get_param( 'save_results' ) ) {
$timestamp = gmdate( 'Ymd\THis\Z' );
$path = ABSPATH . 'test-results-' . $timestamp . '.log';
file_put_contents( $path, $report_text, LOCK_EX );
}

return rest_ensure_response( array( 'text' => $report_text ) );
}

function rtctest_detect_object_cache_type() {
Expand Down Expand Up @@ -1071,6 +1084,10 @@ function rtctest_rest_submit( WP_REST_Request $request ) {
)
);

$submission_time = gmdate( 'Ymd\THis\Z' );
$log_path = ABSPATH . 'submit-response-' . $submission_time . '.log';
file_put_contents( $log_path, print_r( $response, true ), LOCK_EX );

if ( is_wp_error( $response ) ) {
return new WP_Error( 'submit_failed', $response->get_error_message(), array( 'status' => 502 ) );
}
Expand Down
18 changes: 15 additions & 3 deletions rtc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1732,8 +1732,20 @@ cmd_report() {
cmd_report_all() {
print_header "report-all"
require_auth
local url="${PLUGIN_REPORT_ALL_URL}"
local arg
for arg in "$@"; do
case "${arg}" in
--save-results)
case "${url}" in
*\?*) url="${url}&save_results=1" ;;
*) url="${url}?save_results=1" ;;
esac
;;
esac
done
local data
data=$(curl "${BASE_CURL_OPTS[@]}" "${PLUGIN_REPORT_ALL_URL}" 2>/dev/null) || true
data=$(curl "${BASE_CURL_OPTS[@]}" "${url}" 2>/dev/null) || true
_print_report_text "${data}"
}

Expand Down Expand Up @@ -2080,7 +2092,7 @@ case "${COMMAND}" in
sustain) cmd_sustain ;;
env) cmd_env ;;
report) cmd_report ;;
report-all) cmd_report_all ;;
report-all) shift; cmd_report_all "$@" ;;
submit-results) cmd_submit_results ;;
clear) cmd_clear ;;
reset) cmd_reset ;;
Expand Down Expand Up @@ -2113,7 +2125,7 @@ case "${COMMAND}" in
printf ' sustain N_CLIENTS independent pollers for DURATION seconds\n'
printf ' env Print environment snapshot (PHP, WP, DB, cache, etc.)\n'
printf ' report Fetch log from plugin and print summary table\n'
printf ' report-all Print summary by approach × scenario × poll_delay × update_size\n'
printf ' report-all [--save-results] Print summary by approach × scenario × poll_delay × update_size (--save-results writes test-results-TIMESTAMP.log to ABSPATH)\n'
printf ' submit-results POST all results to the reporter endpoint (requires REPORTER_* vars)\n'
printf ' clear Delete all log entries (table stays, schema intact)\n'
printf ' reset Drop the log table entirely (recreated on next tagged request)\n'
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ done
bash "${RTC}" reset-approach

# ── Results ───────────────────────────────────────────────────────────────────
bash "${RTC}" report-all
bash "${RTC}" report-all --save-results
bash "${RTC}" submit-results

printf '\nTotal wall time: %s\n' "$(_run_sh_format_elapsed "${SECONDS}")"