@@ -32,6 +32,22 @@ def test_simple_job_redirect(execparams: ExecutorTestParams) -> None:
3232
3333
3434def test_attach (execparams : ExecutorTestParams ) -> None :
35+ job1 = Job (JobSpec (executable = '/bin/sleep' , arguments = ['1' ]))
36+ ex = _get_executor_instance (execparams , job1 )
37+ ex .submit (job1 )
38+ job1 .wait (target_states = [JobState .ACTIVE , JobState .COMPLETED ])
39+ native_id = job1 .native_id
40+
41+ assert native_id is not None
42+ job2 = Job ()
43+ ex .attach (job2 , native_id )
44+ status2 = job2 .wait (timeout = _get_timeout (execparams ))
45+ assert_completed (job2 , status2 )
46+ status1 = job1 .wait (timeout = _get_timeout (execparams ))
47+ assert_completed (job1 , status1 )
48+
49+
50+ def test_attach2 (execparams : ExecutorTestParams ) -> None :
3551 job = Job (JobSpec (executable = '/bin/sleep' , arguments = ['1' ]))
3652 ex = _get_executor_instance (execparams , job )
3753 ex .submit (job )
@@ -40,7 +56,8 @@ def test_attach(execparams: ExecutorTestParams) -> None:
4056
4157 assert native_id is not None
4258 job2 = Job ()
43- ex .attach (job2 , native_id )
59+ ex2 = _get_executor_instance (execparams )
60+ ex2 .attach (job2 , native_id )
4461 status = job2 .wait (timeout = _get_timeout (execparams ))
4562 assert_completed (job2 , status )
4663
0 commit comments