|
37 | 37 | import java.util.List; |
38 | 38 | import java.util.Map; |
39 | 39 | import java.util.Optional; |
| 40 | +import java.util.Random; |
40 | 41 | import java.util.Set; |
41 | 42 | import java.util.concurrent.atomic.AtomicBoolean; |
42 | 43 | import java.util.concurrent.atomic.AtomicLong; |
@@ -72,6 +73,8 @@ public final class RemoteStoreRefreshListener implements ReferenceManager.Refres |
72 | 73 | private final AtomicLong refreshSeqNo = new AtomicLong(); |
73 | 74 | private final Map<String, Long> fileSizeMap = new HashMap<>(); |
74 | 75 |
|
| 76 | + private final Random random = new Random(); |
| 77 | + |
75 | 78 | public RemoteStoreRefreshListener(IndexShard indexShard) { |
76 | 79 | this.indexShard = indexShard; |
77 | 80 | this.storeDirectory = indexShard.store().directory(); |
@@ -153,6 +156,15 @@ public void afterRefresh(boolean didRefresh) { |
153 | 156 | // Start tracking total uploads started |
154 | 157 | statsTracker.incrementTotalUploadsStarted(); |
155 | 158 |
|
| 159 | + // For test purpose |
| 160 | + // Step 1 - Injection artificial delay of 1s to 100s |
| 161 | + Thread.sleep(random.nextInt(100) + 1); |
| 162 | + |
| 163 | + // Step 2 - Fail 30% of requests by throwing exception |
| 164 | + if (random.nextInt(100) < 30) { |
| 165 | + throw new RuntimeException("Failing upload for test purpose"); |
| 166 | + } |
| 167 | + |
156 | 168 | // Start the segments upload |
157 | 169 | segmentsUploadStatus = UploadStatus.STARTED; |
158 | 170 | segmentsUploadStatus = uploadNewSegments(localSegmentsPostRefresh, statsTracker, sizeMap); |
|
0 commit comments