NAME
IPC::Manager::Test - Reusable protocol-agnostic test suite for IPC::Manager
DESCRIPTION
This module provides a set of standard tests that verify the correctness of an IPC::Manager protocol implementation. Each test is an ordinary method whose name begins with test_; they are discovered automatically by tests() and executed by run_all().
Protocol test files typically look like:
use Test2::V1 -ipP;
use Test2::IPC;
use IPC::Manager::Test;
IPC::Manager::Test->run_all(protocol => 'AtomicPipe');
done_testing;
METHODS
- IPC::Manager::Test->run_all(protocol => $PROTOCOL)
-
Run every
test_*method as an isolated subtest. Each test is forked into its own process so that failures and resource leaks cannot affect sibling tests.protocolis required and is set as the default protocol viaipcm_default_protocolbefore any test runs. - @names = IPC::Manager::Test->tests
-
Returns a sorted list of all
test_*method names defined on the class (or a subclass). Used internally byrun_all. - IPC::Manager::Test->test_generic
-
Tests the low-level IPC bus: spawning a store, connecting multiple clients, sending point-to-point and broadcast messages, verifying message contents and ordering, and checking that per-client statistics are accurate on disconnect.
- IPC::Manager::Test->test_simple_service
-
Tests
ipcm_serviceat the single-service level: starts a named service, sends a request to it from the parent process, verifies the service echoes a response back with the correct content, and confirms that both sides observed the exchange. - IPC::Manager::Test->test_nested_services
-
Tests the nested-service code path where
ipcm_serviceis called from inside a running service. An outer service starts an inner service during itson_startcallback, then acts as a transparent proxy: each request received from the test process is forwarded to the inner service, and the inner service's response is returned to the caller with an identifying prefix. The test verifies the full two-hop request/response chain. - IPC::Manager::Test->test_exec_service
-
Tests the
execcode path ofipcm_service. Instead of running the service in a forked child, the child callsexec()to start a fresh Perl interpreter that loads IPC::Manager::Service::State and deserialises the service parameters from@ARGV. The test starts IPC::Manager::Service::Echo via exec, sends a request, and verifies the echoed response. - IPC::Manager::Test->test_workers
-
Tests the
ipcm_workerfacility. A service spawns two workers duringon_start: a short-lived worker that writes a marker file and exits, and a long-lived worker that sleeps indefinitely. The test verifies that both workers run, that the service tracks them viaworkers(), and thatterminate_workers()kills the long-lived worker when the service shuts down. - IPC::Manager::Test->test_suspend_and_reconnect
-
Tests the suspend/reconnect lifecycle. A client suspends (preserving its slot on the bus), messages are sent to it while it is away, and then it reconnects and verifies that both the pre-suspend and during-suspend messages are received. Skipped for protocols that do not support reconnect (e.g. AtomicPipe).
- IPC::Manager::Test->test_sync_request
-
Tests synchronous (blocking) request/response via
$handle->sync_request. Sends a single request and verifies the returned response without using callbacks. - IPC::Manager::Test->test_multiple_requests
-
Sends five concurrent requests to a service using callback-based
send_request, awaits all responses withawait_all_responses, and verifies that every response arrived with the correct content. - IPC::Manager::Test->test_handle_messages_buffer
-
Tests the Handle's non-response message buffer. A service sends both a response and a plain (non-response) notification for the same request. The test verifies the response is delivered via the callback and the notification lands in
$handle->messages. - IPC::Manager::Test->test_service_callbacks
-
Exercises the
on_interval,on_peer_delta,on_cleanup, andshould_endservice callbacks in a single service. Verifies thaton_intervalfires periodically,on_peer_deltafires when a new peer connects,should_endterminates the service when its condition becomes true, andon_cleanupruns during shutdown. - IPC::Manager::Test->test_service_signal_handling
-
Tests the
on_sigcallback by starting a service that interceptsSIGUSR1, sending the signal from the test process, and verifying the handler ran. - IPC::Manager::Test->test_peer_active
-
Tests
$client->peer_activeby connecting two clients and verifying each sees the other as active. Also verifies that a nonexistent peer name returns false. - IPC::Manager::Test->test_disconnect_with_handler
-
Tests the disconnect handler callback. Sends messages to a client then disconnects it with a handler; verifies the handler receives the pending messages instead of producing a warning.
- IPC::Manager::Test->test_try_message
-
Tests
try_messagein both scalar and list context for both the success path (message delivered) and the failure path (nonexistent peer). - IPC::Manager::Test->test_general_messages_to_service
-
Sends a plain (non-request, non-response) message to a service and verifies that
on_general_messageis invoked with the correct content. - IPC::Manager::Test->test_intercept_errors
-
Starts a service with
intercept_errors => 1, sends a request that triggers an exception in the handler, then sends a second request to verify the service survived and continued processing. - IPC::Manager::Test->test_watch_pids
-
Tests the
watch_pidsmechanism. A child process starts a service that watches the child's own PID. The child exits, and the test verifies that the service detected the death and ran its cleanup callback. - IPC::Manager::Test->test_spawn_terminate_with_signal
-
Tests that
Spawn::terminatesends a signal to service processes when the spawn has a signal configured. Verifies the service'son_sighandler fires for the delivered signal. - IPC::Manager::Test->test_cleave
-
Tests
Spawn::cleaveby double-forking ownership of the IPC bus away from the current process. Verifies the parent receives the new owner's PID, spawn ownership transfers, and the bus remains functional.
- IPC::Manager::Test->test_request_error_generic
-
Tests that an exception in
handle_requestsends an error response withipcm_errorset to a generic message ("Internal service error") andresponseset to undef. Verifies the service continues operating after the error. This is the default behaviour (expose_error_detailsoff). - IPC::Manager::Test->test_request_error_detailed
-
Tests that with
expose_error_details => 1an exception inhandle_requestsends an error response whoseipcm_errorcontains the actual exception text. Verifies the service continues operating.
SOURCE
The source code repository for IPC::Manager can be found at https://github.com/exodist/IPC-Manager.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See https://dev.perl.org/licenses/
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1298:
'=item' outside of any '=over'