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 (opensearch-project#9915)

Signed-off-by: Kunal Kotwani <kkotwani@amazon.com>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
  • Loading branch information
kotwanikunal authored and shiv0408 committed Apr 25, 2024
1 parent 9064a4b commit 5bf77db
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 5bf77db

Please sign in to comment.