@@ -100,8 +100,6 @@ public void testSchedulesHealthCheckAtRefreshIntervals() throws Exception {
100100 }
101101
102102 public void testFailsHealthOnIOException () throws IOException {
103- assumeFalse ("https://github.com/elastic/elasticsearch/issues/59380" , Constants .WINDOWS );
104-
105103 FileSystem fileSystem = PathUtils .getDefaultFileSystem ();
106104 FileSystemIOExceptionProvider disruptFileSystemProvider = new FileSystemIOExceptionProvider (fileSystem );
107105 fileSystem = disruptFileSystemProvider .getFileSystem (null );
@@ -116,6 +114,7 @@ public void testFailsHealthOnIOException() throws IOException {
116114 assertEquals ("health check passed" , fsHealthService .getHealth ().getInfo ());
117115
118116 //disrupt file system
117+ disruptFileSystemProvider .restrictPathPrefix ("" ); // disrupt all paths
119118 disruptFileSystemProvider .injectIOException .set (true );
120119 fsHealthService = new FsHealthService (settings , clusterSettings , testThreadPool , env );
121120 fsHealthService .new FsHealthMonitor ().run ();
@@ -221,9 +220,9 @@ public void testFailsHealthOnSinglePathWriteFailure() throws IOException {
221220 assertEquals ("health check passed" , fsHealthService .getHealth ().getInfo ());
222221
223222 //disrupt file system writes on single path
224- disruptWritesFileSystemProvider .injectIOException .set (true );
225223 String disruptedPath = randomFrom (paths ).toString ();
226224 disruptWritesFileSystemProvider .restrictPathPrefix (disruptedPath );
225+ disruptWritesFileSystemProvider .injectIOException .set (true );
227226 fsHealthService = new FsHealthService (settings , clusterSettings , testThreadPool , env );
228227 fsHealthService .new FsHealthMonitor ().run ();
229228 assertEquals (UNHEALTHY , fsHealthService .getHealth ().getStatus ());
@@ -241,7 +240,7 @@ private static class FileSystemIOExceptionProvider extends FilterFileSystemProvi
241240 AtomicBoolean injectIOException = new AtomicBoolean ();
242241 AtomicInteger injectedPaths = new AtomicInteger ();
243242
244- private String pathPrefix = "/" ;
243+ private String pathPrefix ;
245244
246245 FileSystemIOExceptionProvider (FileSystem inner ) {
247246 super ("disrupt_fs_health://" , inner );
@@ -258,6 +257,7 @@ public int getInjectedPathCount(){
258257 @ Override
259258 public OutputStream newOutputStream (Path path , OpenOption ... options ) throws IOException {
260259 if (injectIOException .get ()){
260+ assert pathPrefix != null : "must set pathPrefix before starting disruptions" ;
261261 if (path .toString ().startsWith (pathPrefix ) && path .toString ().endsWith (".es_temp_file" )) {
262262 injectedPaths .incrementAndGet ();
263263 throw new IOException ("fake IOException" );
@@ -272,7 +272,7 @@ private static class FileSystemFsyncIOExceptionProvider extends FilterFileSystem
272272 AtomicBoolean injectIOException = new AtomicBoolean ();
273273 AtomicInteger injectedPaths = new AtomicInteger ();
274274
275- private String pathPrefix = "/" ;
275+ private String pathPrefix = null ;
276276
277277 FileSystemFsyncIOExceptionProvider (FileSystem inner ) {
278278 super ("disrupt_fs_health://" , inner );
@@ -292,6 +292,7 @@ public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options,
292292 @ Override
293293 public void force (boolean metaData ) throws IOException {
294294 if (injectIOException .get ()) {
295+ assert pathPrefix != null : "must set pathPrefix before starting disruptions" ;
295296 if (path .toString ().startsWith (pathPrefix ) && path .toString ().endsWith (".es_temp_file" )) {
296297 injectedPaths .incrementAndGet ();
297298 throw new IOException ("fake IOException" );
0 commit comments