KiCad PCB EDA Suite
Loading...
Searching...
No Matches
API_SERVER_MANAGER Class Reference

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_CLIENTClient ()
 
void Reset ()
 Kill the current server and reset state so EnsureReady() will start fresh.
 

Static Public Member Functions

static API_SERVER_MANAGERInstance ()
 

Private Member Functions

 API_SERVER_MANAGER ()
 
 ~API_SERVER_MANAGER ()
 
 API_SERVER_MANAGER (const API_SERVER_MANAGER &)=delete
 
API_SERVER_MANAGERoperator= (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_PROCESSm_process = nullptr
 
long m_pid = 0
 
wxString m_socketPath
 
wxString m_socketUrl
 
wxString m_stdout
 
wxString m_stderr
 
int m_exitCode = 0
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ API_SERVER_MANAGER() [1/2]

API_SERVER_MANAGER::API_SERVER_MANAGER ( )
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=().

◆ ~API_SERVER_MANAGER()

API_SERVER_MANAGER::~API_SERVER_MANAGER ( )
inlineprivate

Definition at line 558 of file api_e2e_utils.h.

References m_pid, and m_socketPath.

◆ API_SERVER_MANAGER() [2/2]

API_SERVER_MANAGER::API_SERVER_MANAGER ( const API_SERVER_MANAGER & )
privatedelete

References API_SERVER_MANAGER().

Member Function Documentation

◆ Client()

API_TEST_CLIENT & API_SERVER_MANAGER::Client ( )
inline

Definition at line 512 of file api_e2e_utils.h.

References m_client.

Referenced by API_SERVER_E2E_FIXTURE::Client().

◆ collectServerOutput()

void API_SERVER_MANAGER::collectServerOutput ( )
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().

◆ connectAndWaitReady()

bool API_SERVER_MANAGER::connectAndWaitReady ( wxString * aError)
inlineprivate

Definition at line 633 of file api_e2e_utils.h.

References collectServerOutput(), isProcessAlive(), m_client, m_socketUrl, and traceApi.

Referenced by EnsureReady().

◆ EnsureReady()

bool API_SERVER_MANAGER::EnsureReady ( const wxString & aCliPath,
wxString * aError )
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().

◆ Instance()

static API_SERVER_MANAGER & API_SERVER_MANAGER::Instance ( )
inlinestatic

◆ isProcessAlive()

bool API_SERVER_MANAGER::isProcessAlive ( ) const
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().

◆ operator=()

API_SERVER_MANAGER & API_SERVER_MANAGER::operator= ( const API_SERVER_MANAGER & )
privatedelete

References API_SERVER_MANAGER().

◆ Reset()

void API_SERVER_MANAGER::Reset ( )
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().

◆ startServerProcess()

bool API_SERVER_MANAGER::startServerProcess ( const wxString & aCliPath,
wxString * aError )
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().

Member Data Documentation

◆ m_client

API_TEST_CLIENT API_SERVER_MANAGER::m_client
private

Definition at line 731 of file api_e2e_utils.h.

Referenced by Client(), connectAndWaitReady(), and Reset().

◆ m_exitCode

int API_SERVER_MANAGER::m_exitCode = 0
mutableprivate

Definition at line 738 of file api_e2e_utils.h.

Referenced by startServerProcess().

◆ m_pid

long API_SERVER_MANAGER::m_pid = 0
private

Definition at line 733 of file api_e2e_utils.h.

Referenced by isProcessAlive(), Reset(), startServerProcess(), and ~API_SERVER_MANAGER().

◆ m_process

API_SERVER_PROCESS* API_SERVER_MANAGER::m_process = nullptr
private

Definition at line 732 of file api_e2e_utils.h.

Referenced by collectServerOutput(), Reset(), and startServerProcess().

◆ m_ready

bool API_SERVER_MANAGER::m_ready = false
private

Definition at line 730 of file api_e2e_utils.h.

Referenced by EnsureReady(), Reset(), and startServerProcess().

◆ m_socketPath

wxString API_SERVER_MANAGER::m_socketPath
private

◆ m_socketUrl

wxString API_SERVER_MANAGER::m_socketUrl
private

Definition at line 735 of file api_e2e_utils.h.

Referenced by API_SERVER_MANAGER(), and connectAndWaitReady().

◆ m_stderr

wxString API_SERVER_MANAGER::m_stderr
private

Definition at line 737 of file api_e2e_utils.h.

Referenced by collectServerOutput(), and startServerProcess().

◆ m_stdout

wxString API_SERVER_MANAGER::m_stdout
private

Definition at line 736 of file api_e2e_utils.h.

Referenced by collectServerOutput(), and startServerProcess().


The documentation for this class was generated from the following file: