def test_is_up(self): std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test', dbDirPath=self.test_dir) assert std_env.isUp() == False std_env.startEnv() assert std_env.isUp() == True std_env.stopEnv() assert std_env.isUp() == False
def test_cluster_node_timeout(self): std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test', dbDirPath=self.test_dir, clusterNodeTimeout=60000) std_env.startEnv() con = std_env.getConnection() assert (con.execute_command("CONFIG", "GET", "cluster-node-timeout"), "60000") std_env.stopEnv()
def test_get_connection_by_key(self): tagsCount = 3 std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test', dbDirPath=self.test_dir) std_env.startEnv() for i in range(tagsCount): key = 'x{%i}' % i con = std_env.getConnectionByKey(key, "set") assert (con.set(key, "1")) std_env.stopEnv()
def test_is_tls(self): std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test', dbDirPath=self.test_dir) std_env.startEnv() assert std_env.isTLS() == False std_env.stopEnv() if not os.path.isfile(TLS_CERT) or not os.path.isfile(TLS_KEY) or not os.path.isfile(TLS_CACERT): self.skipTest("missing required tls files") tls_std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test', dbDirPath=self.test_dir, useTLS=True, tlsCertFile=TLS_CERT, tlsKeyFile=TLS_KEY, tlsCaCertFile=TLS_CACERT) tls_std_env.startEnv() assert tls_std_env.isTLS() == True tls_std_env.stopEnv()
def test__stop_process(self): std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test', dbDirPath=self.test_dir, useSlaves=True) assert std_env.isUp() == False std_env.startEnv() assert std_env._isAlive(std_env.masterProcess) == True assert std_env._isAlive(std_env.slaveProcess) == True std_env.stopEnv() assert std_env._isAlive(std_env.masterProcess) == False assert std_env._isAlive(std_env.slaveProcess) == False std_env = StandardEnv(redisBinaryPath=REDIS_BINARY, outputFilesFormat='%s-test', dbDirPath=self.test_dir, useSlaves=True) assert std_env.isUp() == False std_env.startEnv() assert std_env._isAlive(std_env.masterProcess) == True assert std_env._isAlive(std_env.slaveProcess) == True assert std_env.isUp() == True assert std_env.isHealthy() == True std_env.stopEnv(masters=True, slaves=False) assert std_env._isAlive(std_env.masterProcess) == False assert std_env._isAlive(std_env.slaveProcess) == True assert std_env.isUp() == True assert std_env.isHealthy() == False std_env.stopEnv(slaves=True) assert std_env._isAlive(std_env.masterProcess) == False assert std_env._isAlive(std_env.slaveProcess) == False assert std_env.isUp() == False assert std_env.isHealthy() == False