Skip to content
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

Deprecate manually adding simulated sled agents #7375

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

jmpesp
Copy link
Contributor

@jmpesp jmpesp commented Jan 20, 2025

Change tests that manually add simulated sled agents to instead use the new extra_sled_agents macro parameter.

This was also pulled out of work as part of testing for oxidecomputer/crucible#1594.

Change tests that manually add simulated sled agents to instead use the
new `extra_sled_agents` macro parameter.

This was also pulled out of work as part of testing for
oxidecomputer/crucible#1594.
Copy link
Contributor

@gjcolombo gjcolombo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for doing this!

pub(crate) fn select_first_alternate_sled(
db_vmm: &crate::app::db::model::Vmm,
other_sleds: &[(SledUuid, omicron_sled_agent::sim::Server)],
other_sleds: &[&omicron_sled_agent::sim::Server],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that there's an all_sled_agents function on the test context, I think this whole function might boil down to

cptestctx.all_sled_agents().find(|sa| sa.id != db_vmm.sled_id).expect("need at least one other sled")

which could either be used as a function body here or substituted into the places where it's called (there are only three in my local clone).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b7de7c6, thanks :)

async fn test_migration_source_completed_succeeds(
cptestctx: &ControlPlaneTestContext,
) {
let _project_id = setup_test_project(&cptestctx.external_client).await;
let other_sleds = test_helpers::add_sleds(cptestctx, 1).await;
let other_sleds: Vec<_> = cptestctx.all_sled_agents().skip(1).collect();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, take it or leave it: we write this a lot...maybe ControlPlaneTestContext should just have a method that returns all of the extra sled agents?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, perhaps we could have the ControlPlaneTextContext return that as a slice, using &self.sled_agents[1..], so that callers don't need to always iterate over the sled agents and collect them?

Edit: Oh, disregard that last bit, I see that all_ssled_agents is returning the sa.server(), so it does have to be an iterator. Carry on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b7de7c6, thanks :)

@jmpesp jmpesp enabled auto-merge (squash) January 21, 2025 18:13
@jmpesp jmpesp merged commit 21c677e into oxidecomputer:main Jan 21, 2025
16 checks passed
@jmpesp jmpesp deleted the deprecate_add_sleds branch January 21, 2025 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants