Skip to content

Commit

Permalink
Fix ReadContextListenerTests to avoid inconsistent WindowsFS file han…
Browse files Browse the repository at this point in the history
…dle simulation

Signed-off-by: Kunal Kotwani <[email protected]>
  • Loading branch information
kotwanikunal committed Sep 7, 2023
1 parent 2a35f15 commit e781bd6
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.common.blobstore.stream.read.listener;

import org.apache.lucene.tests.util.LuceneTestCase.SuppressFileSystems;
import org.opensearch.action.LatchedActionListener;
import org.opensearch.action.support.PlainActionFuture;
import org.opensearch.common.blobstore.stream.read.ReadContext;
Expand All @@ -32,6 +33,12 @@

import static org.opensearch.common.blobstore.stream.read.listener.ListenerTestUtils.CountingCompletionListener;

/*
WindowsFS tries to simulate file handles in a best case simulation.
The deletion for the open file on an actual Windows system will be performed as soon as the last handle
is closed, which this simulation does not account for. Preventing use of WindowsFS for these tests.
*/
@SuppressFileSystems("WindowsFS")
public class ReadContextListenerTests extends OpenSearchTestCase {

private Path path;
Expand Down Expand Up @@ -70,7 +77,6 @@ public void testReadContextListener() throws InterruptedException, IOException {
assertEquals(NUMBER_OF_PARTS * PART_SIZE, Files.size(fileLocation));
}

@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/9776")
public void testReadContextListenerFailure() throws Exception {
Path fileLocation = path.resolve(UUID.randomUUID().toString());
List<InputStreamContainer> blobPartStreams = initializeBlobPartStreams();
Expand Down Expand Up @@ -100,7 +106,7 @@ public int available() {
readContextListener.onResponse(readContext);

countDownLatch.await();
assertBusy(() -> { assertFalse(Files.exists(fileLocation)); });
assertFalse(Files.exists(fileLocation));
}

public void testReadContextListenerException() {
Expand Down

0 comments on commit e781bd6

Please sign in to comment.