|
9 | 9 |
|
10 | 10 | import java.nio.file.Path; |
11 | 11 | import java.security.cert.X509Certificate; |
| 12 | +import java.util.UUID; |
12 | 13 | import java.util.concurrent.TimeUnit; |
13 | 14 | import java.util.function.Function; |
14 | 15 | import org.junit.jupiter.api.AfterAll; |
@@ -131,7 +132,7 @@ private void testServerSsl( |
131 | 132 | } |
132 | 133 |
|
133 | 134 | @ParameterizedTest |
134 | | - @EnumSource(value = JmxScraperContainer.ConfigSource.class) |
| 135 | + @EnumSource |
135 | 136 | void serverSslClientSsl(JmxScraperContainer.ConfigSource configSource) { |
136 | 137 | // Note: this could have been made simpler by relying on the fact that keystore could be used |
137 | 138 | // as a trust store, but having clear split provides also some extra clarity |
@@ -175,6 +176,39 @@ void serverSslClientSsl(JmxScraperContainer.ConfigSource configSource) { |
175 | 176 | .withConfigSource(configSource)); |
176 | 177 | } |
177 | 178 |
|
| 179 | + @Test |
| 180 | + void stableServiceInstanceServiceId() { |
| 181 | + UUID expectedServiceId = null; |
| 182 | + |
| 183 | + // start a single app, connect twice to it and check that the service id is the same |
| 184 | + try (TestAppContainer app = appContainer().withJmxPort(JMX_PORT)) { |
| 185 | + app.start(); |
| 186 | + for (int i = 0; i < 2; i++) { |
| 187 | + try (JmxScraperContainer scraper = |
| 188 | + scraperContainer() |
| 189 | + .withRmiServiceUrl(APP_HOST, JMX_PORT) |
| 190 | + // does not need to be tested on all config sources |
| 191 | + .withConfigSource(JmxScraperContainer.ConfigSource.SYSTEM_PROPERTIES)) { |
| 192 | + scraper.start(); |
| 193 | + waitTerminated(scraper); |
| 194 | + String[] logLines = scraper.getLogs().split("\n"); |
| 195 | + UUID serviceId = null; |
| 196 | + for (String logLine : logLines) { |
| 197 | + if (logLine.contains("remote service instance ID")) { |
| 198 | + serviceId = UUID.fromString(logLine.substring(logLine.lastIndexOf(":") + 1).trim()); |
| 199 | + } |
| 200 | + } |
| 201 | + assertThat(serviceId).isNotNull(); |
| 202 | + if (expectedServiceId == null) { |
| 203 | + expectedServiceId = serviceId; |
| 204 | + } else { |
| 205 | + assertThat(serviceId).isEqualTo(expectedServiceId); |
| 206 | + } |
| 207 | + } |
| 208 | + } |
| 209 | + } |
| 210 | + } |
| 211 | + |
178 | 212 | private static void connectionTest( |
179 | 213 | Function<TestAppContainer, TestAppContainer> customizeApp, |
180 | 214 | Function<JmxScraperContainer, JmxScraperContainer> customizeScraper) { |
|
0 commit comments