Skip to content

Commit

Permalink
Add test logging to debug SearchableSnapshotsLicenseIntegTests.testSh…
Browse files Browse the repository at this point in the history
…ardAllocationOnInvalidLicense (#74621)

Relates #72329
  • Loading branch information
tlrx authored Jun 28, 2021
1 parent d251d74 commit 5f8be72
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.DeleteLicenseAction;
Expand All @@ -35,6 +36,7 @@
import org.elasticsearch.license.PostStartTrialResponse;
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
import org.elasticsearch.xpack.searchablesnapshots.action.ClearSearchableSnapshotsCacheAction;
Expand Down Expand Up @@ -143,6 +145,7 @@ public void testClearCacheRequiresLicense() throws ExecutionException, Interrupt
}
}

@TestLogging(reason = "https://github.com/elastic/elasticsearch/issues/72329", value = "org.elasticsearch.license:DEBUG")
public void testShardAllocationOnInvalidLicense() throws Exception {
// check that shards have been failed as part of invalid license
assertBusy(
Expand All @@ -167,10 +170,23 @@ public void testShardAllocationOnInvalidLicense() throws Exception {
waitNoPendingTasksOnAll();
ensureClusterStateConsistency();

PostStartTrialRequest startTrialRequest = new PostStartTrialRequest().setType(License.LicenseType.TRIAL.getTypeName())
.acknowledge(true);
PostStartTrialResponse resp = client().execute(PostStartTrialAction.INSTANCE, startTrialRequest).get();
assertEquals(PostStartTrialResponse.Status.UPGRADED_TO_TRIAL, resp.getStatus());
try {
PostStartTrialRequest startTrialRequest = new PostStartTrialRequest().setType(License.LicenseType.TRIAL.getTypeName())
.acknowledge(true);
PostStartTrialResponse resp = client().execute(PostStartTrialAction.INSTANCE, startTrialRequest).get();
assertEquals(PostStartTrialResponse.Status.UPGRADED_TO_TRIAL, resp.getStatus());
} catch (AssertionError ae) {
try {
final ClusterService clusterService = internalCluster().getCurrentMasterNodeInstance(ClusterService.class);
logger.error(
"Failed to start trial license again, cluster state on master node is:\n{}",
Strings.toString(clusterService.state(), false, true)
);
} catch (Exception e) {
ae.addSuppressed(e);
}
throw ae;
}
// check if cluster goes green again after valid license has been put in place
ensureGreen(indexName);
}
Expand Down

0 comments on commit 5f8be72

Please sign in to comment.