@@ -236,53 +236,55 @@ it.layer(NodeServices.layer)("service state persistence", (it) => {
236236 } ) ,
237237 ) ;
238238
239- it . effect ( "a fresh launcher repoints a unit left behind by an interrupted commit" , ( ) =>
240- Effect . gen ( function * ( ) {
241- const fs = yield * FileSystem . FileSystem ;
242- const path = yield * Path . Path ;
243- const root = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-service-launcher-repoint-" } ) ;
244- const statePath = path . join ( root , "runtime" , "service-state.json" ) ;
245- yield * writeFakeRuntime (
246- fs ,
247- path ,
248- path . join ( root , "runtime" , "versions" , "1.1.0" ) ,
249- "setInterval(() => {}, 1_000);\n" ,
250- ) ;
251- yield * Effect . promise ( ( ) =>
252- writeServiceState ( statePath , {
253- protocol : SERVICE_LAUNCHER_PROTOCOL ,
254- activeVersion : "1.1.0" ,
255- update : {
256- id : "update-1" ,
257- fromVersion : "1.0.0" ,
258- targetVersion : "1.1.0" ,
259- status : "committed" ,
260- } ,
261- } ) ,
262- ) ;
263- const unit = yield * fakeServiceUnit ( fs , path , root , "1.0.0" ) ;
264- const run = ( ) =>
265- Effect . gen ( function * ( ) {
266- const launcher = new Launcher (
267- root ,
268- yield * Effect . promise ( ( ) => readServiceState ( statePath ) ) ,
269- { serviceUnit : unit } ,
270- ) ;
271- const running = launcher . run ( ) ;
272- yield * Effect . promise ( ( ) => launcher . stop ( "SIGTERM" ) ) ;
273- yield * Effect . promise ( ( ) => running ) ;
274- } ) ;
275-
276- yield * run ( ) ;
277- assert . equal (
278- yield * fs . readFileString ( unit . path ) ,
279- renderBootServiceUnit ( unitPlan ( root , "1.1.0" ) ) ,
280- ) ;
281- assert . equal ( unit . reloads , 1 ) ;
239+ it . effect . each ( [ "committed" , "rolled-back" ] as const ) (
240+ "a fresh launcher repoints a unit left behind by a %s update" ,
241+ ( status ) =>
242+ Effect . gen ( function * ( ) {
243+ const fs = yield * FileSystem . FileSystem ;
244+ const path = yield * Path . Path ;
245+ const root = yield * fs . makeTempDirectoryScoped ( { prefix : "t3-service-launcher-repoint-" } ) ;
246+ const statePath = path . join ( root , "runtime" , "service-state.json" ) ;
247+ yield * writeFakeRuntime (
248+ fs ,
249+ path ,
250+ path . join ( root , "runtime" , "versions" , "1.1.0" ) ,
251+ "setInterval(() => {}, 1_000);\n" ,
252+ ) ;
253+ yield * Effect . promise ( ( ) =>
254+ writeServiceState ( statePath , {
255+ protocol : SERVICE_LAUNCHER_PROTOCOL ,
256+ activeVersion : "1.1.0" ,
257+ update : {
258+ id : "update-1" ,
259+ fromVersion : status === "committed" ? "1.0.0" : "1.1.0" ,
260+ targetVersion : status === "committed" ? "1.1.0" : "1.2.0" ,
261+ status,
262+ } ,
263+ } ) ,
264+ ) ;
265+ const unit = yield * fakeServiceUnit ( fs , path , root , "1.0.0" ) ;
266+ const run = ( ) =>
267+ Effect . gen ( function * ( ) {
268+ const launcher = new Launcher (
269+ root ,
270+ yield * Effect . promise ( ( ) => readServiceState ( statePath ) ) ,
271+ { serviceUnit : unit } ,
272+ ) ;
273+ const running = launcher . run ( ) ;
274+ yield * Effect . promise ( ( ) => launcher . stop ( "SIGTERM" ) ) ;
275+ yield * Effect . promise ( ( ) => running ) ;
276+ } ) ;
277+
278+ yield * run ( ) ;
279+ assert . equal (
280+ yield * fs . readFileString ( unit . path ) ,
281+ renderBootServiceUnit ( unitPlan ( root , "1.1.0" ) ) ,
282+ ) ;
283+ assert . equal ( unit . reloads , 1 ) ;
282284
283- yield * run ( ) ;
284- assert . equal ( unit . reloads , 1 ) ;
285- } ) ,
285+ yield * run ( ) ;
286+ assert . equal ( unit . reloads , 1 ) ;
287+ } ) ,
286288 ) ;
287289
288290 it . effect ( "stays idle instead of exiting when another server owns the T3 home" , ( ) =>
0 commit comments