+
+ def test_complete_configuration_if_less_ports_than_addresses(self, monkeypatch):
+ monkeypatch.setenv('DBAAS_SERVICE_HOST', 'service-ricplt-dbaas-tcp-cluster-0.ricplt')
+ monkeypatch.setenv('DBAAS_SERVICE_PORT', '10000')
+ monkeypatch.setenv('DBAAS_CLUSTER_ADDR_LIST', 'service-ricplt-dbaas-tcp-cluster-0.ricplt,service-ricplt-dbaas-tcp-cluster-1.ricplt')
+
+ expected_config = _Configuration.Params(db_host='service-ricplt-dbaas-tcp-cluster-0.ricplt',
+ db_ports=['10000','10000'],
+ db_sentinel_ports=[],
+ db_sentinel_master_names=[],
+ db_cluster_addrs=['service-ricplt-dbaas-tcp-cluster-0.ricplt','service-ricplt-dbaas-tcp-cluster-1.ricplt'],
+ db_type=DbBackendType.REDIS)
+ assert expected_config == _Configuration(fake_db_backend=None).get_params()
+
+ def test_complete_configuration_if_less_sentinel_ports_than_addresses(self, monkeypatch):
+ monkeypatch.setenv('DBAAS_SERVICE_HOST', 'service-ricplt-dbaas-tcp-cluster-0.ricplt')
+ monkeypatch.setenv('DBAAS_SERVICE_PORT', '10000,10001')
+ monkeypatch.setenv('DBAAS_SERVICE_SENTINEL_PORT', '11000')
+ monkeypatch.setenv('DBAAS_MASTER_NAME', 'my-master-0,my-master-1')
+ monkeypatch.setenv('DBAAS_CLUSTER_ADDR_LIST', 'service-ricplt-dbaas-tcp-cluster-0.ricplt,service-ricplt-dbaas-tcp-cluster-1.ricplt')
+
+ expected_config = _Configuration.Params(db_host='service-ricplt-dbaas-tcp-cluster-0.ricplt',
+ db_ports=['10000','10001'],
+ db_sentinel_ports=['11000','11000'],
+ db_sentinel_master_names=['my-master-0','my-master-1'],
+ db_cluster_addrs=['service-ricplt-dbaas-tcp-cluster-0.ricplt','service-ricplt-dbaas-tcp-cluster-1.ricplt'],
+ db_type=DbBackendType.REDIS)
+ assert expected_config == _Configuration(fake_db_backend=None).get_params()
+
+ def test_complete_configuration_if_less_sentinel_names_than_addresses(self, monkeypatch):
+ monkeypatch.setenv('DBAAS_SERVICE_HOST', 'service-ricplt-dbaas-tcp-cluster-0.ricplt')
+ monkeypatch.setenv('DBAAS_SERVICE_PORT', '10000,10001')
+ monkeypatch.setenv('DBAAS_SERVICE_SENTINEL_PORT', '11000,11001')
+ monkeypatch.setenv('DBAAS_MASTER_NAME', 'my-master-0')
+ monkeypatch.setenv('DBAAS_CLUSTER_ADDR_LIST', 'service-ricplt-dbaas-tcp-cluster-0.ricplt,service-ricplt-dbaas-tcp-cluster-1.ricplt')
+
+ expected_config = _Configuration.Params(db_host='service-ricplt-dbaas-tcp-cluster-0.ricplt',
+ db_ports=['10000','10001'],
+ db_sentinel_ports=['11000','11001'],
+ db_sentinel_master_names=['my-master-0','my-master-0'],
+ db_cluster_addrs=['service-ricplt-dbaas-tcp-cluster-0.ricplt','service-ricplt-dbaas-tcp-cluster-1.ricplt'],
+ db_type=DbBackendType.REDIS)
+ assert expected_config == _Configuration(fake_db_backend=None).get_params()