/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->roma_client = RomaClient::getInstance(array("localhost_11211", "localhost_11212")); $ret = $this->roma_client->alist_sized_insert("alist-key", 3, "aaa"); $ret = $this->roma_client->alist_sized_insert("alist-key", 3, "bbb"); $ret = $this->roma_client->alist_sized_insert("alist-key", 3, "ccc"); }
/** * get roma-client instance. * @param hosts - ["127.0.0.1:11211", "127.0.0.1:11212"] | * ["-d", "127.0.0.1:12345"] */ public static function getInstance($hosts) { $hosts_string = ""; foreach ($hosts as &$value) { $hosts_string = $hosts_string . "," . $value; } $hosts_string = substr(0, strlen($hosts_string), $hosts_string); RomaClient::$romaclient = new RomaClient($hosts_string); return RomaClient::$romaclient; }
/** * No.1 * No. */ public function testConfMiss() { print "\n***TEST*** " . get_class($this) . "::" . __FUNCTION__ . "\n"; exec($this->server_script_path . ' starts'); sleep(15); $roma_client = RomaClient::getInstance(array("-d", "localhost_11211", "localhost_11212")); for ($i = 0; $i < 100; $i++) { $ret = $roma_client->set("test-conf-miss-" . $i, "test-conf-miss-" . $i, 1000); } exec($this->server_script_path . ' stops'); $this->assertTrue($ret); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { //rmc_log(0,0); $this->roma_client = RomaClient::getInstance(array("localhost_11211", "localhost_11212", "localhost_11213", "localhost_11214")); //$ret = $this->roma_client->alist_sized_insert("alist-key", 3,"aaa"); //$ret = $this->roma_client->alist_sized_insert("alist-key", 3,"bbb"); //$ret = $this->roma_client->alist_sized_insert("alist-key", 3,"ccc"); $val_10b = "0123456789"; for ($i = 0; $i < 10000; $i++) { $this->val_100kb .= $val_10b; } }
/** * No.3 * No. */ public function testNode2Stop() { print "\n***TEST*** " . get_class($this) . "::" . __FUNCTION__ . "\n"; exec($this->server_script_path . ' starts'); sleep(15); exec($this->server_script_path . ' stop2'); sleep(20); $roma_client = RomaClient::getInstance(array("localhost_11211", "localhost_11212")); $roma_client->set("test-node2-stop", "test-node2-stop", 1000); $val = $roma_client->get("test-node2-stop"); exec($this->server_script_path . ' stops'); $this->assertEquals("test-node2-stop", $val); }
/** * get roma-client instance. * * @param hosts (array) */ public static function getInstance($hosts) { $hosts_string = ""; foreach ($hosts as &$value) { $hosts_string .= $value . ","; } $hosts_string = substr($hosts_string, 0, strlen($hosts_string) - 1); //echo $hosts_string, "<br/>"; $result = rmc_connect($hosts_string); if ($result == 1) { return False; } RomaClient::$romaclient = new RomaClient(); return RomaClient::$romaclient; }
/** * No.59 * No. */ public function testRomaStartConnect() { print "\n***TEST*** " . get_class($this) . "::" . __FUNCTION__ . "\n"; $flg = False; for ($i = 0; $i < 50000; $i++) { print '.'; if ($i == 10) { exec($this->server_script_path . ' starts'); } $roma_client = RomaClient::getInstance(array("localhost_11211", "localhost_11212")); if ($roma_client != False) { break; } } sleep(20); $this->assertInstanceOf(RomaClient, $roma_client); }
/** * No.56 * No. */ public function testRomaStopAlistClear() { print "\n***TEST*** " . get_class($this) . "::" . __FUNCTION__ . "\n"; exec($this->server_script_path . ' starts'); sleep(30); $flg = True; $roma_client = RomaClient::getInstance(array("localhost_11211", "localhost_11212")); for ($i = 0; $i < 100; $i++) { if ($i == 50) { exec($this->server_script_path . ' stops'); } try { $roma_client->alist_clear("test-join-alist"); } catch (Exception $e) { $flg = False; break; } } exec($this->server_script_path . ' stops'); $this->assertFalse($flg); }
/** * No.50, 51 * No. */ public function testRomaStopCasCasUnique() { print "\n***TEST*** " . get_class($this) . "::" . __FUNCTION__ . "\n"; exec($this->server_script_path . ' starts'); sleep(30); $flg = True; $roma_client = RomaClient::getInstance(array("localhost_11211", "localhost_11212")); $roma_client->set("test-join-cas", "test-join-cas", 100); for ($i = 0; $i < 10000; $i++) { if ($i == 5000) { exec($this->server_script_path . ' stops'); } try { $val = $roma_client->cas_unique("test-join-cas"); $roma_client->cas("test-join-cas", "test-join-cas" . $i, $val[0], 100); } catch (Exception $e) { $flg = False; break; } } exec($this->server_script_path . ' stops'); $this->assertFalse($flg); }
/** * No.39 * No. */ public function testJoinAlistUpdateAt() { print "\n***TEST*** " . get_class($this) . "::" . __FUNCTION__ . "\n"; $cnt = 0; $this->roma_client = RomaClient::getInstance(array("localhost_11211", "localhost_11212", "localhost_11213")); $this->roma_client->alist_sized_insert("test-join-alist", 100, "test-join-alist"); for ($i = 0; $i < 100; $i++) { try { $this->roma_client->alist_update_at("test-join-alist", 0, "test-join-alist" . $i); } catch (Exception $e) { $cnt++; } } $this->assertLessThanOrEqual(0, $cnt); }
/** * No.40 * No. */ public function testRomaStop() { print "\n***TEST*** " . get_class($this) . "::" . __FUNCTION__ . "\n"; $roma_client = RomaClient::getInstance(array("localhost_11211", "localhost_11212")); $this->assertFalse($roma_client); }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->roma_client = RomaClient::getInstance($this->nodes); }
<?php require "RomaClient.php"; $OK = "OK<br/>"; $NG = "NG<br/>"; $hosts = array('192.168.0.1_11211', '192.168.0.1_11212'); $romaclient = RomaClient::getInstance($hosts); //$romaclient = RomaClient::getInstance("-d,192.168.0.1_12345"); $not_key_1 = $romaclient->get("not_exist_key_001"); echo "not_exist_key_001 <br/>"; $not_key_2 = $romaclient->get("not_exist_key_002"); echo "not_exist_key_002<br/>"; $not_key_3 = $romaclient->get("not_exist_key_003"); echo "not_exist_key_003<br/>"; if (is_null($not_key_1)) { echo "not_exist_key_001 is null<br/>"; } if (is_null($not_key_2)) { echo "not_exist_key_002 is null<br/>"; } if (is_null($not_key_3)) { echo "not_exist_key_003 is null<br/>"; } echo "=== check point 001 === <br/>"; $key01 = "key-test-001"; $key02 = "key-test-002"; $key03 = "key-test-003"; $key04 = "key-test-004"; $key05 = "key-test-005"; $key06 = "key-test-006"; $key07 = "key-test-007";
require_once "RomaClient.php"; $no_conn = RomaClient::getInstance(array("-d", "localhost_12345")); if (!$no_conn) { print "NO-CONN FALSE\n"; } $without_route = RomaClient::getInstance(array("-d", "localhost_11211", "localhost_11212")); if ($without_route) { $without_route->set_default_timeout(10000); $res = $without_route->set("rc", "*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*", 100); for ($i = 0; $i < 10; $i++) { $val = $without_route->get("rc"); print "V:{$val}\n"; } } $use_route = RomaClient::getInstance(array("localhost_11211")); if ($use_route) { $use_route->set("rc2", "**************************************", 100); for ($i = 0; $i < 10; $i++) { $v2 = $use_route->get("rc2"); print "V:{$v2}\n"; } $use_route->alist_sized_insert("rc3", 10, "aaaa"); $use_route->alist_sized_insert("rc3", 10, "bbbb"); $use_route->alist_sized_insert("rc3", 10, "cccc"); $use_route->alist_sized_insert("rc3", 10, "dddd"); $ls = $use_route->alist_join("rc3", "-"); foreach ($ls as &$l) { print "{$l}\n"; } // EXP