@@ -1560,7 +1560,7 @@ mod tests {
1560
1560
use tokio:: time:: timeout;
1561
1561
1562
1562
const TIMEOUT_DURATION : tokio:: time:: Duration =
1563
- tokio:: time:: Duration :: from_secs ( 3 ) ;
1563
+ tokio:: time:: Duration :: from_secs ( 30 ) ;
1564
1564
1565
1565
#[ derive( Default , Clone ) ]
1566
1566
enum ReceivedInstanceState {
@@ -1748,7 +1748,7 @@ mod tests {
1748
1748
tokio:: spawn ( storage_manager. run ( ) ) ;
1749
1749
let external_zpool_name = ZpoolName :: new_external ( Uuid :: new_v4 ( ) ) ;
1750
1750
let external_disk: RawDisk =
1751
- SyntheticDisk :: new ( external_zpool_name) . into ( ) ;
1751
+ SyntheticDisk :: new ( external_zpool_name, 0 ) . into ( ) ;
1752
1752
storage_handle. upsert_disk ( external_disk) . await ;
1753
1753
storage_handle
1754
1754
}
@@ -1913,10 +1913,15 @@ mod tests {
1913
1913
1914
1914
let ( put_tx, put_rx) = oneshot:: channel ( ) ;
1915
1915
1916
+ // pretending we're InstanceManager::ensure_state, start our "instance"
1917
+ // (backed by fakes and propolis_mock_server)
1916
1918
inst. put_state ( put_tx, InstanceStateRequested :: Running )
1917
1919
. await
1918
1920
. expect ( "failed to send Instance::put_state" ) ;
1919
1921
1922
+ // even though we ignore this result at instance creation time in
1923
+ // practice (to avoid request timeouts), in this test let's make sure
1924
+ // it actually completes.
1920
1925
timeout ( TIMEOUT_DURATION , put_rx)
1921
1926
. await
1922
1927
. expect ( "timed out waiting for Instance::put_state result" )
@@ -1982,11 +1987,21 @@ mod tests {
1982
1987
1983
1988
let ( put_tx, put_rx) = oneshot:: channel ( ) ;
1984
1989
1990
+ tokio:: time:: pause ( ) ;
1991
+
1992
+ // pretending we're InstanceManager::ensure_state, try in vain to start
1993
+ // our "instance", but no propolis server is running
1985
1994
inst. put_state ( put_tx, InstanceStateRequested :: Running )
1986
1995
. await
1987
1996
. expect ( "failed to send Instance::put_state" ) ;
1988
1997
1989
- timeout ( TIMEOUT_DURATION , put_rx)
1998
+ let timeout_fut = timeout ( TIMEOUT_DURATION , put_rx) ;
1999
+
2000
+ tokio:: time:: advance ( TIMEOUT_DURATION ) . await ;
2001
+
2002
+ tokio:: time:: resume ( ) ;
2003
+
2004
+ timeout_fut
1990
2005
. await
1991
2006
. expect_err ( "*should've* timed out waiting for Instance::put_state, but didn't?" ) ;
1992
2007
@@ -2010,16 +2025,18 @@ mod tests {
2010
2025
// automock'd things used during this test
2011
2026
let _mock_vnic_contexts = mock_vnic_contexts ( ) ;
2012
2027
2028
+ let rt_handle = tokio:: runtime:: Handle :: current ( ) ;
2029
+
2013
2030
// time out while booting zone, on purpose!
2014
2031
let boot_ctx = MockZones :: boot_context ( ) ;
2015
- boot_ctx. expect ( ) . return_once ( |_| {
2016
- std :: thread :: sleep ( TIMEOUT_DURATION * 2 ) ;
2032
+ boot_ctx. expect ( ) . return_once ( move |_| {
2033
+ rt_handle . block_on ( tokio :: time :: sleep ( TIMEOUT_DURATION * 2 ) ) ;
2017
2034
Ok ( ( ) )
2018
2035
} ) ;
2019
2036
let wait_ctx = illumos_utils:: svc:: wait_for_service_context ( ) ;
2020
- wait_ctx. expect ( ) . times ( 1 ..) . returning ( |_, _, _| Ok ( ( ) ) ) ;
2037
+ wait_ctx. expect ( ) . times ( ..) . returning ( |_, _, _| Ok ( ( ) ) ) ;
2021
2038
let zone_id_ctx = MockZones :: id_context ( ) ;
2022
- zone_id_ctx. expect ( ) . times ( 1 ..) . returning ( |_| Ok ( Some ( 1 ) ) ) ;
2039
+ zone_id_ctx. expect ( ) . times ( ..) . returning ( |_| Ok ( Some ( 1 ) ) ) ;
2023
2040
2024
2041
let FakeNexusParts { nexus_client, nexus_server, state_rx } =
2025
2042
FakeNexusParts :: new ( & logctx) ;
@@ -2051,13 +2068,23 @@ mod tests {
2051
2068
. await
2052
2069
. expect ( "timed out creating Instance struct" ) ;
2053
2070
2071
+ tokio:: time:: pause ( ) ;
2072
+
2054
2073
let ( put_tx, put_rx) = oneshot:: channel ( ) ;
2055
2074
2075
+ // pretending we're InstanceManager::ensure_state, try in vain to start
2076
+ // our "instance", but the zone never finishes installing
2056
2077
inst. put_state ( put_tx, InstanceStateRequested :: Running )
2057
2078
. await
2058
2079
. expect ( "failed to send Instance::put_state" ) ;
2059
2080
2060
- timeout ( TIMEOUT_DURATION , put_rx)
2081
+ let timeout_fut = timeout ( TIMEOUT_DURATION , put_rx) ;
2082
+
2083
+ tokio:: time:: advance ( TIMEOUT_DURATION * 2 ) . await ;
2084
+
2085
+ tokio:: time:: resume ( ) ;
2086
+
2087
+ timeout_fut
2061
2088
. await
2062
2089
. expect_err ( "*should've* timed out waiting for Instance::put_state, but didn't?" ) ;
2063
2090
0 commit comments