Skip to content

Commit

Permalink
Remove test that cannot live with assertion error.
Browse files Browse the repository at this point in the history
  • Loading branch information
henningandersen committed Jan 16, 2020
1 parent 2b24d57 commit 0dae4f4
Showing 1 changed file with 0 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

package org.elasticsearch.action.admin.indices.create;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.UnavailableShardsException;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
Expand All @@ -35,9 +32,7 @@
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.service.ClusterApplierService;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentFactory;
Expand All @@ -49,7 +44,6 @@
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.MockLogAppender;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -384,48 +378,4 @@ public void testIndexNameInResponse() {

assertEquals("Should have index name in response", "foo", response.index());
}

/**
* Test that when creating a new index successfully, a failure in the ActionListener's onResponse does not result in a call to
* onFailure. It is the responsibility of the caller to handle exceptions in the ActionListener's onResponse and onFailure methods.
*/
public void testOnResponseFailureOnMaster() throws Exception {
final String exceptionMessage = randomAlphaOfLength(10);
final Logger logger = LogManager.getLogger(ClusterApplierService.class);
final MockLogAppender appender = new MockLogAppender();
appender.start();
appender.addExpectation(
new MockLogAppender.ExceptionSeenEventExpectation(
getTestName(),
logger.getName(),
Level.WARN,
"failed to notify ClusterStateListener",
TestException.class,
exceptionMessage));
try {
Loggers.addAppender(logger, appender);

internalCluster().masterClient().admin().indices().prepareCreate("test").execute(new ActionListener<>() {
@Override
public void onResponse(CreateIndexResponse response) {
throw new TestException(exceptionMessage);
}

@Override
public void onFailure(Exception e) {
fail();
}
});
assertBusy(appender::assertAllExpectationsMatched);
} finally {
Loggers.removeAppender(logger, appender);
appender.stop();
}
}

private static class TestException extends RuntimeException {
TestException(String message) {
super(message);
}
}
}

0 comments on commit 0dae4f4

Please sign in to comment.