@@ -48,10 +48,8 @@ public class TransportSnapshotsStatusActionTests extends ESTestCase {
4848 private RepositoriesService repositoriesService ;
4949 private TransportSnapshotsStatusAction action ;
5050
51- @ Override
5251 @ Before
53- public void setUp () throws Exception {
54- super .setUp ();
52+ public void initializeComponents () throws Exception {
5553 threadPool = new TestThreadPool (TransportSnapshotsStatusActionTests .class .getName ());
5654 clusterService = ClusterServiceUtils .createClusterService (threadPool );
5755 transportService = new CapturingTransport ().createTransportService (
@@ -82,10 +80,8 @@ public void setUp() throws Exception {
8280 );
8381 }
8482
85- @ Override
8683 @ After
87- public void tearDown () throws Exception {
88- super .tearDown ();
84+ public void shutdownComponents () throws Exception {
8985 threadPool .shutdown ();
9086 repositoriesService .close ();
9187 transportService .close ();
@@ -103,18 +99,23 @@ public void testBuildResponseInvokesListenerWithResponseWhenTaskIsNotCancelled()
10399 private void runBasicBuildResponseTest (boolean shouldCancelTask ) {
104100 final var expectedSnapshot = new Snapshot (ProjectId .DEFAULT , "test-repo" , new SnapshotId ("snapshot" , "uuid" ));
105101 final var expectedState = SnapshotsInProgress .State .STARTED ;
102+ final var indexName = "test-index-name" ;
103+ final var indexUuid = "test-index-uuid" ;
106104 final var currentSnapshotEntries = List .of (
107105 SnapshotsInProgress .Entry .snapshot (
108106 expectedSnapshot ,
109107 randomBoolean (),
110108 randomBoolean (),
111109 SnapshotsInProgress .State .STARTED ,
112- Map .of ("index" , new IndexId ("index" , "uuid" )),
110+ Map .of (indexName , new IndexId (indexName , indexUuid )),
113111 List .of (),
114112 List .of (),
115113 randomNonNegativeLong (),
116114 randomNonNegativeLong (),
117- Map .of (new ShardId ("index" , "uuid" , 0 ), new SnapshotsInProgress .ShardSnapshotStatus ("node" , new ShardGeneration ("gen" ))),
115+ Map .of (
116+ new ShardId (indexName , indexUuid , 0 ),
117+ new SnapshotsInProgress .ShardSnapshotStatus ("node" , new ShardGeneration ("gen" ))
118+ ),
118119 null ,
119120 Map .of (),
120121 IndexVersion .current ()
@@ -132,7 +133,7 @@ private void runBasicBuildResponseTest(boolean shouldCancelTask) {
132133 assertNotNull (rsp );
133134 final var snapshotStatuses = rsp .getSnapshots ();
134135 assertNotNull (snapshotStatuses );
135- assertEquals (1 , snapshotStatuses .size ());
136+ assertEquals ("expected a single snapshot status instead of " + snapshotStatuses , 1 , snapshotStatuses .size ());
136137 final var snapshotStatus = snapshotStatuses .getFirst ();
137138 assertNotNull (snapshotStatus .getSnapshot ());
138139 assertEquals (expectedSnapshot , snapshotStatus .getSnapshot ());
@@ -142,16 +143,27 @@ private void runBasicBuildResponseTest(boolean shouldCancelTask) {
142143 assertEquals (1 , snapshotStatusShards .size ());
143144 final var snapshotStatusIndices = snapshotStatus .getIndices ();
144145 assertNotNull (snapshotStatusIndices );
145- assertEquals (1 , snapshotStatusIndices .size ());
146- assertTrue (snapshotStatusIndices .containsKey ("index" ));
146+ assertEquals (
147+ "expected a single entry in snapshotStatusIndices instead of " + snapshotStatusIndices ,
148+ 1 ,
149+ snapshotStatusIndices .size ()
150+ );
151+ assertTrue (
152+ "no entry for indexName [" + indexName + "] found in snapshotStatusIndices keyset " + snapshotStatusIndices .keySet (),
153+ snapshotStatusIndices .containsKey (indexName )
154+ );
147155 assertNotNull (snapshotStatus .getShardsStats ());
148156 };
149157
150158 final var listener = new ActionListener <SnapshotsStatusResponse >() {
151159 @ Override
152160 public void onResponse (SnapshotsStatusResponse rsp ) {
153161 if (shouldCancelTask ) {
154- fail ("expected detection of task cancellation" );
162+ fail (
163+ "expected detection of task cancellation and onFailure() instead of onResponse("
164+ + (rsp == null ? "null" : rsp .getSnapshots ())
165+ + ")"
166+ );
155167 } else {
156168 verifyResponse .accept (rsp );
157169 }
@@ -162,7 +174,7 @@ public void onFailure(Exception e) {
162174 if (shouldCancelTask ) {
163175 assertTrue (e instanceof TaskCancelledException );
164176 } else {
165- fail ("expected normal response when task is not cancelled " );
177+ fail ("expected onResponse() instead of onFailure(" + e + ") " );
166178 }
167179 }
168180 };
0 commit comments