yyqdbngt opened a new pull request, #4708:
URL: https://github.com/apache/rocketmq-dashboard/pull/4708
<!-- Base branch: `rocketmq-studio`, the RocketMQ Studio trunk. -->
### Related issue
No open issue covers this defect; the closed issues #2242 ([Studio] fix:
canonicalize metrics data
source configuration) and #1469 (Normalize data source identifiers
independently of JVM locale) only
canonicalized the stored configuration, they did not touch the
connection-test type gate.
### Brief Description
`server/src/main/java/org/apache/rocketmq/studio/settings/SettingsService.java:328`
— the
`type` gate of the data-source connection test strips only whitespace
(`type.replaceAll("\\s+", "")`) before looking the value up in
`PROMETHEUS_COMPATIBLE_TYPES`,
while `MetricsBackendType.fromProviderType` (the component that actually
resolves the query path for
the very same request, and that `DataSourceDTO`'s own `@Pattern` documents
as accepting
`victoria[ _]?metrics`) strips every separator (`[\\s_-]+`).
The two normalizations therefore disagree: a data source saved through
`POST/PUT /api/settings/datasources` with `type = "victoria_metrics"` passes
bean validation,
is canonicalized to `VictoriaMetrics` and queries fine, but `POST
/api/settings/datasources/test`
answers `{"success":false,"message":"Unsupported data source type:
victoria_metrics"}` without ever
issuing the probe request. The gate now strips the separators exactly like
the resolver, and keeps
its own reject-unknown behaviour on purpose (delegating to
`fromProviderType` would be wrong here,
because that method defaults unknown values to `PROMETHEUS` and
`connectionShouldRejectUnsupportedTypeTest`
asserts `rocketmq` stays rejected).
### How Did You Test This Change?
Failing test first, on the unmodified production code (new test only):
```
$ cd server && mvn -B -ntp test
-Dtest='SettingsServiceTest#connectionShouldAcceptTheProviderTypeAliasTheDataSourceApiAcceptsTest'
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[ERROR]
SettingsServiceTest.connectionShouldAcceptTheProviderTypeAliasTheDataSourceApiAcceptsTest:772
Expecting value to be true but was false
[ERROR] BUILD FAILURE
```
After the one-line normalization change:
```
$ cd server && mvn -B -ntp test -Dtest=SettingsServiceTest
[INFO] You have 0 Checkstyle violations.
[INFO] Tests run: 44, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
$ cd server && mvn -B -ntp test
'-Dtest=SettingsServiceTest,SettingsServiceCachingTest,SettingsControllerTest,DataSourceDTOTest,DataSourceTestDTOTest,DataSourceClientHttpRequestFactoryTest,MybatisPlusSettingsRepositoryTest,MetricsBackendTypeTest'
[INFO] You have 0 Checkstyle violations.
[INFO] Tests run: 89, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
Clean-tree baseline for reference: a full `mvn -B -ntp test` on an untouched
`rocketmq-studio`
checkout reports `Tests run: 3051, Failures: 6, Errors: 25, Skipped: 4` —
the 11 pre-existing red
classes are the MySQL-8-backed `AuthService*IntegrationTest`,
`HealthProbeIntegrationTest`,
`QueryHistoryServiceIntegrationTest`, `NativeAlertEvaluationTransactionTest`,
`NotificationOutboxMapperIntegrationTest`,
`RmqAlertStateMapperIntegrationTest`,
`StudioApplicationTest` and the two external-CLI agent provider tests. None
of them is in the
selection above, and the full suite is deliberately not run here. Checkstyle
stayed at
`You have 0 Checkstyle violations.` on every run.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [x] New source files carry the ASF license header
- [x] Documentation touched where behaviour changed (README / `docs/` /
in-app help)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]