X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=tst%2Fconfigurationreader_test.cpp;fp=tst%2Fconfigurationreader_test.cpp;h=4e730f04eb4d7acf0ba5d3b4202ed79b82ee58c1;hb=ece67088ea6c4f67b9d0db74477a9d5c614d7763;hp=b1ed9f125d2661eedd48829dc90abd3b77d89032;hpb=aad0a0b5f51c2abd855aba0a9cb8e99ac5023600;p=ric-plt%2Fsdl.git diff --git a/tst/configurationreader_test.cpp b/tst/configurationreader_test.cpp index b1ed9f1..4e730f0 100644 --- a/tst/configurationreader_test.cpp +++ b/tst/configurationreader_test.cpp @@ -740,6 +740,7 @@ public: std::string dbPortEnvVariableValue; std::string sentinelPortEnvVariableValue; std::string sentinelMasterNameEnvVariableValue; + std::string dbClusterAddrListEnvVariableValue; std::istringstream is{R"JSON( { "database": @@ -774,8 +775,11 @@ public: try { EXPECT_CALL(systemMock, getenv(_)) - .Times(4) + .Times(5) .WillOnce(Return(dbHostEnvVariableValue.c_str())) + .WillOnce(Return(nullptr)) + .WillOnce(Return(nullptr)) + .WillOnce(Return(nullptr)) .WillOnce(Return(nullptr)); initializeReaderWithoutDirectories(); configurationReader->readDatabaseConfiguration(databaseConfigurationMock); @@ -798,6 +802,7 @@ TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationCanOv expectGetEnvironmentString(dbPortEnvVariableValue.c_str()); expectGetEnvironmentString(nullptr); //SENTINEL_PORT_ENV_VAR_NAME expectGetEnvironmentString(nullptr); //SENTINEL_MASTER_NAME_ENV_VAR_NAME + expectGetEnvironmentString(nullptr); //DB_CLUSTER_ENV_VAR_NAME expectDbTypeConfigurationCheckAndApply("redis-standalone"); expectDBServerAddressConfigurationCheckAndApply("unknownAddress.local:12345"); @@ -814,6 +819,7 @@ TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationWitho expectGetEnvironmentString(nullptr); //DB_PORT_ENV_VAR_NAME expectGetEnvironmentString(nullptr); //SENTINEL_PORT_ENV_VAR_NAME expectGetEnvironmentString(nullptr); //SENTINEL_MASTER_NAME_ENV_VAR_NAME + expectGetEnvironmentString(nullptr); //DB_CLUSTER_ENV_VAR_NAME expectDbTypeConfigurationCheckAndApply("redis-standalone"); expectDBServerAddressConfigurationCheckAndApply("server.local"); @@ -841,6 +847,7 @@ TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationAccep expectGetEnvironmentString(nullptr); //DB_PORT_ENV_VAR_NAME expectGetEnvironmentString(nullptr); //SENTINEL_PORT_ENV_VAR_NAME expectGetEnvironmentString(nullptr); //SENTINEL_MASTER_NAME_ENV_VAR_NAME + expectGetEnvironmentString(nullptr); //DB_CLUSTER_ENV_VAR_NAME expectDbTypeConfigurationCheckAndApply("redis-standalone"); expectDBServerAddressConfigurationCheckAndApply("[2001::123]:12345"); @@ -859,6 +866,7 @@ TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationWithS expectGetEnvironmentString(sentinelPortEnvVariableValue.c_str()); sentinelMasterNameEnvVariableValue = "mymaster"; expectGetEnvironmentString(sentinelMasterNameEnvVariableValue.c_str()); + expectGetEnvironmentString(nullptr); //DB_CLUSTER_ENV_VAR_NAME expectDbTypeConfigurationCheckAndApply("redis-sentinel"); expectSentinelAddressConfigurationCheckAndApply("sentinelAddress.local:2222"); @@ -866,3 +874,27 @@ TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationWithS initializeReaderWithoutDirectories(); configurationReader->readDatabaseConfiguration(databaseConfigurationMock); } + +TEST_F(ConfigurationReaderEnvironmentVariableTest, EnvironmentConfigurationWithSentinelAndClusterConfiguration) +{ + InSequence dummy; + dbHostEnvVariableValue = "address-0.local"; + expectGetEnvironmentString(dbHostEnvVariableValue.c_str()); + dbPortEnvVariableValue = "1111"; + expectGetEnvironmentString(dbPortEnvVariableValue.c_str()); + sentinelPortEnvVariableValue = "2222"; + expectGetEnvironmentString(sentinelPortEnvVariableValue.c_str()); + sentinelMasterNameEnvVariableValue = "mymaster"; + expectGetEnvironmentString(sentinelMasterNameEnvVariableValue.c_str()); + dbClusterAddrListEnvVariableValue = "address-0.local,address-1.local,address-2.local"; + expectGetEnvironmentString(dbClusterAddrListEnvVariableValue.c_str()); + + expectDbTypeConfigurationCheckAndApply("sdl-cluster"); + expectDBServerAddressConfigurationCheckAndApply("address-0.local"); + expectDBServerAddressConfigurationCheckAndApply("address-1.local"); + expectDBServerAddressConfigurationCheckAndApply("address-2.local"); + expectSentinelAddressConfigurationCheckAndApply("address-0.local:2222"); + expectSentinelMasterNameConfigurationCheckAndApply(sentinelMasterNameEnvVariableValue); + initializeReaderWithoutDirectories(); + configurationReader->readDatabaseConfiguration(databaseConfigurationMock); +}