Best Python code snippet using localstack_python
install.py
Source:install.py
...50def get_elasticsearch_install_version(version=None):51 if config.SKIP_INFRA_DOWNLOADS:52 return ELASTICSEARCH_DEFAULT_VERSION53 return version or ELASTICSEARCH_DEFAULT_VERSION54def get_elasticsearch_install_dir(version=None):55 version = get_elasticsearch_install_version(version)56 if version == ELASTICSEARCH_DEFAULT_VERSION and not os.path.exists(MARKER_FILE_LIGHT_VERSION):57 # install the default version into a subfolder of the code base58 install_dir = os.path.join(INSTALL_DIR_INFRA, 'elasticsearch')59 else:60 install_dir = os.path.join(config.TMP_FOLDER, 'elasticsearch', version)61 return install_dir62def install_elasticsearch(version=None):63 version = get_elasticsearch_install_version(version)64 install_dir = get_elasticsearch_install_dir(version)65 installed_executable = os.path.join(install_dir, 'bin', 'elasticsearch')66 if not os.path.exists(installed_executable):67 log_install_msg('Elasticsearch (%s)' % version)68 es_url = ELASTICSEARCH_URLS.get(version)69 if not es_url:70 raise Exception('Unable to find download URL for Elasticsearch version "%s"' % version)71 install_dir_parent = os.path.dirname(install_dir)72 mkdir(install_dir_parent)73 # download and extract archive74 tmp_archive = os.path.join(config.TMP_FOLDER, 'localstack.%s' % os.path.basename(es_url))75 download_and_extract_with_retry(es_url, tmp_archive, install_dir_parent)76 elasticsearch_dir = glob.glob(os.path.join(install_dir_parent, 'elasticsearch*'))77 if not elasticsearch_dir:78 raise Exception('Unable to find Elasticsearch folder in %s' % install_dir_parent)...
cluster.py
Source:cluster.py
...109 "ES_TMPDIR": self.directories.tmp,110 }111 def _resolve_directories(self) -> Directories:112 # determine various directory paths113 base_dir = install.get_elasticsearch_install_dir(self.version)114 es_tmp_dir = os.path.join(base_dir, "tmp")115 es_mods_dir = os.path.join(base_dir, "modules")116 if config.DATA_DIR:117 es_data_dir = os.path.join(config.DATA_DIR, "elasticsearch")118 else:119 es_data_dir = os.path.join(base_dir, "data")120 backup_dir = os.path.join(config.TMP_FOLDER, "es_backup")121 return Directories(base_dir, es_tmp_dir, es_mods_dir, es_data_dir, backup_dir)122 def _init_directories(self):123 dirs = self.directories124 LOG.debug("initializing elasticsearch directories %s", dirs)125 chmod_r(dirs.base, 0o777)126 if not dirs.data.startswith(config.DATA_DIR):127 # only clear previous data if it's not in DATA_DIR...
es_starter.py
Source:es_starter.py
...10LOG = logging.getLogger(__name__)11STATE = {}12def delete_all_elasticsearch_data(version):13 """ This function drops ALL data in the local Elasticsearch data folder. Use with caution! """14 base_dir = install.get_elasticsearch_install_dir(version)15 data_dir = os.path.join(base_dir, 'data', 'elasticsearch', 'nodes')16 rm_rf(data_dir)17def stop_elasticsearch():18 thread = STATE.get('_thread_')19 if not thread:20 return21 LOG.info('Terminating Elasticsearch instance, as all clusters have been removed')22 thread.stop()23 if STATE['_proxy_']:24 STATE['_proxy_'].stop()25 del STATE['_thread_']26 del STATE['_proxy_']27def start_elasticsearch(port=None, version=None, delete_data=True, asynchronous=False, update_listener=None):28 if STATE.get('_thread_'):29 return STATE['_thread_']30 port = port or config.PORT_ELASTICSEARCH31 # delete Elasticsearch data that may be cached locally from a previous test run32 delete_all_elasticsearch_data(version)33 install.install_elasticsearch(version)34 backend_port = get_free_tcp_port()35 base_dir = install.get_elasticsearch_install_dir(version)36 es_data_dir = os.path.join(base_dir, 'data')37 es_tmp_dir = os.path.join(base_dir, 'tmp')38 es_mods_dir = os.path.join(base_dir, 'modules')39 if config.DATA_DIR:40 delete_data = False41 es_data_dir = '%s/elasticsearch' % config.DATA_DIR42 # Elasticsearch 5.x cannot be bound to 0.0.0.0 in some Docker environments,43 # hence we use the default bind address 127.0.0.0 and put a proxy in front of it44 backup_dir = os.path.join(config.TMP_FOLDER, 'es_backup')45 cmd = (('%s/bin/elasticsearch ' +46 '-E http.port=%s -E http.publish_port=%s -E http.compression=false ' +47 '-E path.data=%s -E path.repo=%s') %48 (base_dir, backend_port, backend_port, es_data_dir, backup_dir))49 if os.path.exists(os.path.join(es_mods_dir, 'x-pack-ml')):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!