spring-cloud-netflix
spring-cloud-netflix copied to clipboard
Support slice testing of zuul components
Supports #2419 - Slice testing of Zuul filter and properties. If this looks good I can send another PR to update the documentation.
Codecov Report
Merging #2437 into master will increase coverage by
0.05%. The diff coverage is94.11%.
@@ Coverage Diff @@
## master #2437 +/- ##
==========================================
+ Coverage 68.43% 68.49% +0.05%
==========================================
Files 236 238 +2
Lines 8276 8293 +17
Branches 1027 1027
==========================================
+ Hits 5664 5680 +16
Misses 2228 2228
- Partials 384 385 +1
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...etflix/zuul/slice/ZuulTestContextBootstrapper.java | 100% <100%> (ø) |
|
| ...loud/netflix/zuul/slice/ZuulTypeExcludeFilter.java | 92.3% <92.3%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 62a8f72...6eaf940. Read the comment docs.
Note that Discovery based Ribbon ServerList is disabled for the slice test, this way there is no dependency on needing any registry for these slice tests and the target zuul endpoint needs to be explicitly specified for tests using listOfServers - serviceId.ribbon.listOfServers=localhost:${wiremock.server.port}. If we absolutely need to support Discovery for Ribbon an option could be to hook up SimpleDiscoveryClient based ServerList and use it instead(such an auto-configuration does not exist but can be added if desired)
Is there some kind advantage to doing it this way as opposed to using spring cloud contract?
Yes, good point @ryanjbaxter. S-C-Contract would assume that we have contract's defined for all downstream services that Zuul is fronting, which likely may not be available + Zuul may be used for hiding legacy services typically those may be say SOAP based services for which contracts may not be possible
The approach in the PR is to leave it to the user during test to define a stub behavior for the downstream service (using @AutoConfigureWireMock) and then test purely using MockMvc
OK maybe I misunderstood the use case. This is not for testing our Zuul implementation in SC Netflix its for testing apps using Zuul, right?
Yes, that is correct @ryanjbaxter - I faced an issue at a customer location where we added Zuul proxy to an existing application and this application uses some shared libraries with its own set of auto-configurations. Now to test the Zuul specific configuration we could exclude all the auto-configurations that the customer has OR test it by activating only Zuul specific auto-configurations.
These specific auto-configurations which worked for at the customer location are now part of this slice test
Makes sense, could we get some documentation then on how its used?
Oh yes, sounds good @ryanjbaxter, will update the PR with documentation on how to use this
Added in documentation now @ryanjbaxter