@@ -83,11 +83,11 @@ public void testPruneCacheWithRealData() throws Exception {
8383 }
8484
8585 assertBusy (() -> {
86- long usage = getFileCacheUsage ();
86+ long usage = getFileCacheUsage (client );
8787 assertTrue ("Cache should be populated after index access" , usage > 0 );
8888 }, 30 , TimeUnit .SECONDS );
8989
90- long usageBefore = getFileCacheUsage ();
90+ long usageBefore = getFileCacheUsage (client );
9191 logger .info ("--> File cache usage before prune: {} bytes" , usageBefore );
9292 assertTrue ("File cache should have data before prune" , usageBefore > 0 );
9393
@@ -109,7 +109,7 @@ public void testPruneCacheWithRealData() throws Exception {
109109 assertTrue ("Should have pruned bytes" , response .getTotalPrunedBytes () > 0 );
110110
111111 // Verify cache usage after prune
112- long usageAfter = getFileCacheUsage ();
112+ long usageAfter = getFileCacheUsage (client );
113113 logger .info ("--> File cache usage after prune: {} bytes" , usageAfter );
114114
115115 // Cache should be reduced (might not be zero if files are still referenced)
@@ -148,11 +148,11 @@ public void testPruneResponseMetrics() throws Exception {
148148 assertDocCount (restoredIndexName , 100L );
149149
150150 assertBusy (() -> {
151- long usage = getFileCacheUsage ();
151+ long usage = getFileCacheUsage (client );
152152 assertTrue ("Cache should be populated" , usage > 0 );
153153 }, 30 , TimeUnit .SECONDS );
154154
155- long usageBefore = getFileCacheUsage ();
155+ long usageBefore = getFileCacheUsage (client );
156156
157157 PruneFileCacheRequest request = new PruneFileCacheRequest ();
158158 PlainActionFuture <PruneFileCacheResponse > future = new PlainActionFuture <>();
@@ -170,7 +170,7 @@ public void testPruneResponseMetrics() throws Exception {
170170 assertTrue ("Node should have cache capacity" , nodeResponse .getCacheCapacity () > 0 );
171171 assertTrue ("Node should report pruned bytes" , nodeResponse .getPrunedBytes () >= 0 );
172172
173- long usageAfter = getFileCacheUsage ();
173+ long usageAfter = getFileCacheUsage (client );
174174 long expectedPruned = usageBefore - usageAfter ;
175175 assertEquals ("Response should match actual cache reduction" , expectedPruned , response .getTotalPrunedBytes ());
176176 }
@@ -261,8 +261,8 @@ private void assertRemoteSnapshotIndexSettings(Client client, String... indexNam
261261 /**
262262 * Returns total file cache usage across all warm nodes in bytes.
263263 */
264- private long getFileCacheUsage () {
265- NodesStatsResponse response = client () .admin ().cluster ().nodesStats (new NodesStatsRequest ().all ()).actionGet ();
264+ private long getFileCacheUsage (Client client ) {
265+ NodesStatsResponse response = client .admin ().cluster ().nodesStats (new NodesStatsRequest ().all ()).actionGet ();
266266
267267 long totalUsage = 0L ;
268268 for (NodeStats stats : response .getNodes ()) {
0 commit comments