Add property to migrate deprecated endoint IDs

Allow legacy actuator endpoint IDs that contain dots to be transparently
migrated to the new format. This update will allow Spring Cloud users
to proactively migrate from endpoints such as `hystrix.stream` to
`hystrixstream`.

Closes gh-18148
This commit is contained in:
Phillip Webb
2019-09-24 17:56:36 -07:00
parent 0a70e33009
commit 323a78c4b9
9 changed files with 102 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.system.CapturedOutput;
import org.springframework.boot.test.system.OutputCaptureExtension;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@@ -92,6 +93,16 @@ class EndpointIdTests {
.contains("Endpoint ID 'foo-bar' contains invalid characters, please migrate to a valid format");
}
@Test
void ofWhenMigratingLegacyNameRemovesDots(CapturedOutput output) {
EndpointId.resetLoggedWarnings();
MockEnvironment environment = new MockEnvironment();
environment.setProperty("management.endpoints.migrate-legacy-ids", "true");
EndpointId endpointId = EndpointId.of(environment, "foo.bar");
assertThat(endpointId.toString()).isEqualTo("foobar");
assertThat(output).doesNotContain("contains invalid characters");
}
@Test
void equalsAndHashCode() {
EndpointId one = EndpointId.of("foobar1");