-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
chore: add testing and linting to neutron driver plugin
- Loading branch information
Showing
8 changed files
with
2,604 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,13 @@ on: | |
- main | ||
paths: | ||
- "python/ironic-understack/**" | ||
- "python/neutron-understack/**" | ||
- "python/understack-workflows/**" | ||
- ".github/workflows/code-test.yaml" | ||
pull_request_target: | ||
paths: | ||
- "python/ironic-understack/**" | ||
- "python/neutron-understack/**" | ||
- "python/understack-workflows/**" | ||
- ".github/workflows/code-test.yaml" | ||
workflow_dispatch: | ||
|
@@ -51,3 +53,24 @@ jobs: | |
with: | ||
coverageFile: python/${{ matrix.project }}/coverage.xml | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
neutron-understack: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./python/neutron-understack | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: pipx install poetry==1.7.1 && poetry self add 'poetry-dynamic-versioning[plugin]' | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version-file: python/neutron-understack/pyproject.toml | ||
cache: "poetry" | ||
- run: poetry install --sync --with test | ||
- run: poetry build | ||
- run: "poetry run pytest --cov-report xml:coverage.xml" | ||
- uses: orgoro/[email protected] | ||
with: | ||
coverageFile: python/ironic-understack/coverage.xml | ||
token: ${{ secrets.GITHUB_TOKEN }} |
13 changes: 10 additions & 3 deletions
13
python/neutron-understack/neutron_understack/argo/workflows.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 20 additions & 22 deletions
42
python/neutron-understack/neutron_understack/tests/test_neutron_understack_mech.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,35 @@ | ||
from dataclasses import dataclass | ||
from unittest.mock import patch, MagicMock | ||
from unittest.mock import MagicMock | ||
|
||
import pytest | ||
from neutron_understack.argo.workflows import ArgoClient | ||
|
||
from neutron_understack.neutron_understack_mech import UnderstackDriver | ||
from neutron_understack.argo.workflows import ArgoClient | ||
|
||
# TODO: I am not sure how we run tests in this project. | ||
|
||
@dataclass | ||
class ContextDouble: | ||
current: dict | ||
@pytest.fixture | ||
def argo_client() -> ArgoClient: | ||
return MagicMock(spec_set=ArgoClient) | ||
|
||
def mock_context_data(file): | ||
ref = pathlib.Path(__file__).joinpath(filename) | ||
with ref.open("r") as f: | ||
return ContextDouble(json.load(f)) | ||
|
||
@patch('neutron_understack.argo.workflows.ArgoClient') | ||
def test_update_port_postcommit(mock_argo_client): | ||
context_data = mock_context_data( | ||
"fixtures/neutron_update_port_postcommit.json" | ||
def test_move_to_network__provisioning(argo_client): | ||
driver = UnderstackDriver() | ||
driver._move_to_network( | ||
vif_type="other", | ||
mac_address="fa:16:3e:35:1c:3d", | ||
device_uuid="41d18c6a-5548-4ee9-926f-4e3ebf43153f", | ||
network_id="c2702769-5592-4555-8ae6-e670db82c31e", | ||
argo_client=argo_client, | ||
) | ||
|
||
UnderstackDriver.update_port_postcommit(context_data) | ||
|
||
mock_argo_client.assert_called_once_with( | ||
argo_client.submit.assert_called_once_with( | ||
template_name="undersync-device", | ||
entrypoint="trigger-undersync", | ||
parameters={ | ||
"interface_uuid": "e5d5cd73-ca9a-4b74-9d52-43188d0cdcaa", | ||
"interface_mac": "fa:16:3e:35:1c:3d", | ||
"device_uuid": "41d18c6a-5548-4ee9-926f-4e3ebf43153f", | ||
"network_name": "provisioning", | ||
"dry_run": false, | ||
"force": false, | ||
"network_name": "tenant", | ||
"dry_run": True, | ||
"force": False, | ||
}, | ||
service_account="workflow", | ||
) |
Oops, something went wrong.