Skip to content

Commit d4382e6

Browse files
authored
Adding Nua e2e tests (#26)
* Adding Nua e2e tests * Test summarize * WIP * Lets activate it * Fix names * Fix env vars * Fix
1 parent 091aa31 commit d4382e6

19 files changed

+534
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: run-nua-e2e-prod
2+
run-name: Running e2e PROD NUA tests
3+
on:
4+
workflow_dispatch:
5+
branches:
6+
- main
7+
schedule:
8+
# run every at every saturdat at 12
9+
- cron: '25 4 * * 6'
10+
jobs:
11+
test:
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
# Launch NucliaDB in docker
17+
18+
- name: Setup Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.9"
22+
cache: "pip"
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install flake8 pytest
28+
pip install -r nua/requirements.txt
29+
30+
- name: Install dependencies
31+
env: # Or as an environment variable
32+
TEST_EUROPE1_STASHIFY_NUA: ${{ secrets.TEST_EUROPE1_STASHIFY_NUA }}
33+
TEST_EUROPE1_NUCLIA_NUA: ${{ secrets.TEST_EUROPE1_NUCLIA_NUA }}
34+
TEST_AWS_US_EAST_2_1_NUCLIA_NUA: ${{ secrets.TEST_AWS_US_EAST_2_1_NUCLIA_NUA }}
35+
run: |
36+
pytest nua/e2e --durations=0 --junitxml nua.xml
37+
38+
- name: Publish Test Report
39+
uses: mikepenz/action-junit-report@v4
40+
if: success() || failure() # always run even if the previous step fails
41+
with:
42+
report_paths: 'nua.xml'
43+
44+
- name: Discord notification
45+
uses: cl8dep/[email protected]
46+
if: ${{ failure() && github.ref_name == 'main' }}
47+
with:
48+
webhook: ${{ secrets.DISCORD_WEBHOOK_NUA }}
49+
message: |
50+
⚠️ tests failed @NUA
51+
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>
52+
username: 'NUA E2E'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: run-nua-e2e-stage
2+
run-name: Running e2e STAGE NUA tests
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
workflow_dispatch:
8+
branches:
9+
- main
10+
schedule:
11+
# run every at every saturdat at 12
12+
- cron: '25 4 * * *'
13+
jobs:
14+
test:
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
# Launch NucliaDB in docker
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.9"
25+
cache: "pip"
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install flake8 pytest
31+
pip install -r nua/requirements.txt
32+
33+
- name: Install dependencies
34+
env: # Or as an environment variable
35+
TEST_EUROPE1_STASHIFY_NUA: ${{ secrets.TEST_EUROPE1_STASHIFY_NUA }}
36+
37+
run: |
38+
TEST_ENV=stage pytest nua/e2e --durations=0 --junitxml nua.xml
39+
40+
- name: Publish Test Report
41+
uses: mikepenz/action-junit-report@v4
42+
if: success() || failure() # always run even if the previous step fails
43+
with:
44+
report_paths: 'nua.xml'
45+
46+
- name: Discord notification
47+
uses: cl8dep/[email protected]
48+
if: ${{ failure() && github.ref_name == 'main' }}
49+
with:
50+
webhook: ${{ secrets.DISCORD_WEBHOOK_NUA }}
51+
message: |
52+
⚠️ tests failed @NUA
53+
<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>
54+
username: 'NUA E2E'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ npm-debug.log
3838
yarn-error.log
3939
testem.log
4040
/typings
41+
.python-version
4142

4243
# System Files
4344
.DS_Store

nua.xml

Lines changed: 31 additions & 0 deletions
Large diffs are not rendered by default.

nua/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
config.sh
2+
*.pyc

nua/e2e/assets/2310.14587.pdf

468 KB
Binary file not shown.

nua/e2e/assets/simple_video.mp4

5.81 MB
Binary file not shown.
Binary file not shown.

nua/e2e/conftest.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import os
2+
import tempfile
3+
4+
import pytest
5+
6+
import nuclia
7+
from nuclia.config import reset_config_file, set_config_file
8+
from nuclia.sdk import NucliaAuth
9+
10+
import logging
11+
12+
logger = logging.getLogger("e2e")
13+
14+
15+
TOKENS = {
16+
"europe-1.stashify.cloud": os.environ.get("TEST_EUROPE1_STASHIFY_NUA"),
17+
"europe-1.nuclia.cloud": os.environ.get("TEST_EUROPE1_NUCLIA_NUA"),
18+
"aws-us-east-2-1.nuclia.cloud": os.environ.get("TEST_AWS_US_EAST_2_1_NUCLIA_NUA"),
19+
}
20+
21+
22+
@pytest.fixture(
23+
scope="function",
24+
params=[
25+
"europe-1.stashify.cloud",
26+
"europe-1.nuclia.cloud",
27+
"aws-us-east-2-1.nuclia.cloud",
28+
],
29+
)
30+
def nua_config(request):
31+
if (
32+
os.environ.get("TEST_ENV") == "stage"
33+
and "stashify.cloud" not in request.param # noqa
34+
): # noqa
35+
pytest.skip("skipped on this platform: {}")
36+
37+
nuclia.REGIONAL = f"https://{request.param}"
38+
39+
token = TOKENS.get(request.param)
40+
41+
assert token
42+
43+
with tempfile.NamedTemporaryFile() as temp_file:
44+
temp_file.write(b"{}")
45+
temp_file.flush()
46+
set_config_file(temp_file.name)
47+
nuclia_auth = NucliaAuth()
48+
client_id = nuclia_auth.nua(token)
49+
assert client_id
50+
nuclia_auth._config.set_default_nua(client_id)
51+
52+
yield
53+
reset_config_file()

0 commit comments

Comments
 (0)