Skip to content

Commit 58c1449

Browse files
committed
Another test
Signed-off-by: Benjamin Leggett <[email protected]>
1 parent 95ed979 commit 58c1449

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/inpod/statemanager.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,47 @@ mod tests {
612612
state.drain().await;
613613
}
614614

615+
#[tokio::test]
616+
async fn del_workload_before_snapshot_removes_from_pending() {
617+
let fixture = fixture!();
618+
let mut state = fixture.state;
619+
620+
let ns = new_netns();
621+
622+
// to make the proxy fail, bind to its ports in its netns
623+
let _sock = create_proxy_conflict(&ns);
624+
625+
let data = WorkloadData {
626+
netns: ns,
627+
workload_uid: uid(0),
628+
workload_info: workload_info(),
629+
};
630+
631+
let ret = state
632+
.process_msg(WorkloadMessage::AddWorkload(data))
633+
.await;
634+
635+
assert!(state.snapshot_names.len() == 1);
636+
assert!(ret.is_err());
637+
assert!(state.have_pending());
638+
639+
state
640+
.process_msg(WorkloadMessage::DelWorkload(uid(0)))
641+
.await
642+
.unwrap();
643+
644+
assert!(state.snapshot_names.is_empty());
645+
646+
state
647+
.process_msg(WorkloadMessage::WorkloadSnapshotSent)
648+
.await
649+
.unwrap();
650+
651+
assert!(state.snapshot_names.is_empty());
652+
assert!(!state.have_pending());
653+
state.drain().await;
654+
}
655+
615656
#[tokio::test]
616657
async fn add_delete_add_workload_starts_only_one_proxy() {
617658
let fixture = fixture!();

0 commit comments

Comments
 (0)