Skip to content

Commit 30d39df

Browse files
committed
review nits
1 parent 484d14b commit 30d39df

File tree

4 files changed

+44
-18
lines changed

4 files changed

+44
-18
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ branch = "oxide/omicron"
120120
#
121121
# libsodium-sys is a dependency of thrussh, used in `end-to-end-tests`. We
122122
# maintain a fork of the sodiumoxide repository to address an illumos build
123-
# issue. See the README.oxide.md in the "oxide" branch of our fork for
123+
# issue. See the README.oxide.md in the "omicron/oxide" branch of our fork for
124124
# details.
125125
#
126126
[patch.crates-io.libsodium-sys]

end-to-end-tests/src/bin/bootstrap.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use anyhow::{bail, Result};
2-
use end_to_end_tests::helpers::ctx::{build_client, nexus_addr, Context};
3-
use end_to_end_tests::helpers::generate_name;
1+
use anyhow::Result;
2+
use end_to_end_tests::helpers::ctx::{build_client, Context};
3+
use end_to_end_tests::helpers::{generate_name, get_system_ip_pool};
44
use omicron_test_utils::dev::poll::{wait_for_condition, CondCheckError};
55
use oxide_client::types::{
66
ByteCount, DiskCreate, DiskSource, IpPoolCreate, IpRange, Ipv4Range,
77
};
88
use oxide_client::{ClientDisksExt, ClientOrganizationsExt, ClientSystemExt};
9-
use std::net::IpAddr;
109
use std::time::Duration;
1110

1211
#[tokio::main]
@@ -30,17 +29,7 @@ async fn main() -> Result<()> {
3029

3130
// ===== CREATE IP POOL ===== //
3231
eprintln!("creating IP pool...");
33-
let nexus_addr = match nexus_addr().ip() {
34-
IpAddr::V4(addr) => addr.octets(),
35-
IpAddr::V6(_) => bail!("not sure what to do about IPv6 here"),
36-
};
37-
// TODO: not really sure about a good heuristic for selecting an IP address
38-
// range here. in both my (iliana's) environment and the lab, the last octet
39-
// is 20; in my environment the DHCP range is 100-249, and in the buildomat
40-
// lab environment the network is currently private.
41-
let first = [nexus_addr[0], nexus_addr[1], nexus_addr[2], 50].into();
42-
let last = [nexus_addr[0], nexus_addr[1], nexus_addr[2], 90].into();
43-
32+
let (first, last) = get_system_ip_pool()?;
4433
let pool_name = client
4534
.ip_pool_create()
4635
.body(IpPoolCreate {

end-to-end-tests/src/helpers/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
pub mod ctx;
22

3-
use anyhow::Result;
3+
use self::ctx::nexus_addr;
4+
use anyhow::{bail, Result};
45
use oxide_client::types::Name;
56
use rand::{thread_rng, Rng};
7+
use std::net::{IpAddr, Ipv4Addr};
68

79
pub fn generate_name(prefix: &str) -> Result<Name> {
810
format!("{}-{:x}", prefix, thread_rng().gen_range(0..0xfff_ffff_ffffu64))
911
.try_into()
1012
.map_err(anyhow::Error::msg)
1113
}
14+
15+
/// HACK: we're picking a range that doesn't conflict with either iliana's or
16+
/// the lab environment's IP ranges. This is not terribly robust. (in both
17+
/// iliana's environment and the lab, the last octet is 20; in my environment
18+
/// the DHCP range is 100-249, and in the buildomat lab environment the network
19+
/// is currently private.)
20+
pub fn get_system_ip_pool() -> Result<(Ipv4Addr, Ipv4Addr)> {
21+
let nexus_addr = match nexus_addr().ip() {
22+
IpAddr::V4(addr) => addr.octets(),
23+
IpAddr::V6(_) => bail!("not sure what to do about IPv6 here"),
24+
};
25+
26+
let first = [nexus_addr[0], nexus_addr[1], nexus_addr[2], 50].into();
27+
let last = [nexus_addr[0], nexus_addr[1], nexus_addr[2], 90].into();
28+
29+
Ok((first, last))
30+
}

end-to-end-tests/src/instance_launch.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,32 @@ async fn instance_launch() -> Result<()> {
219219
);
220220

221221
// tear-down
222-
eprintln!("tear-down");
222+
eprintln!("stopping instance");
223223
ctx.client
224224
.instance_stop()
225225
.organization_name(ctx.org_name.clone())
226226
.project_name(ctx.project_name.clone())
227227
.instance_name(instance.name.clone())
228228
.send()
229229
.await?;
230+
231+
eprintln!("deleting instance");
232+
wait_for_condition(
233+
|| async {
234+
ctx.client
235+
.instance_delete()
236+
.organization_name(ctx.org_name.clone())
237+
.project_name(ctx.project_name.clone())
238+
.instance_name(instance.name.clone())
239+
.send()
240+
.await
241+
.map_err(|_| CondCheckError::<oxide_client::Error>::NotYet)
242+
},
243+
&Duration::from_secs(1),
244+
&Duration::from_secs(60),
245+
)
246+
.await?;
247+
230248
ctx.cleanup().await
231249
}
232250

0 commit comments

Comments
 (0)