2018-02-14 09:49:01 -05:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test Perl Exec
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
#include "config/config.h"
|
|
|
|
|
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Test Run
|
|
|
|
***********************************************************************************************************************************/
|
|
|
|
void
|
2018-08-03 19:19:14 -04:00
|
|
|
testRun(void)
|
2018-02-14 09:49:01 -05:00
|
|
|
{
|
2018-05-18 11:57:32 -04:00
|
|
|
FUNCTION_HARNESS_VOID();
|
|
|
|
|
2018-02-14 09:49:01 -05:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------------------
|
2018-03-09 09:30:50 -05:00
|
|
|
if (testBegin("perlOptionJson()"))
|
2018-02-14 09:49:01 -05:00
|
|
|
{
|
|
|
|
cfgInit();
|
|
|
|
TEST_RESULT_STR(strPtr(perlOptionJson()), "{}", "no options");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
cfgInit();
|
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptCompress, true);
|
|
|
|
cfgOptionSet(cfgOptCompress, cfgSourceParam, varNewBool(true));
|
|
|
|
|
2018-03-08 10:43:09 -05:00
|
|
|
cfgOptionValidSet(cfgOptConfig, true);
|
|
|
|
cfgOptionNegateSet(cfgOptConfig, true);
|
|
|
|
cfgOptionSet(cfgOptConfig, cfgSourceParam, NULL);
|
|
|
|
|
2018-02-14 09:49:01 -05:00
|
|
|
cfgOptionValidSet(cfgOptOnline, true);
|
|
|
|
cfgOptionNegateSet(cfgOptOnline, true);
|
|
|
|
cfgOptionSet(cfgOptOnline, cfgSourceParam, varNewBool(false));
|
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptPgHost, true);
|
|
|
|
cfgOptionResetSet(cfgOptPgHost, true);
|
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptBackupStandby, true);
|
|
|
|
cfgOptionResetSet(cfgOptBackupStandby, true);
|
2018-03-08 10:43:09 -05:00
|
|
|
cfgOptionSet(cfgOptBackupStandby, cfgSourceParam, varNewBool(false));
|
2018-02-14 09:49:01 -05:00
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptProtocolTimeout, true);
|
|
|
|
cfgOptionSet(cfgOptProtocolTimeout, cfgSourceParam, varNewDbl(1.1));
|
|
|
|
|
2018-04-18 19:37:35 -04:00
|
|
|
cfgOptionValidSet(cfgOptArchivePushQueueMax, true);
|
|
|
|
cfgOptionSet(cfgOptArchivePushQueueMax, cfgSourceParam, varNewInt64(999999999999));
|
2018-02-14 09:49:01 -05:00
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptCompressLevel, true);
|
|
|
|
cfgOptionSet(cfgOptCompressLevel, cfgSourceConfig, varNewInt(3));
|
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptStanza, true);
|
|
|
|
cfgOptionSet(cfgOptStanza, cfgSourceDefault, varNewStr(strNew("db")));
|
|
|
|
|
|
|
|
TEST_RESULT_STR(
|
|
|
|
strPtr(perlOptionJson()),
|
|
|
|
"{"
|
2018-04-18 19:37:35 -04:00
|
|
|
"\"archive-push-queue-max\":"
|
|
|
|
"{\"valid\":true,\"source\":\"param\",\"negate\":false,\"reset\":false,\"value\":999999999999},"
|
2018-03-09 09:30:50 -05:00
|
|
|
"\"backup-standby\":{\"valid\":true,\"source\":\"param\",\"negate\":false,\"reset\":true,\"value\":false},"
|
|
|
|
"\"compress\":{\"valid\":true,\"source\":\"param\",\"negate\":false,\"reset\":false,\"value\":true},"
|
|
|
|
"\"compress-level\":{\"valid\":true,\"source\":\"config\",\"negate\":false,\"reset\":false,\"value\":3},"
|
|
|
|
"\"config\":{\"valid\":true,\"source\":\"param\",\"negate\":true,\"reset\":false},"
|
|
|
|
"\"online\":{\"valid\":true,\"source\":\"param\",\"negate\":true,\"reset\":false,\"value\":false},"
|
|
|
|
"\"pg1-host\":{\"valid\":true,\"source\":\"default\",\"negate\":false,\"reset\":true},"
|
|
|
|
"\"protocol-timeout\":{\"valid\":true,\"source\":\"param\",\"negate\":false,\"reset\":false,\"value\":1.1},"
|
|
|
|
"\"stanza\":{\"valid\":true,\"source\":\"default\",\"negate\":false,\"reset\":false,\"value\":\"db\"}"
|
2018-02-14 09:49:01 -05:00
|
|
|
"}",
|
|
|
|
"simple options");
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
cfgInit();
|
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptDbInclude, true);
|
|
|
|
StringList *includeList = strLstNew();
|
|
|
|
strLstAdd(includeList, strNew("db1"));
|
|
|
|
strLstAdd(includeList, strNew("db2"));
|
|
|
|
cfgOptionSet(cfgOptDbInclude, cfgSourceParam, varNewVarLst(varLstNewStrLst(includeList)));
|
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptRecoveryOption, true);
|
|
|
|
// !!! WHY DO WE STILL NEED TO CREATE THE VAR KV EMPTY?
|
|
|
|
Variant *recoveryVar = varNewKv();
|
|
|
|
KeyValue *recoveryKv = varKv(recoveryVar);
|
|
|
|
kvPut(recoveryKv, varNewStr(strNew("standby_mode")), varNewStr(strNew("on")));
|
|
|
|
kvPut(recoveryKv, varNewStr(strNew("primary_conn_info")), varNewStr(strNew("blah")));
|
|
|
|
cfgOptionSet(cfgOptRecoveryOption, cfgSourceParam, recoveryVar);
|
|
|
|
|
|
|
|
StringList *commandParamList = strLstNew();
|
|
|
|
strLstAdd(commandParamList, strNew("param1"));
|
|
|
|
strLstAdd(commandParamList, strNew("param2"));
|
|
|
|
cfgCommandParamSet(commandParamList);
|
|
|
|
|
|
|
|
cfgOptionValidSet(cfgOptPerlOption, true);
|
|
|
|
StringList *perlList = strLstNew();
|
|
|
|
strLstAdd(perlList, strNew("-I."));
|
|
|
|
strLstAdd(perlList, strNew("-MDevel::Cover=-silent,1"));
|
|
|
|
cfgOptionSet(cfgOptPerlOption, cfgSourceParam, varNewVarLst(varLstNewStrLst(perlList)));
|
|
|
|
|
|
|
|
TEST_RESULT_STR(
|
|
|
|
strPtr(perlOptionJson()),
|
|
|
|
"{"
|
2018-03-09 09:30:50 -05:00
|
|
|
"\"db-include\":{\"valid\":true,\"source\":\"param\",\"negate\":false,\"reset\":false,"
|
|
|
|
"\"value\":{\"db1\":true,\"db2\":true}},"
|
|
|
|
"\"perl-option\":{\"valid\":true,\"source\":\"param\",\"negate\":false,\"reset\":false,"
|
|
|
|
"\"value\":{\"-I.\":true,\"-MDevel::Cover=-silent,1\":true}},"
|
|
|
|
"\"recovery-option\":{\"valid\":true,\"source\":\"param\",\"negate\":false,\"reset\":false,"
|
|
|
|
"\"value\":{\"standby_mode\":\"on\",\"primary_conn_info\":\"blah\"}}"
|
2018-02-14 09:49:01 -05:00
|
|
|
"}",
|
|
|
|
"complex options");
|
|
|
|
}
|
2018-05-18 11:57:32 -04:00
|
|
|
|
|
|
|
FUNCTION_HARNESS_RESULT_VOID();
|
2018-02-14 09:49:01 -05:00
|
|
|
}
|