From bc76db00f3996ce21cde44b0c46af6cb0cae77fb Mon Sep 17 00:00:00 2001 From: Pranav Bhaskaran <67958542+Pranav-b-7@users.noreply.github.com> Date: Tue, 30 Apr 2024 00:49:52 +0530 Subject: [PATCH] fix(test/clouddriver): Mock http error using SpinnakerHttpException in WaitForCloudFormationCompletionTaskSpec (#4717) With the introduction of the commit: 84a7106c512ceada65d7799f527a956262d964d5 , the expected behaviour of all OortService APIs is to throw SpinnakerHttpException when any http error has occurred. Here in this test the response of the API : https://github.com/spinnaker/orca/blob/a1b32d7398eb9b1ff610d7f3afd980b51f6cf7b1/orca-clouddriver/src/main/java/com/netflix/spinnaker/orca/clouddriver/OortService.java#L182 is mocked up with RetrofitError which makes the test irrelvant. Wrapping the RetrofitError in SpinnakerHttpException to make it in compliance with the retrofit configuration. Co-authored-by: Pranav-b-7 --- .../WaitForCloudFormationCompletionTaskSpec.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orca-clouddriver/src/test/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/providers/aws/cloudformation/WaitForCloudFormationCompletionTaskSpec.groovy b/orca-clouddriver/src/test/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/providers/aws/cloudformation/WaitForCloudFormationCompletionTaskSpec.groovy index 8cc96f30f7..7c8e21822d 100644 --- a/orca-clouddriver/src/test/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/providers/aws/cloudformation/WaitForCloudFormationCompletionTaskSpec.groovy +++ b/orca-clouddriver/src/test/groovy/com/netflix/spinnaker/orca/clouddriver/tasks/providers/aws/cloudformation/WaitForCloudFormationCompletionTaskSpec.groovy @@ -177,7 +177,7 @@ class WaitForCloudFormationCompletionTaskSpec extends Specification { 'kato.tasks': [[resultObjects: [[stackId: 'stackId']]]] ] def stage = new StageExecutionImpl(pipeline, 'test', 'test', context) - def error500 = RetrofitError.httpError("url", new Response("url", 500, "reason", [], null), null, null) + def error500 = new SpinnakerHttpException(RetrofitError.httpError("url", new Response("url", 500, "reason", [], null), null, null)) when: def result = waitForCloudFormationCompletionTask.execute(stage) @@ -185,7 +185,7 @@ class WaitForCloudFormationCompletionTaskSpec extends Specification { then: 1 * oortService.getCloudFormationStack('stackId') >> { throw error500 } RuntimeException ex = thrown() - ex.message == "500 reason" + ex.message == "Status: 500, URL: url, Message: reason" result == null }