@@ -354,10 +354,18 @@ extension IntegrationSuite {
354354 func testFSNotifyEvents( ) async throws {
355355 let id = " test-fsnotify-events "
356356
357- let bs = try await bootstrap ( )
357+ let bs = try await bootstrap ( reference : " docker.io/library/node:18-alpine " )
358358 let directory = try createFSNotifyTestDirectory ( )
359+ let inotifyBuffer : IntegrationSuite . BufferWriter = BufferWriter ( )
359360 let container = try LinuxContainer ( id, rootfs: bs. rootfs, vmm: bs. vmm) { config in
360- config. process. arguments = [ " /bin/sh " , " -c " , " sleep 30 " ] // Keep container running
361+ config. process. arguments = [
362+ " node " ,
363+ " -e " ,
364+ " fs=require('fs');fs.watch(process.argv[1],(t,f)=>console.log(t,f)) " ,
365+ " /mnt " ,
366+ ]
367+ config. process. stdout = inotifyBuffer
368+ config. process. stderr = inotifyBuffer
361369 config. mounts. append ( . share( source: directory. path, destination: " /mnt " ) )
362370 }
363371
@@ -368,8 +376,10 @@ extension IntegrationSuite {
368376 let connection = try await container. dialVsock ( port: 1024 ) // Default vminitd port
369377 let group = MultiThreadedEventLoopGroup ( numberOfThreads: 1 )
370378 let agent = Vminitd ( connection: connection, group: group)
379+ try await Task . sleep ( for: . seconds( 1 ) )
371380
372381 // Test 1: CREATE event on existing file
382+ print ( " Sending CREATE event... " )
373383 let createResponse = try await agent. notifyFileSystemEvent (
374384 path: " /mnt/existing.txt " ,
375385 eventType: . create,
@@ -379,8 +389,10 @@ extension IntegrationSuite {
379389 guard createResponse. success else {
380390 throw IntegrationError . assert ( msg: " CREATE event failed: \( createResponse. error) " )
381391 }
392+ print ( " CREATE event succeeded " )
382393
383394 // Test 2: MODIFY event on existing file
395+ print ( " Sending MODIFY event... " )
384396 let modifyResponse = try await agent. notifyFileSystemEvent (
385397 path: " /mnt/existing.txt " ,
386398 eventType: . modify,
@@ -389,42 +401,23 @@ extension IntegrationSuite {
389401 guard modifyResponse. success else {
390402 throw IntegrationError . assert ( msg: " MODIFY event failed: \( modifyResponse. error) " )
391403 }
404+ print ( " MODIFY event succeeded " )
392405
393- // Test 3: Verify inotify events are actually generated using inotifywait
394- let inotifyBuffer = BufferWriter ( )
395- let inotifyProcess = try await container. exec ( " test-inotify " ) { config in
396- // Install inotify-tools and monitor the mount point for events
397- config. arguments = [
398- " /bin/sh " , " -c " ,
399- """
400- apk add --no-cache inotify-tools > /dev/null 2>&1 && \
401- timeout 5 inotifywait -m /mnt -e modify,create,delete --format '%e %f' 2>/dev/null || true
402- """ ,
403- ]
404- config. stdout = inotifyBuffer
405- }
406-
407- try await inotifyProcess. start ( )
408-
409- // Wait for inotify to start monitoring, then send FSNotify events
410- try await Task . sleep ( for: . milliseconds( 500 ) )
411-
412- // Send ONLY agent-driven events
413- let _ = try await agent. notifyFileSystemEvent (
414- path: " /mnt/existing.txt " ,
415- eventType: . modify,
416- containerID: id
417- )
406+ // Wait for events to be processed
407+ print ( " Waiting for inotify events to be detected... " )
408+ try await Task . sleep ( for: . seconds( 1 ) )
418409
419- let _ = try await inotifyProcess. wait ( )
420410 let inotifyOutput = String ( data: inotifyBuffer. data, encoding: . utf8) ?? " "
411+ print ( " === Final Container Output === " )
412+ print ( inotifyOutput)
413+ print ( " === End Container Output === " )
421414
422415 // Verify that inotify detected the modify event
423- guard inotifyOutput. contains ( " MODIFY existing.txt" ) else {
424- throw IntegrationError . assert ( msg: " inotify did not detect FSNotify agent modify event . Output: ' \( inotifyOutput) ' " )
416+ guard inotifyOutput. contains ( " change " ) && inotifyOutput . contains ( " existing.txt " ) else {
417+ throw IntegrationError . assert ( msg: " inotify did not detect FSNotify agent events . Output: ' \( inotifyOutput) ' " )
425418 }
426419
427- // Test 4 : DELETE event on non-existent file
420+ // Test 3 : DELETE event on non-existent file
428421 let deleteResponse = try await agent. notifyFileSystemEvent (
429422 path: " /mnt/nonexistent.txt " ,
430423 eventType: . delete,
0 commit comments