mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-12-24 21:48:52 +00:00
Start Elasticsearch with a Github Action (#142)
This commit is contained in:
parent
2e4d2e792b
commit
180dc8cbd6
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@ -13,16 +13,31 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Configure sysctl limits for Elasticsearch
|
||||
run: |
|
||||
sudo swapoff -a
|
||||
sudo sysctl -w vm.swappiness=1
|
||||
sudo sysctl -w fs.file-max=262144
|
||||
sudo sysctl -w vm.max_map_count=262144
|
||||
|
||||
- name: Run Elasticsearch
|
||||
uses: elastic/elastic-github-actions/elasticsearch@25ad91e35aeee806711d335fc9dec7927ae49bc6
|
||||
with:
|
||||
stack-version: 7.6.0
|
||||
|
||||
- name: Set up Python 3.7
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.7
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install pytest
|
||||
pip install -r requirements.txt
|
||||
pip install -e .
|
||||
|
||||
- name: Test with pytest
|
||||
run: |
|
||||
cd test && pytest
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import tarfile
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
from subprocess import Popen, PIPE, STDOUT, run
|
||||
|
||||
import pytest
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
@ -14,12 +14,17 @@ def elasticsearch_dir(tmpdir_factory):
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def elasticsearch_fixture(elasticsearch_dir):
|
||||
thetarfile = "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-linux-x86_64.tar.gz"
|
||||
ftpstream = urllib.request.urlopen(thetarfile)
|
||||
thetarfile = tarfile.open(fileobj=ftpstream, mode="r|gz")
|
||||
thetarfile.extractall(path=elasticsearch_dir)
|
||||
es_server = Popen([elasticsearch_dir / "elasticsearch-7.6.1/bin/elasticsearch"], stdout=PIPE, stderr=STDOUT)
|
||||
time.sleep(40)
|
||||
# test if a ES cluster is already running. If not, download and start an ES instance locally.
|
||||
try:
|
||||
client = Elasticsearch(hosts=[{"host": "localhost"}])
|
||||
client.info()
|
||||
except:
|
||||
thetarfile = "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.1-linux-x86_64.tar.gz"
|
||||
ftpstream = urllib.request.urlopen(thetarfile)
|
||||
thetarfile = tarfile.open(fileobj=ftpstream, mode="r|gz")
|
||||
thetarfile.extractall(path=elasticsearch_dir)
|
||||
es_server = Popen([elasticsearch_dir / "elasticsearch-7.6.1/bin/elasticsearch"], stdout=PIPE, stderr=STDOUT)
|
||||
time.sleep(40)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user