mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-18 04:58:51 +02:00
Explicitly run test servers on ipv4 localhost.
If a host defaults to ipv6 then it can confuse the tests and lead to connection failures and inconsistent error messages. For now just hard-code the servers to run on ipv4 but this is an area for later improvement.
This commit is contained in:
parent
04b0437976
commit
c401ae8fb8
@ -268,7 +268,7 @@ hrnServerRun(IoRead *const read, const HrnServerProtocol protocol, const unsigne
|
|||||||
tlsServer = tlsServerNew(STRDEF(HRN_SERVER_HOST), param.ca, param.key, param.certificate, 5000);
|
tlsServer = tlsServerNew(STRDEF(HRN_SERVER_HOST), param.ca, param.key, param.certificate, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
IoServer *socketServer = sckServerNew(STRDEF("localhost"), port, 5000);
|
IoServer *socketServer = sckServerNew(STRDEF("127.0.0.1"), port, 5000);
|
||||||
|
|
||||||
// Loop until no more commands
|
// Loop until no more commands
|
||||||
IoSession *serverSession = NULL;
|
IoSession *serverSession = NULL;
|
||||||
|
@ -123,6 +123,7 @@ testRun(void)
|
|||||||
storageTest,
|
storageTest,
|
||||||
"pgbackrest.conf",
|
"pgbackrest.conf",
|
||||||
"[global]\n"
|
"[global]\n"
|
||||||
|
CFGOPT_TLS_SERVER_ADDRESS "=127.0.0.1\n"
|
||||||
CFGOPT_TLS_SERVER_CA_FILE "=" HRN_SERVER_CA "\n"
|
CFGOPT_TLS_SERVER_CA_FILE "=" HRN_SERVER_CA "\n"
|
||||||
CFGOPT_TLS_SERVER_CERT_FILE "=" HRN_SERVER_CERT "\n"
|
CFGOPT_TLS_SERVER_CERT_FILE "=" HRN_SERVER_CERT "\n"
|
||||||
CFGOPT_TLS_SERVER_KEY_FILE "=" HRN_SERVER_KEY "\n"
|
CFGOPT_TLS_SERVER_KEY_FILE "=" HRN_SERVER_KEY "\n"
|
||||||
@ -221,7 +222,7 @@ testRun(void)
|
|||||||
TEST_RESULT_VOID(cmdServerPing(), "ping");
|
TEST_RESULT_VOID(cmdServerPing(), "ping");
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("ping 12.0.0.1");
|
TEST_TITLE("ping 127.0.0.1");
|
||||||
|
|
||||||
argList = strLstNew();
|
argList = strLstNew();
|
||||||
hrnCfgArgRawFmt(argList, cfgOptTlsServerPort, "%u", testPort);
|
hrnCfgArgRawFmt(argList, cfgOptTlsServerPort, "%u", testPort);
|
||||||
@ -242,6 +243,7 @@ testRun(void)
|
|||||||
HRN_FORK_CHILD_BEGIN(.prefix = "server")
|
HRN_FORK_CHILD_BEGIN(.prefix = "server")
|
||||||
{
|
{
|
||||||
StringList *argList = strLstNew();
|
StringList *argList = strLstNew();
|
||||||
|
hrnCfgArgRawZ(argList, cfgOptTlsServerAddress, "127.0.0.1");
|
||||||
hrnCfgArgRawZ(argList, cfgOptTlsServerCaFile, HRN_SERVER_CA);
|
hrnCfgArgRawZ(argList, cfgOptTlsServerCaFile, HRN_SERVER_CA);
|
||||||
hrnCfgArgRawZ(argList, cfgOptTlsServerCertFile, HRN_SERVER_CERT);
|
hrnCfgArgRawZ(argList, cfgOptTlsServerCertFile, HRN_SERVER_CERT);
|
||||||
hrnCfgArgRawZ(argList, cfgOptTlsServerKeyFile, HRN_SERVER_KEY);
|
hrnCfgArgRawZ(argList, cfgOptTlsServerKeyFile, HRN_SERVER_KEY);
|
||||||
|
@ -497,12 +497,20 @@ testRun(void)
|
|||||||
|
|
||||||
// Shim the server address to return false one time for write ready. This tests connections that take longer.
|
// Shim the server address to return false one time for write ready. This tests connections that take longer.
|
||||||
hrnSckClientOpenWaitShimInstall("127.0.0.1");
|
hrnSckClientOpenWaitShimInstall("127.0.0.1");
|
||||||
|
AddressInfo *addrInfo = addrInfoNew(STRDEF("127.0.0.1"), 443);
|
||||||
|
ASSERT(addrInfoSize(addrInfo) == 1);
|
||||||
|
|
||||||
TEST_ASSIGN(session, ioClientOpen(client), "connection established");
|
TEST_ASSIGN(session, ioClientOpen(client), "connection established");
|
||||||
TEST_RESULT_VOID(
|
|
||||||
sckClientOpenWait(
|
SckClientOpenData openData =
|
||||||
&(SckClientOpenData){.name = "test", .fd = ((SocketSession *)session->pub.driver)->fd, .errNo = EINTR}, 99),
|
{
|
||||||
"check EINTR wait condition");
|
.name = "test",
|
||||||
|
.fd = ((SocketSession *)session->pub.driver)->fd,
|
||||||
|
.address = addrInfoGet(addrInfo, 0)->info,
|
||||||
|
.errNo = EINTR
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_RESULT_VOID(sckClientOpenWait(&openData, 99), "check EINTR wait condition");
|
||||||
TEST_RESULT_VOID(ioSessionFree(session), "connection closed");
|
TEST_RESULT_VOID(ioSessionFree(session), "connection closed");
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------
|
||||||
@ -877,15 +885,15 @@ testRun(void)
|
|||||||
HRN_FORK_CHILD_BEGIN(.prefix = "test server", .timeout = 5000)
|
HRN_FORK_CHILD_BEGIN(.prefix = "test server", .timeout = 5000)
|
||||||
{
|
{
|
||||||
// TLS server to accept connections
|
// TLS server to accept connections
|
||||||
IoServer *socketServer = sckServerNew(STRDEF("localhost"), testPort, 5000);
|
IoServer *socketServer = sckServerNew(STRDEF("127.0.0.1"), testPort, 5000);
|
||||||
IoServer *tlsServer = tlsServerNew(
|
IoServer *tlsServer = tlsServerNew(
|
||||||
STRDEF("localhost"), STRDEF(HRN_SERVER_CA), STRDEF(TEST_PATH "/server-root-perm-link"),
|
STRDEF("127.0.0.1"), STRDEF(HRN_SERVER_CA), STRDEF(TEST_PATH "/server-root-perm-link"),
|
||||||
STRDEF(TEST_PATH "/server-cn-only.crt"), 5000);
|
STRDEF(TEST_PATH "/server-cn-only.crt"), 5000);
|
||||||
IoSession *socketSession = NULL;
|
IoSession *socketSession = NULL;
|
||||||
|
|
||||||
TEST_RESULT_STR(
|
TEST_RESULT_STR(
|
||||||
ioServerName(socketServer), strNewFmt("localhost:%u (127.0.0.1)", testPort), "socket server name");
|
ioServerName(socketServer), strNewFmt("127.0.0.1:%u", testPort), "socket server name");
|
||||||
TEST_RESULT_STR_Z(ioServerName(tlsServer), "localhost", "tls server name");
|
TEST_RESULT_STR_Z(ioServerName(tlsServer), "127.0.0.1", "tls server name");
|
||||||
|
|
||||||
// Invalid client cert
|
// Invalid client cert
|
||||||
socketSession = ioServerAccept(socketServer, NULL);
|
socketSession = ioServerAccept(socketServer, NULL);
|
||||||
|
@ -817,8 +817,8 @@ testRun(void)
|
|||||||
HRN_FORK_PARENT_BEGIN()
|
HRN_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoServer *const tlsServer = tlsServerNew(
|
IoServer *const tlsServer = tlsServerNew(
|
||||||
STRDEF("localhost"), STRDEF(HRN_SERVER_CA), STRDEF(HRN_SERVER_KEY), STRDEF(HRN_SERVER_CERT), 5000);
|
STRDEF("127.0.0.1"), STRDEF(HRN_SERVER_CA), STRDEF(HRN_SERVER_KEY), STRDEF(HRN_SERVER_CERT), 5000);
|
||||||
IoServer *const socketServer = sckServerNew(STRDEF("localhost"), testPort, 5000);
|
IoServer *const socketServer = sckServerNew(STRDEF("127.0.0.1"), testPort, 5000);
|
||||||
ProtocolServer *server = NULL;
|
ProtocolServer *server = NULL;
|
||||||
|
|
||||||
// Server ping
|
// Server ping
|
||||||
|
Loading…
x
Reference in New Issue
Block a user