Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <sachinpkale@gmail.com>
  • Loading branch information
sachinpkale committed Oct 11, 2024
1 parent e6a099a commit 60c08be
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1505,4 +1505,22 @@ public void testTrimUnreferencedReadersNoPermits() throws Exception {
);
}, 30, TimeUnit.SECONDS);
}

public void testTrimUnreferencedReadersFailAlwaysRepo() throws Exception {
ArrayList<Translog.Operation> ops = new ArrayList<>();

addToTranslogAndListAndUpload(translog, ops, new Translog.Index("0", 0, primaryTerm.get(), new byte[] { 1 }));
addToTranslogAndListAndUpload(translog, ops, new Translog.Index("1", 1, primaryTerm.get(), new byte[] { 1 }));
addToTranslogAndListAndUpload(translog, ops, new Translog.Index("2", 2, primaryTerm.get(), new byte[] { 1 }));
addToTranslogAndListAndUpload(translog, ops, new Translog.Index("3", 3, primaryTerm.get(), new byte[] { 1 }));

translog.setMinSeqNoToKeep(2);
RemoteStoreSettings.setPinnedTimestampsLookbackInterval(TimeValue.ZERO);
updatePinnedTimstampTask.run();

fail.failAlways();
translog.trimUnreferencedReaders();

assertBusy(() -> assertTrue(translog.isRemoteGenerationDeletionPermitsAvailable()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.opensearch.cluster.metadata.RepositoryMetadata;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.blobstore.BlobContainer;
import org.opensearch.common.blobstore.BlobMetadata;
import org.opensearch.common.blobstore.BlobPath;
import org.opensearch.common.blobstore.BlobStore;
import org.opensearch.common.blobstore.fs.FsBlobContainer;
Expand All @@ -32,6 +33,7 @@
import org.opensearch.common.util.concurrent.AbstractRunnable;
import org.opensearch.common.util.concurrent.ConcurrentCollections;
import org.opensearch.common.util.io.IOUtils;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.common.bytes.BytesArray;
import org.opensearch.core.common.unit.ByteSizeUnit;
import org.opensearch.core.common.unit.ByteSizeValue;
Expand Down Expand Up @@ -1965,6 +1967,28 @@ public void writeBlobAtomic(final String blobName, final InputStream inputStream
}
super.writeBlobAtomic(blobName, inputStream, blobSize, failIfAlreadyExists);
}

@Override
public void listBlobsByPrefixInSortedOrder(
String blobNamePrefix,
int limit,
BlobNameSortOrder blobNameSortOrder,
ActionListener<List<BlobMetadata>> listener
) {
if (fail.fail()) {
listener.onFailure(new RuntimeException("blob container throwing error"));
return;
}
if (slowDown.getSleepSeconds() > 0) {
try {
Thread.sleep(slowDown.getSleepSeconds() * 1000L);
} catch (InterruptedException e) {
listener.onFailure(new RuntimeException(e));
return;
}
}
super.listBlobsByPrefixInSortedOrder(blobNamePrefix, limit, blobNameSortOrder, listener);
}
}

class TranslogThread extends Thread {
Expand Down

0 comments on commit 60c08be

Please sign in to comment.