@@ -99,7 +99,7 @@ public void testConcurrentAccess() throws Exception {
99
99
}
100
100
}
101
101
102
- public void testFetchBlobWithConcurrentCacheEvictions () throws Exception {
102
+ public void testFetchBlobWithConcurrentCacheEvictions () {
103
103
// Submit 256 tasks to an executor with 16 threads that will each randomly
104
104
// request one of eight blobs. Given that the cache can only hold two
105
105
// blobs this will lead to a huge amount of contention and thrashing.
@@ -114,41 +114,34 @@ public void testFetchBlobWithConcurrentCacheEvictions() throws Exception {
114
114
try (IndexInput indexInput = fetchBlobWithName (blobname )) {
115
115
assertIndexInputIsFunctional (indexInput );
116
116
}
117
+ } catch (IOException ignored ) { // fetchBlobWithName may fail due to fixed capacity
117
118
} catch (Exception e ) {
118
119
throw new AssertionError (e );
119
120
}
120
121
}));
121
122
}
122
123
// Wait for all threads to complete
123
- for (Future <?> future : futures ) {
124
- future .get (10 , TimeUnit .SECONDS );
124
+ try {
125
+ for (Future <?> future : futures ) {
126
+ future .get (10 , TimeUnit .SECONDS );
127
+ }
128
+ } catch (java .util .concurrent .ExecutionException ignored ) { // Index input may be null
129
+ } catch (Exception e ) {
130
+ throw new AssertionError (e );
125
131
}
132
+
126
133
} finally {
127
134
assertTrue (terminate (testRunner ));
128
135
}
129
136
MatcherAssert .assertThat ("Expected many evictions to happen" , fileCache .stats ().evictionCount (), greaterThan (0L ));
130
137
}
131
138
132
- public void testUsageExceedsCapacity () throws Exception {
133
- // Fetch resources that exceed the configured capacity of the cache and assert that the
134
- // returned IndexInputs are still functional.
135
- try (IndexInput i1 = fetchBlobWithName ("1" ); IndexInput i2 = fetchBlobWithName ("2" ); IndexInput i3 = fetchBlobWithName ("3" )) {
136
- assertIndexInputIsFunctional (i1 );
137
- assertIndexInputIsFunctional (i2 );
138
- assertIndexInputIsFunctional (i3 );
139
- MatcherAssert .assertThat (fileCache .usage ().activeUsage (), equalTo ((long ) EIGHT_MB * 3 ));
140
- MatcherAssert .assertThat (fileCache .usage ().usage (), equalTo ((long ) EIGHT_MB * 3 ));
141
- }
142
- MatcherAssert .assertThat (fileCache .usage ().activeUsage (), equalTo (0L ));
143
- MatcherAssert .assertThat (fileCache .usage ().usage (), equalTo ((long ) EIGHT_MB * 3 ));
144
- // Fetch another resource which will trigger an eviction
145
- try (IndexInput i1 = fetchBlobWithName ("1" )) {
146
- assertIndexInputIsFunctional (i1 );
147
- MatcherAssert .assertThat (fileCache .usage ().activeUsage (), equalTo ((long ) EIGHT_MB ));
148
- MatcherAssert .assertThat (fileCache .usage ().usage (), equalTo ((long ) EIGHT_MB ));
149
- }
150
- MatcherAssert .assertThat (fileCache .usage ().activeUsage (), equalTo (0L ));
151
- MatcherAssert .assertThat (fileCache .usage ().usage (), equalTo ((long ) EIGHT_MB ));
139
+ public void testOverflowDisabled () throws Exception {
140
+ initializeTransferManager ();
141
+ IndexInput i1 = fetchBlobWithName ("1" );
142
+ IndexInput i2 = fetchBlobWithName ("2" );
143
+
144
+ assertThrows (IOException .class , () -> { IndexInput i3 = fetchBlobWithName ("3" ); });
152
145
}
153
146
154
147
public void testDownloadFails () throws Exception {
0 commit comments