Skip to content

Commit 4498bad

Browse files
committed
fix broken network interface test
The new "instances are in the VMM state iff they have a Propolis ID" check breaks db::queries::network_interface::tests::test_insert_running_instance_fails. This test suite assumes it can move an instance to the Vmm state and assign it a Propolis ID in separate statements. That's no longer allowed; do it in one statement instead.
1 parent a6bfd3f commit 4498bad

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

nexus/db-queries/src/db/queries/network_interface.rs

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,42 +1938,21 @@ mod tests {
19381938
mut instance: Instance,
19391939
state: InstanceState,
19401940
) -> Instance {
1941-
let new_runtime = model::InstanceRuntimeState {
1942-
nexus_state: state,
1943-
gen: instance.runtime_state.gen.next().into(),
1944-
..instance.runtime_state.clone()
1941+
let propolis_id = match state {
1942+
InstanceState::Vmm => Some(Uuid::new_v4()),
1943+
_ => None,
19451944
};
1946-
let res = db_datastore
1947-
.instance_update_runtime(&instance.id(), &new_runtime)
1948-
.await;
1949-
assert!(matches!(res, Ok(true)), "Failed to change instance state");
1950-
instance.runtime_state = new_runtime;
1951-
instance
1952-
}
19531945

1954-
/// Sets or clears the active Propolis ID in the supplied instance record.
1955-
/// This can be used to exercise the "does this instance have an active
1956-
/// VMM?" test that determines in part whether an instance's network
1957-
/// interfaces can change.
1958-
///
1959-
/// Note that this routine does not construct a VMM record for the
1960-
/// corresponding ID, so any functions that expect such a record to exist
1961-
/// will fail in strange and exciting ways.
1962-
async fn instance_set_active_vmm(
1963-
db_datastore: &DataStore,
1964-
mut instance: Instance,
1965-
propolis_id: Option<Uuid>,
1966-
) -> Instance {
19671946
let new_runtime = model::InstanceRuntimeState {
1947+
nexus_state: state,
19681948
propolis_id,
19691949
gen: instance.runtime_state.gen.next().into(),
19701950
..instance.runtime_state.clone()
19711951
};
1972-
19731952
let res = db_datastore
19741953
.instance_update_runtime(&instance.id(), &new_runtime)
19751954
.await;
1976-
assert!(matches!(res, Ok(true)), "Failed to change instance VMM ref");
1955+
assert!(matches!(res, Ok(true)), "Failed to change instance state");
19771956
instance.runtime_state = new_runtime;
19781957
instance
19791958
}
@@ -2104,7 +2083,7 @@ mod tests {
21042083
}
21052084

21062085
async fn create_running_instance(&self) -> Instance {
2107-
let instance = instance_set_state(
2086+
instance_set_state(
21082087
&self.db_datastore,
21092088
create_instance(
21102089
&self.opctx,
@@ -2114,13 +2093,6 @@ mod tests {
21142093
.await,
21152094
InstanceState::Vmm,
21162095
)
2117-
.await;
2118-
2119-
instance_set_active_vmm(
2120-
&self.db_datastore,
2121-
instance,
2122-
Some(Uuid::new_v4()),
2123-
)
21242096
.await
21252097
}
21262098
}

0 commit comments

Comments
 (0)