Exemplo n.º 1
0
 def test_cluster_size_3(self):
     cluster = self._make_one(size=3)
     cluster.start()
     self.assertEqual(len(cluster), 3)
     self.assertEqual(len(cluster.hosts), 3)
     self.assertEqual(len(os.listdir(cluster.working_path)), 3)
     self.assertEqual(len(cluster.urls), 3)
     client = ElasticSearch(cluster.urls, max_retries=2)
     self.assertEqual(client.health()['number_of_nodes'], 3)
     # test if routing works and data is actually distributed across nodes
     client.create_index('test_shards', settings={
         'number_of_shards': 1,
         'number_of_replicas': 2,
     })
     client.index('test_shards', 'spam', {'eggs': 'bacon'})
     client.refresh('test_shards')
     shard_info = client.status()['indices']['test_shards']['shards']['0']
     nodes = set([s['routing']['node'] for s in shard_info])
     self.assertTrue(len(nodes) > 1)
Exemplo n.º 2
0
 def test_cluster_stop_twice(self):
     cluster = self._make_one()
     cluster.start()
     cluster.stop()
     cluster.stop()
Exemplo n.º 3
0
 def test_cluster_start(self):
     cluster = self._make_one()
     cluster.start()
     self.assertTrue(cluster.client is not None)
     self.assertEqual(cluster.client.health()['number_of_nodes'], 1)