-
Notifications
You must be signed in to change notification settings - Fork 16
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
[ovsp4rt] Implement Client class (work in progress) #674
Draft
ffoulkes
wants to merge
23
commits into
main
Choose a base branch
from
context-object
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Implemented the `Context` class, to provide an abstract interface to the P4Runtime server. - Modified ovsp4rt.cc to use the `Context` object instead of the `OvsP4rtSession` object. In addition to simplifying the code, the `Context` object should allow us to mock the P4Runtime server for unit testing. Signed-off-by: Derek Foster <derek.foster@intel.com>
ffoulkes
added
tests
Affects unit tests
enhancement
New feature or request
and removed
tests
Affects unit tests
labels
Aug 26, 2024
- Made each public C API function a wrapper around a C++ function that accepts the Context object and one of its parameters. This makes it possible to inject a test double. Signed-off-by: Derek Foster <derek.foster@intel.com>
Signed-off-by: Derek Foster <derek.foster@intel.com>
Signed-off-by: Derek Foster <derek.foster@intel.com>
Signed-off-by: Derek Foster <derek.foster@intel.com>
Signed-off-by: Derek Foster <derek.foster@intel.com>
ffoulkes
changed the title
[ovsp4rt] Implement Context class
[ovsp4rt] Implement Client class
Sep 3, 2024
- Converted most of the GetEntry functions to HaveEntry predicates, to stress the difference between testing for the existence of an entry and retrieving its contents. Signed-off-by: Derek Foster <derek.foster@intel.com>
Signed-off-by: Derek Foster <derek.foster@intel.com>
- Defined a virtual destructor. - Made the methods virtual. - Added internal documentation. Signed-off-by: Derek Foster <derek.foster@intel.com>
Signed-off-by: Derek Foster <derek.foster@intel.com>
ffoulkes
changed the title
[ovsp4rt] Implement Client class
[ovsp4rt] Implement Client class (work in progress)
Nov 6, 2024
Signed-off-by: Derek Foster <justffoulkes@gmail.com>
- Enabled the BUILD_CLIENT cmake option in the development branch. Signed-off-by: Derek Foster <justffoulkes@gmail.com>
- Added missing include directory and link libraries when building ovsp4rt_client object library. Signed-off-by: Derek Foster <justffoulkes@gmail.com>
- Fixed compile errors when building the Client library. - Fixed link errors when building ovsp4rt with the Client and Journal libraries. - Removed the session() method from the Client class. Signed-off-by: Derek Foster <justffoulkes@gmail.com>
- Changed `client` parameter type from `Client` to `ClientInterface`, to support dependency injection. Signed-off-by: Derek Foster <justffoulkes@gmail.com>
- Moved the C API wrapper functions to a separate source file, to allow a substitute front end to be used for testing. Signed-off-by: Derek Foster <justffoulkes@gmail.com>
Signed-off-by: Derek Foster <justffoulkes@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a project to improve the testability of ovsp4rt. See issue #701 for details.
Modified ovsp4rt.cc to use a
Client
object instead of anOvsP4rtSession
object to communicate with the P4Runtime server.Made each public C API function a wrapper around a C++ function that accepts a Client object as a parameter. This allows a unit test to replace the object with a test double (e.g. a mock).
Moved the C API functions to another file, separating the user interface from the implementation. This allows a substitute front end to be used for testing.
Converted most of the
GetEntry
functions toHaveEntry
predicates, to make it clear that their purpose is to test for the existence of an entry. The fact that they do so by attempting to read the entry is an implementation detail the caller doesn't need to know.Note
The
BUILD_CLIENT
cmake option is enabled by default in this branch. We cannot compile the modified version ofovsp4rt.cc
without it.