@@ -10,20 +10,17 @@ use nexus_test_utils::http_testing::AuthnMode;
1010use nexus_test_utils:: http_testing:: NexusRequest ;
1111use nexus_test_utils:: http_testing:: RequestBuilder ;
1212use nexus_test_utils:: resource_helpers:: {
13- create_disk, create_instance_with , create_ip_pool, create_organization,
14- create_project , create_vpc, object_create, project_get, DiskTest ,
13+ create_disk, create_ip_pool, create_organization, create_project ,
14+ create_vpc, object_create, project_get, DiskTest ,
1515} ;
1616use nexus_test_utils_macros:: nexus_test;
17+ use omicron_common:: api:: external:: ByteCount ;
1718use omicron_common:: api:: external:: IdentityMetadataCreateParams ;
1819use omicron_common:: api:: external:: Instance ;
20+ use omicron_common:: api:: external:: InstanceCpuCount ;
1921use omicron_nexus:: external_api:: params;
2022use omicron_nexus:: external_api:: views;
2123use omicron_nexus:: external_api:: views:: Project ;
22- use omicron_nexus:: Nexus ;
23- use omicron_nexus:: TestInterfaces as _;
24- use sled_agent_client:: TestInterfaces as _;
25- use std:: sync:: Arc ;
26- use uuid:: Uuid ;
2724
2825type ControlPlaneTestContext =
2926 nexus_test_utils:: ControlPlaneTestContext < omicron_nexus:: Server > ;
@@ -135,11 +132,6 @@ async fn delete_project_expect_fail(
135132 error. message
136133}
137134
138- pub async fn instance_simulate ( nexus : & Arc < Nexus > , id : & Uuid ) {
139- let sa = nexus. instance_sled_by_id ( id) . await . unwrap ( ) ;
140- sa. instance_finish_transition ( id. clone ( ) ) . await ;
141- }
142-
143135#[ nexus_test]
144136async fn test_project_deletion ( cptestctx : & ControlPlaneTestContext ) {
145137 let client = & cptestctx. external_client ;
@@ -171,7 +163,6 @@ async fn test_project_deletion_with_instance(
171163 cptestctx : & ControlPlaneTestContext ,
172164) {
173165 let client = & cptestctx. external_client ;
174- let apictx = & cptestctx. server . apictx ;
175166
176167 let org_name = "test-org" ;
177168 create_ip_pool ( & client, "p0" , None , None ) . await ;
@@ -184,43 +175,33 @@ async fn test_project_deletion_with_instance(
184175 create_project ( & client, & org_name, & name) . await ;
185176 delete_project_default_subnet ( & url, & client) . await ;
186177 delete_project_default_vpc ( & url, & client) . await ;
187- let instance = create_instance_with (
188- & client,
189- & org_name,
190- & name,
191- "my-instance" ,
192- & params:: InstanceNetworkInterfaceAttachment :: None ,
193- vec ! [ ] ,
178+
179+ let _: Instance = object_create (
180+ client,
181+ & format ! ( "{url}/instances" ) ,
182+ & params:: InstanceCreate {
183+ identity : IdentityMetadataCreateParams {
184+ name : "my-instance" . parse ( ) . unwrap ( ) ,
185+ description : format ! ( "description" ) ,
186+ } ,
187+ ncpus : InstanceCpuCount ( 4 ) ,
188+ memory : ByteCount :: from_gibibytes_u32 ( 1 ) ,
189+ hostname : String :: from ( "the_host" ) ,
190+ user_data : b"none" . to_vec ( ) ,
191+ network_interfaces :
192+ params:: InstanceNetworkInterfaceAttachment :: None ,
193+ external_ips : vec ! [ ] ,
194+ disks : vec ! [ ] ,
195+ start : false ,
196+ } ,
194197 )
195198 . await ;
199+
196200 assert_eq ! (
197201 "project to be deleted contains an instance" ,
198202 delete_project_expect_fail( & url, & client) . await ,
199203 ) ;
200- let nexus = & apictx. nexus ;
201-
202- // TODO: Can we start the instance as stopped...
203204
204- // Let the instance start running
205- instance_simulate ( nexus, & instance. identity . id ) . await ;
206- // Ask the instance to stop
207- NexusRequest :: new (
208- RequestBuilder :: new (
209- client,
210- Method :: POST ,
211- & format ! ( "{url}/instances/my-instance/stop" ) ,
212- )
213- . body ( None as Option < & serde_json:: Value > )
214- . expect_status ( Some ( StatusCode :: ACCEPTED ) ) ,
215- )
216- . authn_as ( AuthnMode :: PrivilegedUser )
217- . execute ( )
218- . await
219- . unwrap ( )
220- . parsed_body :: < Instance > ( )
221- . unwrap ( ) ;
222- // Let the instance stop
223- instance_simulate ( nexus, & instance. identity . id ) . await ;
224205 NexusRequest :: object_delete (
225206 client,
226207 & format ! ( "{url}/instances/my-instance" ) ,
0 commit comments