Skip to content

Commit

Permalink
add support for Elasticsearch 8, default to running that for local te…
Browse files Browse the repository at this point in the history
…sts, and test both 7 and 8 in CI (#50)

* update client headers to support Elasticsearch 8.x
  • Loading branch information
Phil Varner authored Mar 15, 2022
1 parent 053f130 commit d3acbae
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 17 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
- package-ecosystem: pip
directory: "/.github/workflows"
schedule:
interval: daily
- package-ecosystem: pip
directory: "/stac_fastapi/elasticsearch"
schedule:
interval: daily
34 changes: 28 additions & 6 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:

services:

elasticsearch_db_service:
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
elasticsearch_7_svc:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.1
env:
node.name: es01
cluster.name: stac-cluster
Expand All @@ -23,7 +23,19 @@ jobs:
ES_JAVA_OPTS: -Xms512m -Xmx512m
ports:
- 9200:9200


# elasticsearch_8_svc:
# image: docker.elastic.co/elasticsearch/elasticsearch:8.1.0
# env:
# node.name: es01
# cluster.name: stac-cluster
# discovery.type: single-node
# network.host: 0.0.0.0
# http.port: 9200
# ES_JAVA_OPTS: -Xms512m -Xmx512m
# ports:
# - 9200:9200

steps:
- name: Check out repository code
uses: actions/checkout@v2
Expand All @@ -44,13 +56,23 @@ jobs:
- name: Install elasticsearch stac-fastapi
run: |
pip install ./stac_fastapi/elasticsearch[dev,server]
- name: Run test suite
- name: Run test suite against Elasticsearch 7.x
run: |
cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
env:
ENVIRONMENT: testing
ES_USER: dev
ES_PASS: stac
ES_PORT: 9200
ES_HOST: 172.17.0.1
ES_HOST: 172.17.0.1
#
# - name: Run test suite against Elasticsearch 8.x
# run: |
# cd stac_fastapi/elasticsearch && pipenv run pytest -svvv
# env:
# ENVIRONMENT: testing
# ES_USER: dev
# ES_PASS: stac
# ES_PORT: 9400
# ES_HOST: 172.17.0.1
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Added

- Support for Elasticsearch 7.x or 8.x

### Fixed

### Changed
Expand All @@ -19,4 +21,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Removed


[Unreleased]: <https://github.com/stac-utils/stac-fastapi-elasticsearch/tree/main>
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ docker-shell:
.PHONY: test
test:
$(run_es) /bin/bash -c 'export && ./scripts/wait-for-it-es.sh elasticsearch:9200 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest'
docker-compose down

.PHONY: run-database
run-database:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ docker-compose build
docker-compose up
```

By default, docker-compose uses Elasticsearch 7.x. If you wish to use a different version, put the following in a
file named `.env` in the same directory you run docker-compose from:

```shell
ELASTICSEARCH_VERSION=7.12.0
```

TBD: how to run this with 8.x with a password enabled and TLS.

To create a new Collection:

```shell
Expand Down
8 changes: 2 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ services:

elasticsearch:
container_name: es-container
image: docker.elastic.co/elasticsearch/elasticsearch:7.14.2
image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.17.1}
environment:
node.name: es01
cluster.name: stac-cluster
Expand All @@ -41,8 +41,4 @@ services:
http.port: 9200
ES_JAVA_OPTS: -Xms512m -Xmx512m
ports:
- 9200:9200

networks:
default:
name: stac-fastapi-es-network
- "9200:9200"
4 changes: 2 additions & 2 deletions stac_fastapi/elasticsearch/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"stac-fastapi.api==2.3.0",
"stac-fastapi.extensions==2.3.0",
"fastapi-utils",
"elasticsearch[async]",
"elasticsearch-dsl",
"elasticsearch[async]==7.17.1",
"elasticsearch-dsl==7.4.0",
"pystac[validation]",
"uvicorn",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ElasticsearchSettings(ApiSettings):
@property
def create_client(self):
"""Create es client."""
# try:
client = Elasticsearch([{"host": str(DOMAIN), "port": str(PORT)}])
return client
return Elasticsearch(
[{"host": str(DOMAIN), "port": str(PORT)}],
headers={"accept": "application/vnd.elasticsearch+json; compatible-with=7"},
)

0 comments on commit d3acbae

Please sign in to comment.