Skip to content

Commit

Permalink
[MAINTENANCE] moved tests to lambda directories (#101)
Browse files Browse the repository at this point in the history
* feat: moved tests to lambda dirs
  • Loading branch information
a-chumagin authored Jun 30, 2023
1 parent 39dabdf commit ac6b4b4
Show file tree
Hide file tree
Showing 35 changed files with 53 additions and 30 deletions.
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ build-integration-tests-img: build-lambda-img
-t "$(test)_integration_tests" .

run-integration-tests: build-integration-tests-img
cd ./tests/integration_tests/$(test) && \
docker run --env BUCKET=$(QA_BUCKET) \
--env S3_HOST=$(HOST) --env S3_PORT=$(PORT) $(test)_integration_tests

build-unit-tests-img: build-lambda-img
cd ./tests/unit_tests/$(test) && \
docker build --build-arg="IMAGE_NAME=$(test)" \
--build-arg="VERSION=$(IMAGE_VERSION)" \
build-unit-tests-img:
cd ./functions/$(test) && \
docker build --target=unit-tests \
-t $(test)_unit_tests .

run-unit-tests: build-unit-tests-img
cd ./tests/unit_tests/$(test) && \
docker run $(test)_unit_tests
14 changes: 11 additions & 3 deletions functions/allure_report/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/lambda/python:3.9
FROM public.ecr.aws/lambda/python:3.9 as base
RUN yum install -y unzip java-1.8.0-openjdk
ENV JAVA_HOME=/usr/
ADD ./requirements.txt ./requirements.txt
Expand All @@ -8,6 +8,14 @@ RUN mkdir allure && curl https://github.com/allure-framework/allure2/releases/do
&& curl https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -O -L -C -\
&& unzip awscli-exe-linux-x86_64.zip && rm awscli-exe-linux-x86_64.zip \
&& ./aws/install
COPY ./*.py ./
COPY ./*.sh ./
COPY ./allure_report/*.py ./
COPY ./allure_report/*.sh ./

FROM base as unit-tests
RUN pip install pytest==7.3.1
ENV BUCKET=test-bucket
COPY ./tests/test*.py ./
ENTRYPOINT ["pytest", "-qvs"]

FROM base as production
CMD ["make_allure_report.handler"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 20 additions & 3 deletions functions/data_test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
FROM public.ecr.aws/lambda/python:3.9
FROM public.ecr.aws/lambda/python:3.9 as base
COPY requirements.txt ./
RUN pip3 install -r requirements.txt --no-cache-dir
COPY ./*.py ./
COPY great_expectations ./great_expectations
COPY ./data_test/*.py ./
COPY ./data_test/great_expectations ./great_expectations
RUN rm -f /etc/timezone
RUN python3 -c "import tzlocal; tzlocal.get_localzone()"

FROM base as unit-tests
RUN pip install pytest==7.3.1 moto==4.1.6
ENV ENVIRONMENT=local \
REPORTS_WEB=test \
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test \
AWS_DEFAULT_REGION=us-east-1 \
REDSHIFT_DB=test \
REDSHIFT_SECRET=test \
S3_HOST=localhost \
S3_PORT=9000 \
BUCKET=test-bucket
COPY ./tests/test*.py ./
ENTRYPOINT ["pytest","-qvs"]

FROM base as production
CMD ["data_test.handler"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 19 additions & 2 deletions functions/report_push/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
FROM public.ecr.aws/lambda/python:3.9
FROM public.ecr.aws/lambda/python:3.9 as base
ADD ./requirements.txt ./requirements.txt
RUN pip3 install -r requirements.txt
COPY ./*.py ./
COPY ./report_push/*.py ./

FROM base as unit-tests
RUN pip install pytest==7.3.1 moto==4.1.6
ENV ENVIRONMENT=local \
BUCKET=test-bucket \
DYNAMODB_TABLE=test-table \
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test \
AWS_DEFAULT_REGION=us-east-1 \
SNS_BUGS_TOPIC_ARN=test-topic-arn \
JIRA_URL=https://jira.localhost \
DATAQA_JIRA_USERNAME=qauser \
DATAQA_JIRA_PASSWORD=qapassword
COPY ./tests/test*.py ./
ENTRYPOINT ["pytest", "-qvs"]

FROM base as production
CMD ["push_data_report.handler"]
File renamed without changes.
File renamed without changes.
16 changes: 0 additions & 16 deletions tests/unit_tests/report_push/Dockerfile

This file was deleted.

0 comments on commit ac6b4b4

Please sign in to comment.