Skip to content

Commit

Permalink
Give the e2e tests a first go over
Browse files Browse the repository at this point in the history
  • Loading branch information
Pasarus committed Dec 4, 2024
1 parent 54a499b commit a398922
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 9 deletions.
53 changes: 47 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,35 @@ jobs:

e2e:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: fia
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
rabbit-mq:
image: "rabbitmq:3.12-management"
ports:
- "5672:5672"
- "15672:15672"
env:
RABBITMQ_USER: guest
RABBITMQ_PASSWORD: guest
steps:
- name: Checkout project
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Checkout FIA-API
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
repository: "https://github.com/fiaisis/FIA-API"
path: "fia-api"

- name: Set up python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
Expand All @@ -50,12 +76,27 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Start e2e docker compose environment
run: |
cd test
docker compose up -d
- name: Run e2e test
run: pytest -l -v --random-order --random-order-bucket=global test/test_e2e.py
cd fia-api
python -m pip install .
cd ..
- name: Start API and rundetection then run e2e test
env:
QUEUE_HOST: "rabbit-mq"
INGRESS_QUEUE_NAME: "watched-files"
EGRESS_QUEUE_NAME: "scheduled-jobs"
FIA_API_API_KEY: "shh"
FIA_API_URL: http://localhost:8000
DB_IP: "localhost:5432"
DB_USERNAME: "postgres"
DB_PASSWORD: "password"
DEV_MODE: "True"
run:
cd fia-api
uvicorn fia_api.fia_api:app &
cd ..
python rundetection/run_detection.py &
pytest -l -v --random-order --random-order-bucket=global test/test_e2e.py

- name: View logs on fail
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,5 @@ dmypy.json

# Pyre type checker
.pyre/

fia-api/
18 changes: 18 additions & 0 deletions test/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ services:
RABBITMQ_USER: guest
RABBITMQ_PASSWORD: guest

fia-api:
ports:
- "80:8000"
build:
context: ../fia-api/
dockerfile: ../fia-api/container/fia_api.D
depends_on:
db:
condition: service_healthy
environment:
FIA_API_API_KEY: "shh"
DB_IP: ""
DB_USERNAME: ""
DB_PASSWORD: ""
DEV_MODE: "True"

run-detection:
build:
context: ../
Expand All @@ -24,5 +40,7 @@ services:
QUEUE_HOST: "rabbit-mq"
INGRESS_QUEUE_NAME: "watched-files"
EGRESS_QUEUE_NAME: "scheduled-jobs"
FIA_API_API_KEY: "shh"
FIA_API_URL: http://localhost:8000
volumes:
- ../test/test_data/e2e_data:/archive
4 changes: 1 addition & 3 deletions test/rules/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import unittest
from typing import Any
from unittest.mock import patch

import pytest

Expand Down Expand Up @@ -64,8 +63,7 @@ def test_rule_factory_returns_correct_rule(rule_key, rule_value, expected_rule):
:param expected_rule: The expected rule class
:return: None
"""
with patch("rundetection.rules.mari_rules.MariStitchRule._load_mari_spec"):
assert_correct_rule(rule_key, rule_value, expected_rule)
assert_correct_rule(rule_key, rule_value, expected_rule)


def test_raises_exception_for_missing_rule_class() -> None:
Expand Down

0 comments on commit a398922

Please sign in to comment.