-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Transaction controller model based tests #1661
Open
kuujo
wants to merge
5
commits into
onosproject:master
Choose a base branch
from
kuujo:transaction-controller-model-based-tests
base: master
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.
Open
Transaction controller model based tests #1661
kuujo
wants to merge
5
commits into
onosproject:master
from
kuujo:transaction-controller-model-based-tests
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
SeanCondon
previously approved these changes
Jun 27, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hard to argue with a well formatted tar.gz ;-)
hi @kuujo - can we try to get this merged? |
retest this please |
@SeanCondon can this PR be merged? You already approved it. What is missing? |
@kuujo - Are we still good to merge this? |
# for free
to join this conversation on GitHub.
Already have an account?
# 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 PR adds unit tests to the transaction controller using state transitions output by the TLC model. In total, it adds nearly 100k unit tests covering a wide array of scenarios to the transaction controller tests.
The way it works is it uses the TLA+ spec to generate test cases for every possible scenario that could occur within the onos-config stores. Based on the spec, the TLC model checker computes every possible state and transition and writes them to a file in JSON format, and the test then reads through those states and creates a new subtest for each state/transition. To run the test, the test runner sets up the transaction reconciler using mock stores that return the initial state of the system at the start of the test. For example,
transaction.Store
'sGet
method will be mocked to return theTransaction
being reconciled, which the reconciler will retrieve at the start of theReconcile
call. Then, the test runner explores each possible transition from that state, and uses those transitions to create expected mock API calls. For example, if the controller is supposed to update theConfiguration
's committed values, it will mock an expected call to theconfiguration.Store
'sUpdate
method, and when that method is called, the test runner will check the updates state to verify it's consistent with the TLA+ spec/model.The tests also check states where the controller should not change anything (e.g. the change is waiting to be applied but the node is not connected to the target), and it tests scenarios where a failure can occur during the reconciliation call, resulting in a partial state change. For example, the TLA+ spec models scenarios where the reconciler updates the
Configuration
successfully but fails while updating theTransaction
store state, e.g. due to a node or store failure. In this scenario, the test runner will configure theConfiguration
store to expect an update and theTransaction
store to return an error indicating the failure.Because the test cases are generated from the TLA+ spec, and because the TLA+ spec is checked for correctness, controller code that behaves consistent with the spec can be assumed to be correct, as well. In this case, the type of "correctness" the model checker has evaluated in the spec is:
In short, the algorithm guarantees order and progress and is devoid of deadlock paths, regardless of when or how the node, network, or target may fail.