Skip to content

Commit

Permalink
perf: Update Python to stable v3.11 & add smoke test (#90)
Browse files Browse the repository at this point in the history
* Add smoke test to the separate directory
* Enable smoke-test on the pipeline, like the last step
  • Loading branch information
NexSabre committed Oct 25, 2022
1 parent 70f2697 commit 120707b
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 4 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: '3.11.0-rc.2'
python-version: '3.11'
cache: 'pip'
- name: Install Python dependencies (pip)
run: |
Expand Down Expand Up @@ -153,3 +153,7 @@ jobs:
export GIT_VERSION_TAG=`git describe --tags --abbrev=0`
export SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`
python check_deployment.py https://www.packethelper.com $GIT_VERSION_TAG $SHORT_SHA
- name: Run Smoke tests
run: |
pip install requests pytest
make test-smoke
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ COPY . .
RUN yarn build

# build stage (backend & package)
FROM python:3.11-rc-buster
FROM python:3.11-buster

# Install tshark/wireshark dependecies
RUN echo "wireshark-common wireshark-common/install-setuid boolean true" | debconf-set-selections
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,22 @@ format-ui:
format:
@echo "Formatting..."
python3 -m isort ph/ tests/ --profile black
python3 -m black -t py310 ph/ tests/
python3 -m black -t py311 ph/ tests/
prettier --write src/
@echo "Formatting... Done"

.PHONY: run-back
run-back:
uvicorn --port 8080 ph.main:app

.PHONY: test
test:
mkdir -p static && touch static/index.html
PYTHONPATH=${PWD} pytest
PYTHONPATH=${PWD} pytest tests/integration

.PHONY: test-smoke
test-smoke:
PYTHONPATH=${PWD} pytest tests/smoke

.PHONY: init
init:
Expand Down
File renamed without changes.
Empty file added tests/integration/__init__.py
Empty file.
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added tests/smoke/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions tests/smoke/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import os

import pytest


@pytest.fixture
def instance_uri() -> str:
return os.getenv("PACKET_HELPER_URI", "https://www.packethelper.com")


@pytest.fixture
def api_uri(instance_uri: str) -> str:
return f"{instance_uri}/api"
12 changes: 12 additions & 0 deletions tests/smoke/test_smoke_prod.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from http import HTTPStatus

import requests


def test_smoke(api_uri: str) -> None:
simple_packet = (
"00001Cffffff0000000000000800450000340001000040047cc37f0000017f00000"
"14500002000010000402f7cac7f0000017f00000100000000"
) # Ethernet / IP / IPv6 / GRE
response = requests.get(f"{api_uri}/hex/{simple_packet}")
assert response.status_code == HTTPStatus.OK

0 comments on commit 120707b

Please sign in to comment.