Skip to content

Commit 73d557a

Browse files
committed
Optionally configure mgs and internal dns ports for omicron-dev.
This completes the set of omicron-dev ports used in the simulated workflow that includes `run-all` and a second nexus: https://github.com/oxidecomputer/omicron/blob/main/docs/how-to-run-simulated.adoc#using-both-omicron-dev-run-all-and-running-nexus-manually
1 parent 03a67c7 commit 73d557a

5 files changed

Lines changed: 59 additions & 22 deletions

File tree

dev-tools/omicron-dev/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ nexus-config.workspace = true
2222
nexus-test-interface.workspace = true
2323
nexus-test-utils = { workspace = true, features = ["omicron-dev"] }
2424
omicron-nexus.workspace = true
25-
omicron-test-utils.workspace = true
2625
omicron-workspace-hack.workspace = true
2726
oxide-tokio-rt.workspace = true
2827
# See omicron-rpaths for more about the "pq-sys" dependency.

dev-tools/omicron-dev/src/main.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use libc::SIGINT;
1111
use nexus_config::NexusConfig;
1212
use nexus_test_interface::NexusServer;
1313
use nexus_test_utils::resource_helpers::DiskTest;
14-
use omicron_test_utils::COCKROACHDB_DEFAULT_LISTEN_PORT;
1514
use signal_hook_tokio::Signals;
1615
use std::fs;
1716

@@ -49,12 +48,18 @@ enum OmicronDevCmd {
4948

5049
#[derive(Clone, Debug, Args)]
5150
struct RunAllArgs {
52-
/// Nexus external API listen port. Use `0` to request any available port.
51+
/// Nexus external API listen port. Use `0` to request any available port.
5352
#[clap(long, action)]
5453
nexus_listen_port: Option<u16>,
5554
/// CockroachDB listen port. Use `0` to request any available port.
56-
#[clap(long, default_value_t = COCKROACHDB_DEFAULT_LISTEN_PORT)]
57-
db_listen_port: u16,
55+
#[clap(long)]
56+
db_listen_port: Option<u16>,
57+
/// Internal DNS listen port. Use `0` to request any available port.
58+
#[clap(long)]
59+
internal_dns_listen_port: Option<u16>,
60+
/// Management gateway listen port. Use `0` to request any available port.
61+
#[clap(long)]
62+
mgs_listen_port: Option<u16>,
5863
/// Override the gateway server configuration file.
5964
#[clap(long, default_value = DEFAULT_SP_SIM_CONFIG)]
6065
gateway_config: Utf8PathBuf,
@@ -92,14 +97,18 @@ impl RunAllArgs {
9297
}
9398

9499
println!("omicron-dev: setting up all services ... ");
95-
let cptestctx =
96-
nexus_test_utils::omicron_dev_setup_with_config::<
97-
omicron_nexus::Server,
98-
>(
99-
&mut config, 0, self.gateway_config.clone(), self.db_listen_port
100-
)
101-
.await
102-
.context("error setting up services")?;
100+
let cptestctx = nexus_test_utils::omicron_dev_setup_with_config::<
101+
omicron_nexus::Server,
102+
>(
103+
&mut config,
104+
0,
105+
self.gateway_config.clone(),
106+
self.db_listen_port,
107+
self.internal_dns_listen_port,
108+
self.mgs_listen_port,
109+
)
110+
.await
111+
.context("error setting up services")?;
103112

104113
println!("omicron-dev: Adding disks to first sled agent");
105114

nexus/test-utils/src/nexus_test.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,14 @@ pub async fn omicron_dev_setup_with_config<N: NexusServer>(
361361
config: &mut NexusConfig,
362362
extra_sled_agents: u16,
363363
gateway_config_file: Utf8PathBuf,
364-
listen_port: u16,
364+
db_listen_port: Option<u16>,
365+
internal_dns_listen_port: Option<u16>,
366+
mgs_listen_port: Option<u16>,
365367
) -> Result<ControlPlaneTestContext<N>> {
366368
let mut starter = ControlPlaneStarter::<N>::new("omicron-dev", config);
367-
starter.db_listen_port(listen_port);
369+
starter.db_listen_port(db_listen_port);
370+
starter.internal_dns_listen_port(internal_dns_listen_port);
371+
starter.mgs_listen_port(mgs_listen_port);
368372

369373
let log = &starter.logctx.log;
370374
debug!(log, "Ensuring seed tarball exists");

nexus/test-utils/src/starter.rs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ pub struct ControlPlaneStarter<'a, N: NexusServer> {
168168
pub simulated_upstairs: Arc<sim::SimulatedUpstairs>,
169169

170170
db_listen_port: u16,
171+
internal_dns_listen_port: u16,
172+
mgs_listen_port: Option<u16>,
171173
}
172174

173175
type StepInitFn<'a, N> = Box<
@@ -219,11 +221,25 @@ impl<'a, N: NexusServer> ControlPlaneStarter<'a, N> {
219221
simulated_upstairs_log,
220222
)),
221223
db_listen_port: dev::db::COCKROACHDB_DEFAULT_LISTEN_PORT,
224+
internal_dns_listen_port: 0,
225+
mgs_listen_port: None,
222226
}
223227
}
224228

