mengw15 opened a new pull request, #7560:
URL: https://github.com/apache/texera/pull/7560
### What changes were proposed in this PR?
`ConfigServiceRunSpec` only asserted role annotations on the resource
classes, so
`ConfigService` itself was never instantiated and the file sat at 0%. Adds
four tests
that call `run()` against a mocked Dropwizard `Environment`, following
`AccessControlServiceRunSpec`. The existing role-annotation assertion is
kept.
| counter | before | after |
| --- | --- | --- |
| line | 0/30 | 13/30 |
| instruction | 0/171 | 99/171 |
| branch | 0/6 | 4/6 |
| method | 0/8 | 4/8 |
`run()` itself is now fully covered by line; every remaining missed line is
in
`initialize()` (39-51) or `object ConfigService.main` (95-108), which the
issue puts out
of scope because #5983 moves that boilerplate into a shared
`ServiceBootstrap`.
What the tests pin:
- the `/api/*` url pattern, the session handler on both the Jersey and
servlet
environments, and the `HealthCheckResource` / `ConfigResource`
registrations;
- the auth stack `AuthFeatures.register` installs — `AuthDynamicFeature`,
`UnauthorizedExceptionMapper` and `RolesAllowedDynamicFeature` — without
which `@Auth`
parameters do not resolve and `@RolesAllowed` on the settings endpoints is
ignored;
- `RequestLoggingFilter.register(environment.getApplicationContext)`,
verified as the
`addFilter(FilterHolder, "/*", …)` it performs;
- the default-settings preload, checked against the database rather than a
mock: every
entry of `DefaultsConfig.allDefaults` must be present in `site_settings`
with its value;
- that a preload failure is rethrown rather than swallowed — a service that
came up with
no settings would look healthy while serving none of them.
`run()` ends by writing `default.conf` into `site_settings`, so it needs a
live
`SqlServer`; mocking the `Environment` alone cannot reach the
request-logging filter that
follows. The suite therefore mixes in `MockTexeraDB`, which gives it its own
embedded
database and points `SqlServer` at it — `config-service` already declares
`.dependsOn(DAO % "test->test")` for exactly this, and `ConfigResourceSpec`
in the same
module already does it. The failure case swaps in a `ConnectionProvider`
that cannot
acquire a connection; `MockTexeraDB`'s fixture reinstalls the healthy
context before the
next test, so it stays local (the fixture does not truncate tables, so
dropping one would
not have).
The two branches still missed are not application logic: one on the class
declaration
(`with LazyLogging`, 3/4 arms covered) and the implicit non-`Exception` arm
of
`case ex: Exception`.
No production code was changed.
### Any related issues, documentation, discussions?
Closes #7558.
### How was this PR tested?
`sbt "ConfigService/testOnly *ConfigServiceRunSpec"` — 5 tests pass, run
repeatedly with
the same result; `sbt ConfigService/jacoco` over the module is green (38
tests) and gives
the table above. The failure path was verified by breaking the url-pattern
assertion (red,
non-zero exit) and restoring it. `ConfigService/Test/scalafmtCheck` and
`ConfigService/Test/scalafix --check` are clean.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])
--
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]