Exemplo n.º 1
0
    def copy_es_data(self, elasticsearch):
        """
        Copy data from Internal ES (if exists) to the main ES

        Args:
            elasticsearch (obj): elasticsearch object (if exits)

        Returns:
            bool: True if data was copy to the main ES False otherwise

        """
        if elasticsearch:
            log.info("Copy all data from Internal ES to Main ES")
            log.info("Dumping data from the Internal ES to tar ball file")
            elasticsearch.dumping_all_data(self.full_log_path)
            es_connection = self.backup_es
            es_connection["host"] = es_connection.pop("server")
            es_connection.pop("url")
            if elasticsearch_load(self.main_es, self.full_log_path):
                # Adding this sleep between the copy and the analyzing of the results
                # since sometimes the results of the read (just after write) are empty
                time.sleep(10)
                return True
            else:
                log.warning("Cannot upload data into the Main ES server")
                return False
Exemplo n.º 2
0
    def test_elasticsearch(self):
        """
        This test only deploy the elasticsearch module, connect to it with and
        without credentials and teardown the environment

        Args:
            es (fixture) : fixture that deploy / teardown the elasticsearch

        """

        full_log_path = get_full_test_logs_path(cname=self)
        log.info(f"Logs file path name is : {full_log_path}")
        log.info("The ElasticSearch deployment test started.")
        if self.es.get_health():
            log.info("The Status of the elasticsearch is OK")
        else:
            log.warning("The Status of the elasticsearch is Not OK")
            log.info("Waiting another 30 sec.")
            time.sleep(30)
            if self.es.get_health():
                log.info("The Status of the elasticsearch is OK")
            else:
                log.error("The Status of the elasticsearch is Not OK ! Exiting.")

        if self.es.get_health():
            log.info("\nThe Elastic-Search server information :\n")
            log.info(f"The Elasticsearch IP is {self.es.get_ip()}")
            log.info(f"The Elasticsearch port is {self.es.get_port()}")
            log.info(f"The Password to connect is {self.es.get_password()}")

        else:
            assert False, "The Elasticsearch module is not ready !"

        log.info(f"Test UUDI is : {self.smallfile_run(self.es)}")

        assert self.es.dumping_all_data(full_log_path), "Can not Retrieve the test data"

        assert run_command(
            f"ls {full_log_path}/FullResults.tgz"
        ), "Results file did not retrieve from pod"

        try:
            main_es = Elasticsearch(
                [
                    {
                        "host": defaults.ELASTICSEARCH_DEV_IP,
                        "port": defaults.ELASTICSEARCE_PORT,
                        "url": f"http://{defaults.ELASTICSEARCH_DEV_IP}:{defaults.ELASTICSEARCE_PORT}",
                    }
                ]
            )
        except esexp.ConnectionError:
            log.warning("Cannot connect to ES server in the LocalServer")
            main_es = None
        assert elasticsearch_load(
            main_es, full_log_path
        ), "Can not load data into Main ES server"
Exemplo n.º 3
0
    def test_elasticsearch(self):
        """
        This test do the following operations:

            * deploy the elasticsearch module
            * connect to it
            * run a simple SmallFile benchmark (to verify usability)
            * dump the results to a file
            * push the results from the file to the Dev. ES.
            * teardown the environment

        """

        log.info("Test with 'Dummy' Storageclass")
        try:
            self.es = ElasticSearch(sc="dummy")
        except ElasticSearchNotDeployed:
            log.info("Raised as expected !")

        log.info("Test with 'Real' Storageclass")
        try:
            self.es = ElasticSearch()
        except ElasticSearchNotDeployed as ex:
            log.error("Raise as expected !")
            raise ex

        full_log_path = get_full_test_logs_path(cname=self)
        log.info(f"Logs file path name is : {full_log_path}")
        log.info("The ElasticSearch deployment test started.")
        if self.es.get_health():
            log.info("The Status of the elasticsearch is OK")
        else:
            log.warning("The Status of the elasticsearch is Not OK")
            log.info("Waiting another 30 sec.")
            time.sleep(30)
            if self.es.get_health():
                log.info("The Status of the elasticsearch is OK")
            else:
                log.error(
                    "The Status of the elasticsearch is Not OK ! Exiting.")

        if self.es.get_health():
            log.info("\nThe Elastic-Search server information :\n")
            log.info(f"The Elasticsearch IP is {self.es.get_ip()}")
            log.info(f"The Elasticsearch port is {self.es.get_port()}")
            log.info(f"The Password to connect is {self.es.get_password()}")

        else:
            assert False, "The Elasticsearch module is not ready !"

        log.info(f"Test UUDI is : {self.smallfile_run(self.es)}")

        assert self.es.dumping_all_data(
            full_log_path), "Can not Retrieve the test data"

        assert run_command(f"ls {full_log_path}/FullResults.tgz"
                           ), "Results file did not retrieve from pod"

        # Try to use the development ES server for testing the elasticsearch_load
        # function to push data into ES server
        try:
            main_es = Elasticsearch([{
                "host":
                defaults.ELASTICSEARCH_DEV_IP,
                "port":
                defaults.ELASTICSEARCE_PORT,
                "url":
                f"http://{defaults.ELASTICSEARCH_DEV_IP}:{defaults.ELASTICSEARCE_PORT}",
            }])
        except esexp.ConnectionError:
            log.warning("Cannot connect to ES server in the LocalServer")
            main_es = None
        assert elasticsearch_load(
            main_es, full_log_path), "Can not load data into Main ES server"