Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eda3995

Browse files
committed
Cluster nodes from ENV
1 parent 3eb60f5 commit eda3995

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/RedisClusterTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* where we're validating specific cluster mechanisms
88
*/
99
class Redis_Cluster_Test extends Redis_Test {
10-
private static $_arr_node_map = [];
11-
1210
private $_arr_redis_types = [
1311
Redis::REDIS_STRING,
1412
Redis::REDIS_SET,
@@ -23,6 +21,7 @@ class Redis_Cluster_Test extends Redis_Test {
2321
RedisCluster::FAILOVER_DISTRIBUTE
2422
];
2523

24+
protected static $_arr_node_map = [];
2625
/**
2726
* @var string
2827
*/
@@ -74,15 +73,16 @@ public function testSession_lockWaitTime() { return $this->markTestSkipped(); }
7473
public function __construct($str_host, $i_port, $str_auth) {
7574
parent::__construct($str_host, $i_port, $str_auth);
7675

77-
$str_nodemap_file = dirname($_SERVER['PHP_SELF']) . '/nodes/nodemap';
78-
79-
if (!file_exists($str_nodemap_file)) {
80-
fprintf(STDERR, "Error: Can't find nodemap file for seeds!\n");
81-
exit(1);
82-
}
83-
76+
self::$_arr_node_map = preg_split('/\s+/', getenv('REDIS_CLUSTER_NODES'));
8477
/* Store our node map */
8578
if (!self::$_arr_node_map) {
79+
$str_nodemap_file = dirname($_SERVER['PHP_SELF']) . '/nodes/nodemap';
80+
81+
if (!file_exists($str_nodemap_file)) {
82+
fprintf(STDERR, "Error: Can't find nodemap file for seeds!\n");
83+
exit(1);
84+
}
85+
8686
self::$_arr_node_map = array_filter(
8787
explode("\n", file_get_contents($str_nodemap_file)
8888
));

0 commit comments

Comments
 (0)