Esempio n. 1
0
    def test_host_is_list(self):
        """Function:  test_host_is_list

        Description:  Test to see if host is a list.

        Arguments:

        """

        els = elastic_class.ElasticSearch(self.cfg.host)

        self.assertTrue(els.hosts == self.cfg.host)
Esempio n. 2
0
    def test_ping_success(self):
        """Function:  test_ping_success

        Description:  Test to if ping is successful.

        Arguments:

        """

        els = elastic_class.ElasticSearch(self.cfg.host)

        self.assertTrue(els.cluster_name)
Esempio n. 3
0
    def test_init(self):
        """Function:  test_init

        Description:  Test to see if class instance is created.

        Arguments:

        """

        host_list = ["Host_Name"]

        with gen_libs.no_std_out():
            els = elastic_class.ElasticSearch(host_list)

        self.assertTrue(els.hosts == host_list)
Esempio n. 4
0
    def test_ping_false(self, mock_es):

        """Function:  test_ping_false

        Description:  Test ping of Elasticsearch server is False.

        Arguments:

        """

        self.els.ping_status = False
        mock_es.return_value = self.els

        els = elastic_class.ElasticSearch(self.host_list)
        self.assertEqual((els.port, els.hosts, els.is_connected, els.data,
                          els.logs),
                         (9200, self.host_list, False, {}, {}))
Esempio n. 5
0
    def test_host_list(self, mock_es, mock_nodes, mock_info, mock_health,
                       mock_master, mock_cluster):

        """Function:  test_host_list

        Description:  Test host_list is a list.

        Arguments:

        """

        mock_es.return_value = self.els
        mock_nodes.return_value = self.nodes_data
        mock_info.return_value = self.info_data
        mock_health.return_value = self.health_data
        mock_master.return_value = self.master_name
        mock_cluster.return_value = self.cluster_data

        els = elastic_class.ElasticSearch(self.host_list)
        self.assertEqual((els.port, els.hosts), (9200, self.host_list))
Esempio n. 6
0
    def test_ping_true(self, mock_es, mock_nodes, mock_info, mock_health,
                       mock_master, mock_cluster):
        """Function:  test_ping_true

        Description:  Test ping of Elasticsearch server is True.

        Arguments:

        """

        mock_es.return_value = self.els
        mock_nodes.return_value = self.nodes_data
        mock_info.return_value = self.info_data
        mock_health.return_value = self.health_data
        mock_master.return_value = self.master_name
        mock_cluster.return_value = self.cluster_data

        els = elastic_class.ElasticSearch(self.host_list)
        els.update_status()
        self.assertEqual(
            (els.port, els.hosts, els.is_connected, els.data, els.logs),
            (9200, self.host_list, True, self.data_results, self.logs_results))