Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 39 additions & 8 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,39 +52,70 @@ jobs:
# fail_on_error: true
# vale_flags: "--config=doc/.vale.ini"

tests:
name: Tests and coverage
quick-tests:
name: Quick tests and coverage
runs-on: ${{ matrix.os }}
strategy:
# max 1 job at a time running against the server to make it more robust
max-parallel: 1
matrix:
os: [windows-latest, ubuntu-latest]
python-version: ['3.7', '3.10']
cfg:
- {python-version: "3.7", toxenv: "py37"}
- {python-version: "3.10", toxenv: "py310"}
fail-fast: false

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python ${{ matrix.cfg.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: ${{ matrix.cfg.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox tox-gh-actions

- name: Test with tox
run: tox -e ${{ matrix.cfg.toxenv }}-noeval-coverage
env:
REP_TEST_URL: https://repkube-dev.westeurope.cloudapp.azure.com/rep
REP_TEST_USERNAME: repadmin
REP_TEST_PASSWORD: repadmin

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/test*.xml'
check_name: Test Report ${{ matrix.os }}:${{ matrix.cfg.python-version }}

end-to-end-tests:
name: End-to-end tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox tox-gh-actions

- name: Test with tox
# Only the tox environment specified in the tox.ini gh-actions is run
run: tox
run: tox -e py37-witheval
env:
REP_TEST_URL: https://repkube-dev.westeurope.cloudapp.azure.com/rep
REP_TEST_USERNAME: repadmin
REP_TEST_PASSWORD: repadmin

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: '**/test*.xml'
check_name: Test Report ${{ matrix.os }}:${{ matrix.python-version }}
check_name: End-to-end Test Report

docs:
name: Documentation
Expand Down
13 changes: 13 additions & 0 deletions ansys/rep/client/jms/api/project_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,19 @@ def get_fs_url(project: Project):
rest_gateways = [fs for fs in project.file_storages if fs["obj_type"] == "RestGateway"]
rest_gateways.sort(key=lambda fs: fs["priority"], reverse=True)

# Local deployments use "https://host.docker.internal:8443/rep/fs/api" as first
# FS Rest Gateway address and "https://localhost:8443/rep/fs/api/" only as second.
# host.docker.internal is only available from within Docker, causing the first ping
# further down to always fail, with a time penalty of 2 seconds. This is particularly
# annoying when running tests.
# Therefore, we try to detect such case and move the host.docker.internal entry
# to the bottom of the list.
docker_index = next(
(i for i, rg in enumerate(rest_gateways) if "host.docker.internal" in rg["url"]), None
)
if docker_index is not None:
rest_gateways.append(rest_gateways.pop(docker_index))

if not rest_gateways:
raise REPError(f"Project {project.name} (id={project.id}) has no Rest Gateway defined.")

Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ log_cli = true
log_cli_level = "INFO"
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
log_cli_date_format = "%Y-%m-%d %H:%M:%S"
markers = [
"requires_evaluator: marks tests as end-to-end requiring a running evaluator (deselect with '-m \"not requires_evaluator\"')",
]
filterwarnings = [
"ignore::urllib3.exceptions.InsecureRequestWarning",
"ignore::marshmallow.warnings.RemovedInMarshmallow4Warning",
]
5 changes: 5 additions & 0 deletions tests/auth/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ def test_auth_api_exceptions(self):
except_obj = e

self.assertEqual(except_obj.response_code, 403)

api.delete_user(new_user)
users = api.get_users()
usernames = [x.username for x in users]
self.assertNotIn(new_user.username, usernames)
2 changes: 2 additions & 0 deletions tests/jms/test_task_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import unittest

from examples.mapdl_motorbike_frame.project_setup import create_project
import pytest

from ansys.rep.client.jms import JmsApi, ProjectApi
from ansys.rep.client.jms.resource import File
Expand All @@ -21,6 +22,7 @@


class TaskFilesTest(REPTestCase):
@pytest.mark.requires_evaluator
def test_task_files_in_single_task_definition_project(self):
num_jobs = 5
client = self.client()
Expand Down
3 changes: 3 additions & 0 deletions tests/jms/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import uuid

from examples.mapdl_motorbike_frame.project_setup import create_project
import pytest

from ansys.rep.client.jms import JmsApi, ProjectApi
from ansys.rep.client.jms.resource import Job, JobDefinition, Project, TaskDefinition
Expand Down Expand Up @@ -114,6 +115,7 @@ def test_task_integration(self):
tasks = project_api.get_tasks(job_id=job.id)
self.assertEqual(tasks[0].job_id, job.id)

@pytest.mark.requires_evaluator
def test_job_sync(self):

# create base project with 1 process step and 3 design points
Expand Down Expand Up @@ -241,6 +243,7 @@ def wait_for_evaluation_of_job(self, project_api, job_id, max_eval_time):

return job

@pytest.mark.requires_evaluator
def test_sync_task_definition_snapshot(self):
# verity that the process step snapshot of an evaluated task in not modified
# on job:sync
Expand Down
10 changes: 2 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ envlist =
style,{py37,py38,py39,py310}{,-coverage},doc
skip_missing_interpreters = true

[gh-actions]
description = The tox environment to be executed in gh-actions for a given python version
python =
3.7: style,py37-coverage,doc
3.8: style,py38-coverage,doc
3.9: style,py39-coverage,doc
3.10: style,py310-coverage,doc

[testenv]
description = Checks for project unit tests and coverage (if desired)
basepython =
Expand All @@ -24,6 +16,8 @@ basepython =
passenv = REP_TEST_*
setenv =
PYTHONUNBUFFERED = yes
noeval: PYTEST_MARKERS = -m "not requires_evaluator"
witheval: PYTEST_MARKERS = -m "requires_evaluator"
coverage: PYTEST_EXTRA_ARGS = --cov=ansys.rep --cov-report=term --cov-report=xml --cov-report=html
deps =
-r{toxinidir}/requirements/requirements_tests.txt
Expand Down