Skip to content

Commit ca8a905

Browse files
committed
Fix test for new load rack secret api and clean up comments
1 parent 2630d11 commit ca8a905

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

trust-quorum/src/task.rs

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ impl NodeTaskHandle {
234234
}
235235

236236
/// Load the rack secret for the given epoch
237-
///
238-
/// This can block for an indefinite period of time before returning
239-
/// and depends on availability of the trust quorum.
240237
pub async fn load_rack_secret(
241238
&self,
242239
epoch: Epoch,
@@ -247,12 +244,7 @@ impl NodeTaskHandle {
247244
Ok(rs)
248245
}
249246

250-
/// Return `Ok(true)` if the configuration has committed, `Ok(false)` if
251-
/// it hasn't committed yet, or an error otherwise.
252-
///
253-
/// Nexus will retry this operation and so we should only try once here.
254-
/// This is in contrast to operations like `load_rack_secret` that are
255-
/// called directly from sled agent.
247+
/// Attempt to prepare and commit the given configuration
256248
pub async fn prepare_and_commit(
257249
&self,
258250
config: Configuration,
@@ -263,12 +255,7 @@ impl NodeTaskHandle {
263255
Ok(res)
264256
}
265257

266-
/// Return `Ok(true)` if the configuration has committed, `Ok(false)` if
267-
/// it hasn't committed yet, or an error otherwise.
268-
///
269-
/// Nexus will retry this operation and so we should only try once here.
270-
/// This is in contrast to operations like `load_rack_secret` that are
271-
/// called directly from sled agent.
258+
/// Attempt to commit the configuration at epoch `epoch`
272259
pub async fn commit(
273260
&self,
274261
rack_id: RackUuid,
@@ -1607,7 +1594,10 @@ mod tests {
16071594
async || {
16081595
let mut acked = 0;
16091596
for h in &setup.node_handles {
1610-
if h.commit(rack_id, Epoch(1)).await.unwrap() {
1597+
if matches!(
1598+
h.commit(rack_id, Epoch(1)).await.unwrap(),
1599+
CommitStatus::Committed
1600+
) {
16111601
acked += 1;
16121602
}
16131603
}
@@ -1657,14 +1647,13 @@ mod tests {
16571647
}
16581648

16591649
// Now load the rack secret at all nodes
1660-
let mut secret = None;
1661-
for h in &setup.node_handles {
1662-
let rs = h.load_rack_secret(Epoch(1)).await.unwrap();
1663-
if secret.is_none() {
1664-
secret = Some(rs.clone());
1665-
}
1666-
assert_eq!(&rs, secret.as_ref().unwrap());
1667-
}
1650+
setup
1651+
.wait_for_rack_secrets_and_assert_equality(
1652+
(0..num_nodes).collect(),
1653+
Epoch(1),
1654+
)
1655+
.await
1656+
.unwrap();
16681657

16691658
setup.cleanup_successful();
16701659
}

0 commit comments

Comments
 (0)