summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:47 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:30:47 -0400
commit7e85254903c7c0cb49e381f16b18441ea7b058cc (patch)
treeb22328fcf4c8408fc25a7acb73d1cb1089cd82ac /vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
parent1de335ad3f395ca6861085393ba366a9e3fb4a0d (diff)
parent1a365e77dfb8825136626202b1df462731b42060 (diff)
Merge commit '1a365e'
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php')
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
new file mode 100644
index 00000000..d70825d1
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
@@ -0,0 +1,84 @@
+<?php
+
+namespace Elastica\Test;
+
+use Elastica\Client;
+use Elastica\Node;
+use Elastica\Test\Base as BaseTest;
+
+class NodeTest extends BaseTest
+{
+
+ public function testCreateNode()
+ {
+ $client = $this->_getClient();
+ $names = $client->getCluster()->getNodeNames();
+ $name = reset($names);
+
+ $node = new Node($name, $client);
+ $this->assertInstanceOf('Elastica\Node', $node);
+ }
+
+ public function testGetInfo()
+ {
+ $client = $this->_getClient();
+ $names = $client->getCluster()->getNodeNames();
+ $name = reset($names);
+
+ $node = new Node($name, $client);
+
+ $info = $node->getInfo();
+
+ $this->assertInstanceOf('Elastica\Node\Info', $info);
+ }
+
+ public function testGetStats()
+ {
+ $client = $this->_getClient();
+ $names = $client->getCluster()->getNodeNames();
+ $name = reset($names);
+
+ $node = new Node($name, $client);
+
+ $stats = $node->getStats();
+
+ $this->assertInstanceOf('Elastica\Node\Stats', $stats);
+ }
+
+ /**
+ * Shuts one of two nodes down (if two available)
+ */
+ public function testShutdown()
+ {
+ $this->markTestSkipped('At least two nodes have to be running, because 1 node is shutdown');
+ $client = $this->_getClient();
+ $nodes = $client->getCluster()->getNodes();
+
+ $count = count($nodes);
+ if ($count < 2) {
+ $this->markTestSkipped('At least two nodes have to be running, because 1 node is shutdown');
+ }
+
+ // Store node info of node with port 9200 for later
+ foreach ($nodes as $key => $node) {
+ if ($node->getInfo()->getPort() == 9200) {
+ $info = $node->getInfo();
+ unset($nodes[$key]);
+ }
+ }
+
+ // Select one of the not port 9200 nodes and shut it down
+ $node = array_shift($nodes);
+ $node->shutdown('2s');
+
+ // Wait until node is shutdown
+ sleep(5);
+
+ // Use still existing node
+ $client = new Client(array('host' => $info->getIp(), 'port' => $info->getPort()));
+ $names = $client->getCluster()->getNodeNames();
+
+ // One node less ...
+ $this->assertEquals($count - 1, count($names));
+ }
+}