Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(deploymentmonitor): use SpinnakerRetrofitErrorHandler with D…
…eploymentMonitorService (#4628) * refactor(clouddriver/test): configure logback to log messages to make it possible to add tests that assert on the contents of log messages. orca-test has a logback-test.xml file that disables logging, so add one for orca-clouddriver that takes precedence so log messages actually get generated. Now that logging is enabled, clock.millis() is called an additional time during a test in ServerGroupCacheForceRefreshTaskSpec. * test(clouddriver): demonstrate behavior of EvaluateDeploymentHealthTask to see what changes when moving to SpinnakerRetrofitErrorHandler. Specifically, these tests verify the contents of a log message that's tightly coupled to RetrofitError. * Revert "test(MonitoredDeployBaseTask): Add tests to verify log message for different types of RetrofitError (#4608)" This reverts commit adc81ac. With the addition of EvaluateDeploymentHealthTaskTest, we have equivalent coverage that: - is in java instead of groovy - doesn't increase the visibility of getRetrofitLogMessage - more easily shows behavior changes when adopting SpinnakerRetrofitErrorHandler - is less likely to change when moving from retrofit to retrofit2 * refactor(deploymentmonitor): use SpinnakerRetrofitErrorHandler with DeploymentMonitorService Note, there's a behavior change here when http response bodies aren't json objects. Previously, the log message would, barring an exception processing the response, include the http response body in the log message. With SpinnakerHttpException, response bodies that aren't json objects aren't available, so the body appears to be empty. For example, before: 2024-01-04 12:31:59.640 WARN --- [ Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:49179/deployment/evaluateHealth, status: 400 (Bad Request) response body: non-json response} retrofit.RetrofitError: 400 Bad Request at retrofit.RetrofitError.httpError(RetrofitError.java:40) after: 2024-01-04 14:26:13.270 WARN --- [ Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:58192/deployment/evaluateHealth, status: 400 (Bad Request) response body: } com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException: Status: 400, URL: http://localhost:58192/deployment/evaluateHealth, Message: Bad Request at com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler.handleError(SpinnakerRetrofitErrorHandler.java:55) There's also a behavior change for ConversionException. before: 2024-01-04 16:03:19.363 WARN --- [ Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:60051/deployment/evaluateHealth, status: 200 (OK) headers: response body: } retrofit.RetrofitError: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.netflix.spinnaker.orca.deploymentmonitor.models.DeploymentStep` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('bogus') at [Source: (retrofit.ExceptionCatchingTypedInput$ExceptionCatchingInputStream); line: 1, column: 13] (through reference chain: com.netflix.spinnaker.orca.deploymentmonitor.models.EvaluateHealthResponse["nextStep"]) at retrofit.RetrofitError.conversionError(RetrofitError.java:33) after: 2024-01-04 16:14:03.540 WARN --- [ Test worker] n.s.o.c.t.m.EvaluateDeploymentHealthTask : [] HTTP Error encountered while talking to monitorName(monitorId)->http://localhost:59402/deployment/evaluateHealth, <NO RESPONSE>} com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerConversionException: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.netflix.spinnaker.orca.deploymentmonitor.models.DeploymentStep` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('bogus') at [Source: (retrofit.ExceptionCatchingTypedInput$ExceptionCatchingInputStream); line: 1, column: 13] (through reference chain: com.netflix.spinnaker.orca.deploymentmonitor.models.EvaluateHealthResponse["nextStep"]) at com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler.handleError(SpinnakerRetrofitErrorHandler.java:64) at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242) --------- Co-authored-by: Pranav-b-7 <[email protected]>
- Loading branch information