-
Notifications
You must be signed in to change notification settings - Fork 39
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
[WIP] [reconfigurator] introduce a simulator, make CLI use it #6856
base: sunshowers/spr/main.wip-reconfigurator-introduce-a-simulator-make-cli-use-it
Are you sure you want to change the base?
Conversation
Created using spr 1.3.6-beta.1
@@ -0,0 +1,3 @@ | |||
// This Source Code Form is subject to the terms of the Mozilla Public | |||
// License, v. 2.0. If a copy of the MPL was not distributed with this | |||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
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.
TODO: remove this file
//! | ||
//! This library contains facilities to track and simulate successive system | ||
//! states in the face of reconfiguration events. The library uses an operation | ||
//! log internally to make it possible to rewind to previous states. |
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.
TODO: expand on this
struct SubnetIterator { | ||
subnets: Ipv6Subnets, | ||
} |
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.
Can split this into its own PR.
|
||
use crate::errors::{DuplicateError, MissingError, NonEmptySystemError}; | ||
|
||
/// A versioned, simulated reconfigurator system. |
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.
More documentation.
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
For non-deterministic testing, it's useful to have a higher-level notion of a
succession of system states, which can be inspected, rewound, and other
branches explored as desired. Introduce this via a new
Simulator
struct.The individual states are roughly identical to the existing
ReconfiguratorSim
in the CLI, and are a pretty standard tree structure. Fornow I've chosen not to use a Merkle tree, just a UUID-based tree, but if
there's a good use case for it we may choose to make it a Merkle tree in the
future.
I've added a few basic features like storing the log of changes (though it's
not complete... I think I'll want to make
SystemDescription
follow the samestructure with read-only and mutable versions.)
As a proof of concept, this PR also rebuilds the current reconfigurator-cli
script on top of the simulator. I've not made any functional changes to the
CLI, but hope to add features like looking at the tree of states and undoing
them, and with non-deterministic testing to be able to load up the tree of
states.
The simulator uses a bunch of structural sharing via
Arc
. I was wonderingwhether I could use the
im
crate, but it doesn't seem to have anIndexMap
equivalent, but it doesn't seem to have an
IndexMap
equivalent that I couldtell. The
Arc
s should make cloning cheap enough that I don't think it's anissue in any case. (There's a comment in the PR about why I haven't used an
object-store-like style instead -- it's just easier to use
Arc
for now.)There's a bunch of work to be done before this can be landed, but I wanted to
put it up for folks to have an early look.
TODO fill this out in more detail.