spring-cloud-netflix icon indicating copy to clipboard operation
spring-cloud-netflix copied to clipboard

Support slice testing of zuul components

Open bijukunjummen opened this issue 7 years ago • 9 comments

Supports #2419 - Slice testing of Zuul filter and properties. If this looks good I can send another PR to update the documentation.

bijukunjummen avatar Nov 11 '17 03:11 bijukunjummen

Codecov Report

Merging #2437 into master will increase coverage by 0.05%. The diff coverage is 94.11%.

Impacted file tree graph

@@            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 data Powered by Codecov. Last update 62a8f72...6eaf940. Read the comment docs.

codecov-io avatar Nov 11 '17 04:11 codecov-io

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)

bijukunjummen avatar Nov 13 '17 02:11 bijukunjummen

Is there some kind advantage to doing it this way as opposed to using spring cloud contract?

ryanjbaxter avatar Nov 13 '17 16:11 ryanjbaxter

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

bijukunjummen avatar Nov 13 '17 17:11 bijukunjummen

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?

ryanjbaxter avatar Nov 13 '17 21:11 ryanjbaxter

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

bijukunjummen avatar Nov 14 '17 03:11 bijukunjummen

Makes sense, could we get some documentation then on how its used?

ryanjbaxter avatar Nov 14 '17 17:11 ryanjbaxter

Oh yes, sounds good @ryanjbaxter, will update the PR with documentation on how to use this

bijukunjummen avatar Nov 14 '17 18:11 bijukunjummen

Added in documentation now @ryanjbaxter

bijukunjummen avatar Nov 15 '17 03:11 bijukunjummen