225-
pub fn db_listen_port(&mut self, port: u16) {
226-
self.db_listen_port = port;
229+
pub fn db_listen_port(&mut self, port: Option<u16>) {
230+
if let Some(port) = port {
231+
self.db_listen_port = port;
232+
}
233+
}
234+
235+
pub fn internal_dns_listen_port(&mut self, port: Option<u16>) {
236+
if let Some(port) = port {
237+
self.internal_dns_listen_port = port;
238+
}
239+
}
240+
241+
pub fn mgs_listen_port(&mut self, port: Option<u16>) {
242+
self.mgs_listen_port = port;
227243
}
228244

229245
pub async fn init_with_steps(
@@ -1212,7 +1228,18 @@ impl<'a, N: NexusServer> ControlPlaneStarter<'a, N> {
12121228
/// Set up an internal DNS server on the first sled agent
12131229
pub async fn start_internal_dns(&mut self) {
12141230
let log = self.logctx.log.new(o!("component" => "internal_dns_server"));
1215-
let dns = dns_server::TransientServer::new(&log).await.unwrap();
1231+
let dns_addr = SocketAddrV6::new(
1232+
Ipv6Addr::LOCALHOST,
1233+
self.internal_dns_listen_port,
1234+
0,
1235+
0,
1236+
);
1237+
let dns = dns_server::TransientServer::new_with_address(
1238+
&log,
1239+
dns_addr.into(),
1240+
)
1241+
.await
1242+
.unwrap();
12161243

12171244
let SocketAddr::V6(dns_address) = dns.dns_server.local_address() else {
12181245
panic!("Unsupported IPv4 DNS address");
@@ -1633,7 +1660,7 @@ pub(crate) async fn setup_with_config_impl<N: NexusServer>(
16331660
builder
16341661
.start_gateway(
16351662
SwitchLocation::Switch0,
1636-
None,
1663+
builder.mgs_listen_port,
16371664
mgs_config,
16381665
)
16391666
.boxed()
@@ -1677,7 +1704,7 @@ pub(crate) async fn setup_with_config_impl<N: NexusServer>(
16771704
builder
16781705
.start_gateway(
16791706
SwitchLocation::Switch1,
1680-
None,
1707+
builder.mgs_listen_port,
16811708
gateway_config_file,
16821709
)
16831710
.boxed()

test-utils/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use headers::authorization::Credentials;
1515
pub mod certificates;
1616
pub mod dev;
1717

18-
pub use dev::db::COCKROACHDB_DEFAULT_LISTEN_PORT;
19-
2018
#[macro_use]
2119
extern crate slog;
2220

0 commit comments

Comments
 (0)