Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use connection request v2 spec #297

Merged
merged 17 commits into from
Jul 10, 2024
Merged

Conversation

sajith
Copy link
Member

@sajith sajith commented Jul 2, 2024

Resolves #296. Work in progress, not quite there yet, etc. Updates in comments below.

@sajith
Copy link
Member Author

sajith commented Jul 2, 2024

The POST /connection controller must be able to receive the new connection requests in order to generate connection IDs. But validation of the request body happens before it hits the controller method, so in order to accept v2 format connection requests, the OpenAPI/Swagger definition must change. That might break a few things.

It is not quite clear to me if we should maintain backward compatibility with the original connection request format. If we want to maintain backward compatibility at least for a while, we will probably have to add a new endpoint to handle connection requests in v2 format?

@YufengXin
Copy link
Collaborator

@sajith adding a new /connection/v2 endpoint is probably a good idea, so no need to overhaul all the unittests for the time being? in the swagger.yaml in sdx_lc, I've added the new request connection scheme there.

@sajith
Copy link
Member Author

sajith commented Jul 3, 2024

@YufengXin A simpler solution might be to use oneOf, like so:

  /connection:
    post:
      operationId: place_connection
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/connection'
                - $ref: '#/components/schemas/connection_v2'
        required: true

Now I need to figure out how to write a connection_v2 schema. I tried converting Connection.json to YAML (using an online tool) and using that in the OpenAPI spec, but that does not pass connexion's validator.

See these commits on sdx-lc:

- 128c3445010310a3159c6c1b69e789ac6524d572
- f5a5f576b32d930a34628266d944fb7943057462
- 51f3a5349db2a7d3ed41d54f8d5466116b4bea10
- ab2f6f7df7e591735afd4c388c5a6de238f96ed4
- 22622d1cebb96f263fd8d41a9d27ba9a3479cfbe
- 9c5963a9b9985a95b771b5f3cbeab9053bec8d76

(On branch 152-update-the-schema-on-connection-request-spec, PR:
atlanticwave-sdx/sdx-lc#156)
When we use `oneOf` in request body schemas, the error message has
less detail than it previously had.
Seems that we get two items in the response now, after adding another
test with a different ID. Probably should investigate this further
later.
@coveralls
Copy link

coveralls commented Jul 3, 2024

Pull Request Test Coverage Report for Build 9783166269

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 52.322%

Totals Coverage Status
Change from base Build 9586048784: 0.0%
Covered Lines: 758
Relevant Lines: 1473

💛 - Coveralls

@coveralls
Copy link

coveralls commented Jul 3, 2024

Pull Request Test Coverage Report for Build 9785415149

Details

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 52.486%

Totals Coverage Status
Change from base Build 9586048784: 0.2%
Covered Lines: 763
Relevant Lines: 1478

💛 - Coveralls

@sajith
Copy link
Member Author

sajith commented Jul 3, 2024

@YufengXin @congwang09 I'm keeping this in draft state since this uses code that is not in the main branches of pce and datamodel, but please take a look when you get a chance.

The example connection request does not find a path. However we do generate a connection ID when it is not present (as in the case of v2 connection requests), and send a response like below, and a non-200 response code:

{
  "connection_id": "7e84c036-cc65-4257-9049-9b70992e8057",
  "reason": "Could not generate a traffic matrix",
  "status": "Failure"
}

@YufengXin
Copy link
Collaborator

The modification looks good to me -:)

For the unittest, in the draft PR in PCE,the test I added is this one:

https://github.com/atlanticwave-sdx/pce/blob/052788738691de677786b4c1bc496bafcb4a9043/tests/test_te_manager.py#L947

that uses this request connection in v2 format:

tests/data/test_request-amlight_zaoxi-p2p-v2.json

which finds the path on the three-topology

@coveralls
Copy link

coveralls commented Jul 4, 2024

Pull Request Test Coverage Report for Build 9788498633

Details

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 52.486%

Totals Coverage Status
Change from base Build 9586048784: 0.2%
Covered Lines: 763
Relevant Lines: 1478

💛 - Coveralls

@sajith
Copy link
Member Author

sajith commented Jul 4, 2024

It would be useful to move tests/data/test_request-amlight_zaoxi-p2p-v2.json from pce to datamodel src/sdx_datamodel/data/requests/ so that we can use it here, eventually.

However, for the purpose of the issue (namely, generating a connection ID), I think the newly added test should be sufficient.

@coveralls
Copy link

coveralls commented Jul 5, 2024

Pull Request Test Coverage Report for Build 9811578134

Details

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 52.486%

Totals Coverage Status
Change from base Build 9586048784: 0.2%
Covered Lines: 763
Relevant Lines: 1478

💛 - Coveralls

@sajith
Copy link
Member Author

sajith commented Jul 5, 2024

Ok, added a test that finds a solution.

Note that sdx-pce @ git+https://github.com/atlanticwave-sdx/pce@2a4dbb7 refers to a pce branch that I just pushed, just for testing. We'll need to bump up datamodel and then pce so that we can "properly" use the newest connection request file that was added to datamodel.

@YufengXin
Copy link
Collaborator

Cool! Now that the two tests worked, would you mind/have time to merge the PRs to main properly across the 4 repos with the right pointers in project files? -:)

Otherwise I'll do it early next Monday.

Cong would work on the test and I'll fix next week if these merges break anything

@sajith
Copy link
Member Author

sajith commented Jul 5, 2024

Well, as long as you don't mind dealing with the fallout... Let me see how much I can get done today. :-)

@sajith sajith marked this pull request as ready for review July 5, 2024 20:26
@coveralls
Copy link

coveralls commented Jul 5, 2024

Pull Request Test Coverage Report for Build 9813294445

Details

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 52.486%

Totals Coverage Status
Change from base Build 9586048784: 0.2%
Covered Lines: 763
Relevant Lines: 1478

💛 - Coveralls

@sajith
Copy link
Member Author

sajith commented Jul 5, 2024

@YufengXin @congwang09 I went ahead and merged atlanticwave-sdx/datamodel#131 and atlanticwave-sdx/pce#195. Leaving atlanticwave-sdx/sdx-lc#156 alone for now because I have some comments there.

Ok, now you get to deal with the fallout from the above merges, while I get to do the main thing I've got to do. For a while anyway. ;-)

@sajith
Copy link
Member Author

sajith commented Jul 5, 2024

This should probably wait for @congwang09. :-)

Copy link
Contributor

@congwang09 congwang09 left a comment

Choose a reason for hiding this comment

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

Tested, and this is working fine.

@YufengXin YufengXin merged commit 2b2775a into main Jul 10, 2024
11 checks passed
@YufengXin YufengXin deleted the 296.connection-request-v2-spec branch July 10, 2024 15:14
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.

Generating/processing id in connection request spec 2.0.
4 participants