Skip to content

Commit

Permalink
Makefile adaptado para Opensearch
Browse files Browse the repository at this point in the history
  • Loading branch information
tigreped committed Nov 28, 2023
1 parent c10a94a commit e91c157
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ IMAGE_NAME ?= querido-diario-api
IMAGE_TAG ?= latest
IMAGE_FORMAT ?= docker

# Elasticsearch ports
# Variables used to connect the app to the ElasticSearch
# Opensearch ports
# Variables used to connect the app to the OpenSearch
QUERIDO_DIARIO_DATABASE_CSV ?= censo.csv
ELASTICSEARCH_PORT1 ?= 9200
ELASTICSEARCH_PORT2 ?= 9300
OPENSEARCH_PORT1 ?= 9200
OPENSEARCH_PORT2 ?= 9300
# Containers data
POD_NAME ?= querido-diario-api
DATABASE_CONTAINER_NAME ?= $(POD_NAME)-db
ELASTICSEARCH_CONTAINER_NAME ?= $(POD_NAME)-elasticsearch
OPENSEARCH_CONTAINER_NAME ?= $(POD_NAME)-opensearch
# Database info user to run the tests
POSTGRES_USER ?= companies
POSTGRES_PASSWORD ?= companies
Expand All @@ -20,7 +20,7 @@ POSTGRES_HOST ?= localhost
POSTGRES_PORT ?= 5432
POSTGRES_IMAGE ?= docker.io/postgres:10
DATABASE_RESTORE_FILE ?= contrib/data/queridodiariodb.tar
# Run integration tests. Run local elasticsearch to validate the iteration
# Run integration tests. Run local opensearch to validate the iteration
RUN_INTEGRATION_TESTS ?= 0

API_PORT := 8080
Expand Down Expand Up @@ -81,9 +81,9 @@ set-test-variables:
$(eval POD_NAME=test-$(POD_NAME))
$(eval DATABASE_CONTAINER_NAME=test-$(DATABASE_CONTAINER_NAME))
$(eval API_PORT=8088)
$(eval ELASTICSEARCH_PORT1=9201)
$(eval ELASTICSEARCH_PORT2=9301)
$(eval ELASTICSEARCH_CONTAINER_NAME=test-$(ELASTICSEARCH_CONTAINER_NAME))
$(eval OPENSEARCH_PORT1=9201)
$(eval OPENSEARCH_PORT2=9301)
$(eval OPENSEARCH_CONTAINER_NAME=test-$(OPENSEARCH_CONTAINER_NAME))
$(eval QUERIDO_DIARIO_DATABASE_CSV="")

set-integration-test-variables: set-test-variables
Expand All @@ -97,14 +97,14 @@ retest: set-test-variables black
$(call run-command, python -m unittest discover tests)

.PHONY: test-all
test-all: set-integration-test-variables create-pod elasticsearch database retest
test-all: set-integration-test-variables create-pod opensearch database retest

.PHONY: test-shell
test-shell: set-test-variables
$(call run-command, bash)

.PHONY: coverage
coverage: set-test-variables create-pod elasticsearch database
coverage: set-test-variables create-pod opensearch database
$(call run-command, coverage erase)
$(call run-command, coverage run -m unittest tests)
$(call run-command, coverage report -m)
Expand Down Expand Up @@ -133,19 +133,19 @@ runshell:
$(call run-command, bash)


elasticsearch: stop-elasticsearch start-elasticsearch wait-elasticsearch
opensearch: stop-opensearch start-opensearch wait-opensearch

start-elasticsearch:
start-opensearch:
podman run -d --rm -ti \
--name $(ELASTICSEARCH_CONTAINER_NAME) \
--name $(OPENSEARCH_CONTAINER_NAME) \
--pod $(POD_NAME) \
--env discovery.type=single-node \
elasticsearch:7.9.1
opensearch:2.9.0

stop-elasticsearch:
podman rm --force --ignore $(ELASTICSEARCH_CONTAINER_NAME)
stop-opensearch:
podman rm --force --ignore $(OPENSEARCH_CONTAINER_NAME)

wait-elasticsearch:
wait-opensearch:
$(call wait-for, localhost:9200)

.PHONY: stop-database
Expand Down

0 comments on commit e91c157

Please sign in to comment.