Skip to content

Commit

Permalink
Fix test testWithSegmentReplication_ReplicaUsesPrimaryTranslogUUID.
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Handalian <handalm@amazon.com>
  • Loading branch information
mch2 committed Sep 5, 2022
1 parent e18fec6 commit c9fb1ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ public SafeCommitInfo getSafeCommitInfo() {

@Override
protected final void closeNoLock(String reason, CountDownLatch closedLatch) {
logger.info("Closing");
if (isClosed.compareAndSet(false, true)) {
assert rwl.isWriteLockedByCurrentThread() || failEngineLock.isHeldByCurrentThread()
: "Either the write lock must be held or the engine must be currently be failing itself";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.opensearch.index.engine.EngineFactory;
import org.opensearch.index.engine.InternalEngineFactory;
import org.opensearch.index.engine.InternalEngineTests;
import org.opensearch.index.engine.NRTReplicationEngineFactory;
import org.opensearch.index.mapper.SourceToParse;
import org.opensearch.index.replication.OpenSearchIndexLevelReplicationTestCase;
import org.opensearch.index.replication.RecoveryDuringReplicationTests;
Expand Down Expand Up @@ -106,7 +107,7 @@ public void testTranslogHistoryTransferred() throws Exception {

public void testWithSegmentReplication_ReplicaUsesPrimaryTranslogUUID() throws Exception {
Settings settings = Settings.builder().put(IndexMetadata.SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT).build();
try (ReplicationGroup shards = createGroup(2, settings)) {
try (ReplicationGroup shards = createGroup(2, settings, new NRTReplicationEngineFactory())) {
shards.startAll();
final String expectedUUID = getTranslog(shards.getPrimary()).getTranslogUUID();
assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1507,10 +1507,9 @@ public static MapperService createMapperService() throws IOException {
* Exposes a translog associated with the given engine for testing purpose.
*/
public static Translog getTranslog(Engine engine) {
assert engine instanceof InternalEngine : "only InternalEngines have translogs, got: " + engine.getClass();
InternalEngine internalEngine = (InternalEngine) engine;
internalEngine.ensureOpen();
TranslogManager translogManager = internalEngine.translogManager();
assert engine instanceof InternalEngine || engine instanceof NRTReplicationEngine : "only InternalEngines or NRTReplicationEngines have translogs, got: " + engine.getClass();
engine.ensureOpen();
TranslogManager translogManager = engine.translogManager();
assert translogManager instanceof InternalTranslogManager : "only InternalTranslogManager have translogs, got: "
+ engine.getClass();
InternalTranslogManager internalTranslogManager = (InternalTranslogManager) translogManager;
Expand Down

0 comments on commit c9fb1ed

Please sign in to comment.