|
KiCad PCB EDA Suite
|
Manages a single shared kicad-cli api-server process and NNG client across all E2E tests. More...
#include <api_e2e_utils.h>
Public Member Functions | |
| bool | EnsureReady (const wxString &aCliPath, wxString *aError) |
| Ensure the api-server is running and the shared client is connected and responsive. | |
| API_TEST_CLIENT & | Client () |
| void | Reset () |
| Kill the current server and reset state so EnsureReady() will start fresh. | |
Static Public Member Functions | |
| static API_SERVER_MANAGER & | Instance () |
Private Member Functions | |
| API_SERVER_MANAGER () | |
| ~API_SERVER_MANAGER () | |
| API_SERVER_MANAGER (const API_SERVER_MANAGER &)=delete | |
| API_SERVER_MANAGER & | operator= (const API_SERVER_MANAGER &)=delete |
| bool | startServerProcess (const wxString &aCliPath, wxString *aError) |
| bool | connectAndWaitReady (wxString *aError) |
| void | collectServerOutput () |
| bool | isProcessAlive () const |
Private Attributes | |
| bool | m_ready = false |
| API_TEST_CLIENT | m_client |
| API_SERVER_PROCESS * | m_process = nullptr |
| long | m_pid = 0 |
| wxString | m_socketPath |
| wxString | m_socketUrl |
| wxString | m_stdout |
| wxString | m_stderr |
| int | m_exitCode = 0 |
Manages a single shared kicad-cli api-server process and NNG client across all E2E tests.
Starting the api-server takes several seconds due to process startup and IPC handshake. Rather than paying that cost per test case, this singleton starts the server and connects a single persistent client on first use. Both live until the test module exits.
A single NNG client is used because the NNG req/rep protocol does not reliably handle rapid connect/disconnect cycles on IPC sockets. Keeping one persistent connection avoids stale pipe state in the server's rep socket.
Definition at line 480 of file api_e2e_utils.h.
|
inlineprivate |
Definition at line 539 of file api_e2e_utils.h.
References m_socketPath, and m_socketUrl.
Referenced by API_SERVER_MANAGER(), Instance(), and operator=().
|
inlineprivate |
Definition at line 558 of file api_e2e_utils.h.
References m_pid, and m_socketPath.
|
privatedelete |
References API_SERVER_MANAGER().
|
inline |
Definition at line 512 of file api_e2e_utils.h.
References m_client.
Referenced by API_SERVER_E2E_FIXTURE::Client().
|
inlineprivate |
Definition at line 688 of file api_e2e_utils.h.
References API_SERVER_PROCESS::drainStream(), m_process, m_stderr, and m_stdout.
Referenced by connectAndWaitReady().
|
inlineprivate |
Definition at line 633 of file api_e2e_utils.h.
References collectServerOutput(), isProcessAlive(), m_client, m_socketUrl, and traceApi.
Referenced by EnsureReady().
|
inline |
Ensure the api-server is running and the shared client is connected and responsive.
Definition at line 492 of file api_e2e_utils.h.
References connectAndWaitReady(), isProcessAlive(), m_ready, and startServerProcess().
Referenced by API_SERVER_E2E_FIXTURE::Start().
|
inlinestatic |
Definition at line 483 of file api_e2e_utils.h.
References API_SERVER_MANAGER().
Referenced by API_SERVER_E2E_FIXTURE::Client(), and API_SERVER_E2E_FIXTURE::Start().
|
inlineprivate |
Definition at line 697 of file api_e2e_utils.h.
References BOOST_TEST_MESSAGE(), m_pid, and result.
Referenced by connectAndWaitReady(), EnsureReady(), and Reset().
|
privatedelete |
References API_SERVER_MANAGER().
|
inline |
Kill the current server and reset state so EnsureReady() will start fresh.
Definition at line 517 of file api_e2e_utils.h.
References isProcessAlive(), m_client, m_pid, m_process, m_ready, and m_socketPath.
Referenced by API_SERVER_E2E_FIXTURE::Start().
|
inlineprivate |
Definition at line 584 of file api_e2e_utils.h.
References m_exitCode, m_pid, m_process, m_ready, m_socketPath, m_stderr, and m_stdout.
Referenced by EnsureReady().
|
private |
Definition at line 731 of file api_e2e_utils.h.
Referenced by Client(), connectAndWaitReady(), and Reset().
|
mutableprivate |
Definition at line 738 of file api_e2e_utils.h.
Referenced by startServerProcess().
|
private |
Definition at line 733 of file api_e2e_utils.h.
Referenced by isProcessAlive(), Reset(), startServerProcess(), and ~API_SERVER_MANAGER().
|
private |
Definition at line 732 of file api_e2e_utils.h.
Referenced by collectServerOutput(), Reset(), and startServerProcess().
|
private |
Definition at line 730 of file api_e2e_utils.h.
Referenced by EnsureReady(), Reset(), and startServerProcess().
|
private |
Definition at line 734 of file api_e2e_utils.h.
Referenced by API_SERVER_MANAGER(), Reset(), startServerProcess(), and ~API_SERVER_MANAGER().
|
private |
Definition at line 735 of file api_e2e_utils.h.
Referenced by API_SERVER_MANAGER(), and connectAndWaitReady().
|
private |
Definition at line 737 of file api_e2e_utils.h.
Referenced by collectServerOutput(), and startServerProcess().
|
private |
Definition at line 736 of file api_e2e_utils.h.
Referenced by collectServerOutput(), and startServerProcess().