|
70 | 70 | import static org.hamcrest.Matchers.arrayWithSize;
|
71 | 71 | import static org.hamcrest.Matchers.containsString;
|
72 | 72 | import static org.hamcrest.Matchers.empty;
|
| 73 | +import static org.hamcrest.Matchers.matchesPattern; |
73 | 74 | import static org.hamcrest.Matchers.startsWith;
|
74 | 75 |
|
75 | 76 | @LuceneTestCase.SuppressFileSystems("ExtrasFS") // TODO: fix test to allow extras
|
@@ -134,25 +135,28 @@ public void testShardLock() throws Exception {
|
134 | 135 |
|
135 | 136 | try (var mockLog = MockLog.capture(NodeEnvironment.class); var lock = env.shardLock(new ShardId(index, 0), "1")) {
|
136 | 137 | mockLog.addExpectation(
|
137 |
| - new MockLog.SeenEventExpectation( |
138 |
| - "hot threads logging", |
139 |
| - NODE_ENVIRONMENT_LOGGER_NAME, |
140 |
| - Level.DEBUG, |
141 |
| - "hot threads while failing to obtain shard lock for [foo][0]: obtaining shard lock for [2] timed out after *" |
142 |
| - ) |
| 138 | + new MockLog.SeenEventExpectation("hot threads logging", NODE_ENVIRONMENT_LOGGER_NAME, Level.DEBUG, """ |
| 139 | + hot threads while failing to obtain shard lock for [foo][0]: obtaining shard lock for [2] timed out after [*ms]; \ |
| 140 | + this shard lock is still held by a different instance of the shard and has been in state [1] for [*/*ms]*""") |
143 | 141 | );
|
144 | 142 | mockLog.addExpectation(
|
145 | 143 | new MockLog.UnseenEventExpectation(
|
146 | 144 | "second attempt should be suppressed due to throttling",
|
147 | 145 | NODE_ENVIRONMENT_LOGGER_NAME,
|
148 | 146 | Level.DEBUG,
|
149 |
| - "hot threads while failing to obtain shard lock for [foo][0]: obtaining shard lock for [3] timed out after *" |
| 147 | + "*obtaining shard lock for [3] timed out*" |
150 | 148 | )
|
151 | 149 | );
|
152 | 150 |
|
153 | 151 | assertEquals(new ShardId(index, 0), lock.getShardId());
|
154 | 152 |
|
155 |
| - expectThrows(ShardLockObtainFailedException.class, () -> env.shardLock(new ShardId(index, 0), "2")); |
| 153 | + assertThat( |
| 154 | + expectThrows(ShardLockObtainFailedException.class, () -> env.shardLock(new ShardId(index, 0), "2")).getMessage(), |
| 155 | + matchesPattern(""" |
| 156 | + \\[foo]\\[0]: obtaining shard lock for \\[2] timed out after \\[0ms]; \ |
| 157 | + this shard lock is still held by a different instance of the shard \ |
| 158 | + and has been in state \\[1] for \\[.*/[0-9]+ms]""") |
| 159 | + ); |
156 | 160 |
|
157 | 161 | for (Path path : env.indexPaths(index)) {
|
158 | 162 | Files.createDirectories(path.resolve("0"));
|
|
0 commit comments