Modify URM Test Runner - #585
Srikanth Muppandam (smuppand) merged 1 commit into
Conversation
de6e138 to
213c768
Compare
|
Summary of the changes made to address flock locking related issues
|
36bfbe3 to
5e64d8e
Compare
| # Restart URM service so that the URM server is aware of the | ||
| # test nodes staged in the temporary directory. | ||
| log_info "Restarting URM service" | ||
| if ! systemctl restart urm; then |
There was a problem hiding this comment.
Restart the selected service instead of the hard-coded urm unit. The runner documents and checks SERVICE_NAME, but this block restarts and verifies urm. With SERVICE_NAME=custom-urm.service, the configured daemon is never restarted while the logs claim that it is active, so tests can run against stale state or incorrectly SKIP. Use "$SERVICE_NAME" consistently for restart and readiness checks.
There was a problem hiding this comment.
Replaced hard-coded urm operations with "$SERVICE_NAME" consistently.
| # test nodes staged in the temporary directory. | ||
| log_info "Restarting URM service" | ||
| if ! systemctl restart urm; then | ||
| log_skip "[SERVICE] $SERVICE_NAME could not be restarted — overall SKIP" |
There was a problem hiding this comment.
A failed required restart must not produce a neutral SKIP. The service was already identified as applicable, and this change states that restarting it is required before the staged nodes can be tested.
Returning SKIP here, or when the service never becomes active, can leave CI green without executing the validation.
Record FAIL and retain systemctl status or journal evidence, reserve SKIP for a genuinely absent or non-applicable service.
There was a problem hiding this comment.
Changed required restart failure and post-restart inactive state from neutral SKIP to FAIL.
| exit 0 | ||
| fi | ||
|
|
||
| for i in $(seq 1 10); do |
There was a problem hiding this comment.
Do not depend on an unchecked seq command for service verification. seq is not included in the dependency check, and when it is unavailable the loop executes zero times and the script proceeds without confirming that URM became active. Use a POSIX arithmetic while loop or a shared bounded-wait helper.
There was a problem hiding this comment.
Replaced unchecked seq usage with a usual while loop for service readiness polling.
|
|
||
| # Restart URM service so that the URM server is aware of the | ||
| # test nodes staged in the temporary directory. | ||
| log_info "Restarting URM service" |
There was a problem hiding this comment.
Restart URM only when at least one suite is runnable and node staging succeeded. The current flow restarts the system service even when all binaries are missing or the configuration and nodes will cause every suite to SKIP.
Determine the runnable set first, or perform one guarded restart immediately before the first runnable test.
There was a problem hiding this comment.
Deferred required service restart until immediately before the first runnable suite.
There was a problem hiding this comment.
Avoided restarting the service when all suites will SKIP due to missing binary, missing config, or failed node staging.
| sleep_rc=$? | ||
| trap - INT TERM | ||
| rm -f "$sleep_pid_file" 2>/dev/null || true | ||
| if [ "$sleep_rc" -eq 0 ]; then |
There was a problem hiding this comment.
Record when the timeout watcher actually expires. Currently a timed-out binary returns a signal-derived status such as 143 or 137, which run_one reports only as “UNKNOWN RC” that is indistinguishable from an external signal or crash. Write a timeout marker or return a stable timeout status such as 124, then log the command and configured deadline.
There was a problem hiding this comment.
- Updated run_one() to classify 124 as TIMEOUT / FAIL.
- Added timeout marker handling so helper-expired commands return stable 124 instead of ambiguous signal-derived statuses.
There was a problem hiding this comment.
Added timeout logging with the configured deadline and full command.
| # run_with_timeout() path here so the command, watcher and watcher sleep all | ||
| # drop the lock FD before running, and so the watcher/sleep PIDs can be killed | ||
| # and waited during normal completion or cleanup. | ||
| run_cmd_with_timeout_no_lock_fd() { |
There was a problem hiding this comment.
Update the suite README for the changed runtime contract. It currently says timeout handling is conditional on the shared run_with_timeout helper and does not document the mandatory service restart, its result classification, or the new lock-cleanup diagnostics.
Also add the required function contract describing arguments, return statuses, spawned processes, retained files, and cleanup ownership for this timeout helper.
There was a problem hiding this comment.
Updated the suite README to describe the current runtime contract, including selected SERVICE_NAME, required service restart, timeout behavior, lock cleanup, and diagnostics.
5e64d8e to
1e4e892
Compare
|
Hi Srikanth Muppandam (@smuppand) please let me know if additional changes are needed |
| } | ||
|
|
||
| # shellcheck disable=SC2317 # Invoked indirectly by INT/TERM traps. | ||
| cleanup_signal() { |
There was a problem hiding this comment.
Cleanup_signal() exits with 130/143 without writing or clearing the result file. The YAML ignores the runner exit code and always passes userspace-resource-manager.res to send-to-lava.sh. If an earlier run left PASS, an interrupted run can publish that stale PASS.
Initialize/remove the result at startup and write FAIL from the signal path, preferably through the shared result lifecycle.
There was a problem hiding this comment.
Addressed stale result handling by initializing/removing userspace-resource-manager.res at startup via test_result_init when available, with a fallback rm -f. Added a shared write_result() helper and changed cleanup_signal() to write FAIL before cleanup and before exiting with 130/143. This prevents LAVA from publishing a stale PASS after an interrupted run.
There was a problem hiding this comment.
check_systemd_services() returns success when systemctl is absent or the unit is missing/disabled. The runner consequently logs the service as active, bypasses the absent-service branch, and later fails during mandatory restart.
Use systemd_service_exists() and systemd_service_is_active() explicitly before start/restart.
There was a problem hiding this comment.
Replaced the initial service gate’s use of check_systemd_services() with explicit systemd_service_exists() and systemd_service_is_active() predicates. The runner now correctly distinguishes absent/non-applicable service as SKIP from applicable-but-inactive/unstartable service as FAIL. The mandatory restart path also validates service existence before restart and uses systemd_service_is_active() for readiness polling.
| # Retained files: temporary watcher sleep/timeout marker files under LOGDIR | ||
| # while running only; this helper removes them before return, | ||
| # and cleanup() owns removal on interruption. | ||
| run_cmd_with_timeout_no_lock_fd() { |
There was a problem hiding this comment.
The timeout implementation is generic lifecycle behavior and duplicates shared utility responsibilities. It should be moved into or used to improve functestlib.sh.
There was a problem hiding this comment.
My only concern being that I don't want to touch any core infra which impacts users and teams beyond URM, please advice.
There was a problem hiding this comment.
My only concern being that I don't want to touch any core infra which impacts users and teams beyond URM, please advice.
That concern is valid. Please do not change the existing run_with_timeout() behavior in this PR, since it has other callers. Instead, add a new opt-in managed-timeout helper in functestlib.sh and use it only from URM. Keep the FD 9 closure and URM-specific cleanup wrapper local. This avoids regressions for other suites while keeping reusable timeout lifecycle code out of run.sh.
The other two functional findings remain unresolved at the current head:
- Signal cleanup can publish a stale .res result because the result is neither initialized nor finalized as FAIL.
- check_systemd_services() treats missing systemd or missing/disabled units as success, so it cannot be used for the initial applicability/active-state gate. Please use systemd_service_exists() and systemd_service_is_active() explicitly.
There was a problem hiding this comment.
Addressed the timeout lifecycle review by moving the generic timeout lifecycle behavior out of the URM runner and into a new opt-in helper in functestlib.sh: run_with_managed_timeout(). The existing run_with_timeout() implementation was intentionally left unchanged to avoid impacting existing suites and callers.
URM now uses the new helper only through a thin local wrapper, run_cmd_with_timeout_no_lock_fd(). The wrapper keeps URM-specific behavior local by setting MANAGED_TIMEOUT_PRE_EXEC_HOOK=close_lock_fd_in_child, so the test command, timeout watcher, and watcher sleep close inherited FD 9 before running. This preserves the URM-specific lock handling without pushing FD 9 behavior into shared infrastructure.
URM cleanup also remains local. The shared managed-timeout helper exposes runtime state through MANAGED_TIMEOUT_* variables, and URM’s existing cleanup() trap uses those variables to kill/wait the command, watcher, watcher sleep, and remove timeout marker files on normal cleanup or interruption.
This keeps the reusable timeout process lifecycle in functestlib.sh, avoids changing legacy run_with_timeout() semantics, and limits behavioral change to URM as an explicit opt-in user.
13da9a5 to
84adb68
Compare
- URM service needs to be restarted before starting the tests, so that the new test nodes staged in /tmp are processed by the URM server. - Modify the flock concurrency control mechanism to enforce explicit cleanup of the lock file - Timeout watcher and sleep process are explicitly terminated/waited during normal completion and signal cleanup. Signed-off-by: Kartik Nema <kartnema@qti.qualcomm.com>
84adb68 to
05f3bc4
Compare
Srikanth Muppandam (smuppand)
left a comment
There was a problem hiding this comment.
LGTM
bae1de9
into
qualcomm-linux:main
so that the new test nodes staged in /tmp are processed
by the URM server.
cleanup of the lock file
during normal completion and signal cleanup.