Exemplo n.º 1
0
 public function testGet()
 {
     $client = new Elastica_Client();
     $names = $client->getCluster()->getNodeNames();
     $name = reset($names);
     $node = new Elastica_Node($name, $client);
     $info = new Elastica_Node_Info($node);
     $this->assertInternalType('string', $info->get('os', 'mem', 'total'));
     $this->assertInternalType('array', $info->get('os', 'mem'));
     $this->assertNull($info->get('test', 'notest', 'notexist'));
 }
Exemplo n.º 2
0
 public function testShutdown()
 {
     $this->markTestSkipped('This test shuts down the cluster which means the following tests would not work');
     $client = new Elastica_Client();
     $cluster = $client->getCluster();
     $cluster->shutdown('2s');
     sleep(5);
     try {
         $client->getStatus();
         $this->fail('Should throw exception because cluster is shut down');
     } catch (Elastica_Exception_Client $e) {
         $this->assertTrue(true);
     }
 }
Exemplo n.º 3
0
 public function testShutdown()
 {
     $client = new Elastica_Client();
     $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');
     }
     // Stores node info for later
     $info = $nodes[1]->getInfo();
     $nodes[0]->shutdown('2s');
     sleep(5);
     $client = new Elastica_Client(array('host' => $info->getIp(), 'port' => $info->getPort()));
     $names = $client->getCluster()->getNodeNames();
     // One node less ...
     $this->assertEquals($count - 1, count($names));
 }
Exemplo n.º 4
0
 public function testGetIndexNames()
 {
     $client = new Elastica_Client();
     $cluster = $client->getCluster();
     $indexName = 'elastica_test999';
     $index = $this->_createIndex($indexName);
     $index->delete();
     $cluster->refresh();
     // Checks that index does not exist
     $indexNames = $cluster->getIndexNames();
     $this->assertNotContains($index->getName(), $indexNames);
     $index = $this->_createIndex($indexName);
     $cluster->refresh();
     // Now index should exist
     $indexNames = $cluster->getIndexNames();
     $this->assertContains($index->getname(), $indexNames);
 }