Skip to content

Add unit tests for L2VPN state machine transitions - #515

Merged
gretelliz merged 4 commits into
mainfrom
unit_tests
Mar 24, 2026
Merged

gretelliz merged 4 commits into
mainfrom
unit_tests

Conversation

@gretelliz

@gretelliz gretelliz commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds new unit tests to validate the current and desired behavior of the L2VPN connection state machine.

Important:
This PR does not modify any production code in sdx-controller (no changes to sdx_datamodel.connection_sm, connection_handler.py, or any other module).
It only introduces new test cases in the new file test_connection_state_machine.py to document and verify the state machine behavior.

These tests are intended to:

  • Serve as living documentation of the expected transitions
  • Help detect regressions if/when the state machine is updated
  • Highlight gaps between current implementation and requirements (via xfailed tests)

This PR closes atlanticwave-sdx/datamodel#199
(and builds upon the context from atlanticwave-sdx/datamodel#184).

What the tests verify

The new tests cover the following specific requirements:

  1. DOWN → MODIFYING (via MODIFY action)
  2. DOWN → DELETED (via DELETE action)
  3. ERROR → MODIFYING (via MODIFY action)
  4. DISABLED → DELETED (via DELETE action)
  5. MODIFYING → DELETED (via DELETE action)
  6. Existence of the new MAINTENANCE state (test_maintenance_state_exists)
  7. UP → MAINTENANCE (via MW_START action)
  8. MAINTENANCE → UP (via MW_END action)

Current test results (as of this PR)

  • 7 passed
  • 2 xfailed (UP → MAINTENANCE and MAINTENANCE → UP)

Reason for the two xfailed tests:
The current connection_state_machine() implementation does not raise ConnectionSMException for these transitions.
The xfailed status serves as a marker that these transitions still need proper implementation / validation in a future PR.

Related issues

@coveralls

coveralls commented Feb 4, 2026 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 23260118717

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 53.876%

Totals Coverage Status
Change from base Build 22150611686: 0.0%
Covered Lines: 1265
Relevant Lines: 2348

💛 - Coveralls

@gretelliz
gretelliz requested a review from italovalcy February 4, 2026 00:28
@lmarinve
lmarinve requested review from YufengXin and removed request for italovalcy February 4, 2026 18:16
@YufengXin

Copy link
Copy Markdown
Collaborator

@gretelliz This looks good. But I am not sure about the two xfail's:
2 xfailed (UP → MAINTENANCE and MAINTENANCE → UP)
In datamodel, they're allowed and should succeed.

@YufengXin YufengXin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the two xfail cases related to the 'maintenence' pass?

@gretelliz

Copy link
Copy Markdown
Contributor Author

Hi @YufengXin,

Thanks for reviewing the PR!
The two xfail tests (UP → MAINTENANCE and MAINTENANCE → UP) are still failing.
I left them as xfail on purpose because according to the datamodel those transitions should be allowed, but the current state machine implementation in the controller doesn't seem to be handling them correctly yet.
They serve as documentation of the gap we need to close later.

@gretelliz
gretelliz merged commit 103aa31 into main Mar 24, 2026
4 checks passed
@gretelliz
gretelliz deleted the unit_tests branch March 24, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create a basic test for issue 184 on sdx controller

4 participants