-
Notifications
You must be signed in to change notification settings - Fork 58
[nexus-types] test that PlanningReports can be roundtrip serialized #9085
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
[nexus-types] test that PlanningReports can be roundtrip serialized #9085
Conversation
Created using spr 1.3.6-beta.1
#[cfg_attr(test, strategy(socket_addr_v6_without_flowinfo()))] | ||
pub sled_agent_address: SocketAddrV6, | ||
} | ||
|
||
// For proptest, we pass in flowinfo = 0, because flowinfo doesn't roundtrip | ||
// through JSON. | ||
#[cfg(test)] | ||
fn socket_addr_v6_without_flowinfo() | ||
-> impl proptest::strategy::Strategy<Value = SocketAddrV6> { | ||
use proptest::strategy::Strategy; | ||
|
||
proptest::arbitrary::any::<(Ipv6Addr, u16, u32)>().prop_map( | ||
|(addr, port, scope_id)| SocketAddrV6::new(addr, port, 0, scope_id), | ||
) | ||
} |
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.
😬
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.
ooof
Created using spr 1.3.6-beta.1
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.
Thanks! This looks like it was pretty tedious, but is way more robust than the path I started down.
nexus/types/src/deployment.rs
Outdated
|
||
// location of the baseboard (that we'd pass to MGS) | ||
/// what type of baseboard this is | ||
#[cfg_attr(test, strategy(proptest::prop_oneof![ |
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.
Was there something preventing us from deriving Arbitrary
for SpType
?
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.
Ended up replace
-ing the SpType
in gateway-client in favor of the one in gateway-types: #9093
With that change, we can derive Arbitrary
on SpType
.
#[cfg_attr(test, strategy(socket_addr_v6_without_flowinfo()))] | ||
pub sled_agent_address: SocketAddrV6, | ||
} | ||
|
||
// For proptest, we pass in flowinfo = 0, because flowinfo doesn't roundtrip | ||
// through JSON. | ||
#[cfg(test)] | ||
fn socket_addr_v6_without_flowinfo() | ||
-> impl proptest::strategy::Strategy<Value = SocketAddrV6> { | ||
use proptest::strategy::Strategy; | ||
|
||
proptest::arbitrary::any::<(Ipv6Addr, u16, u32)>().prop_map( | ||
|(addr, port, scope_id)| SocketAddrV6::new(addr, port, 0, scope_id), | ||
) | ||
} |
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.
ooof
Created using spr 1.3.6-beta.1
Created using spr 1.3.6-beta.1
This proptest would catch the issue detected in #9080.
Closes #9081.