From 6eb7b8aeed547078c1aa0acdd2bdcd8f1eea7eac Mon Sep 17 00:00:00 2001 From: Levi Ramsey Date: Thu, 25 Jul 2024 11:35:34 -0400 Subject: [PATCH] tests, style --- .../src/main/resources/reference.conf | 8 ++++---- .../kubernetes/KubernetesApiSpec.scala | 14 +++++++++++++- .../PodDeletionCostAnnotatorCrSpec.scala | 3 ++- .../kubernetes/PodDeletionCostAnnotatorSpec.scala | 3 ++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/rolling-update-kubernetes/src/main/resources/reference.conf b/rolling-update-kubernetes/src/main/resources/reference.conf index 134a7b223..639cf5cce 100644 --- a/rolling-update-kubernetes/src/main/resources/reference.conf +++ b/rolling-update-kubernetes/src/main/resources/reference.conf @@ -34,10 +34,10 @@ akka.rollingupdate.kubernetes { pod-name = "" pod-name = ${?KUBERNETES_POD_NAME} - # Annotations to check to determine the revision. The first one in the list which matches - # wins. The default is suitable for "vanilla" Kubernetes Deployments, but other CI/CD systems - # may set a different annotation. - revision-annotation = [ "deployment.kubernetes.io/revision" ] + # Annotations to check to determine the revision. The first one in the list which matches + # wins. The default is suitable for "vanilla" Kubernetes Deployments, but other CI/CD systems + # may set a different annotation. + revision-annotation = [ "deployment.kubernetes.io/revision" ] secure-api-server = true diff --git a/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/KubernetesApiSpec.scala b/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/KubernetesApiSpec.scala index 3cf61e7f0..2508a36fc 100644 --- a/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/KubernetesApiSpec.scala +++ b/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/KubernetesApiSpec.scala @@ -83,7 +83,8 @@ class KubernetesApiSpec podName = podName, secure = false, apiServiceRequestTimeout = 2.seconds, - customResourceSettings = new CustomResourceSettings(enabled = false, crName = None, 60.seconds) + customResourceSettings = new CustomResourceSettings(enabled = false, crName = None, 60.seconds), + revisionAnnotations = Seq("custom.akka.io/revision", "deployment.kubernetes.io/revision") ) } @@ -167,6 +168,17 @@ class KubernetesApiSpec } } + "parse pod and replica responses to get the revision from custom annotations" in { + stubPodResponse() + stubReplicaResponse(defaultReplicaResponseJson.replaceAllLiterally("deployment.kubernetes.io", "custom.akka.io")) + + EventFilter + .info(pattern = "Reading revision from Kubernetes: akka.cluster.app-version was set to 1", occurrences = 1) + .intercept { + kubernetesApi.readRevision().futureValue should be("1") + } + } + "retry and then fail when pod not found" in { stubFor(getPod(podName1).willReturn(aResponse().withStatus(404))) EventFilter diff --git a/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/PodDeletionCostAnnotatorCrSpec.scala b/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/PodDeletionCostAnnotatorCrSpec.scala index 473f0054a..234fb5086 100644 --- a/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/PodDeletionCostAnnotatorCrSpec.scala +++ b/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/PodDeletionCostAnnotatorCrSpec.scala @@ -115,7 +115,8 @@ class PodDeletionCostAnnotatorCrSpec podName = podName, secure = false, apiServiceRequestTimeout = 2.seconds, - customResourceSettings = new CustomResourceSettings(enabled = false, crName = None, 60.seconds) + customResourceSettings = new CustomResourceSettings(enabled = false, crName = None, 60.seconds), + revisionAnnotations = Seq("deployment.kubernetes.io/revision") ) } diff --git a/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/PodDeletionCostAnnotatorSpec.scala b/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/PodDeletionCostAnnotatorSpec.scala index 4d40b57a2..dba4ee822 100644 --- a/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/PodDeletionCostAnnotatorSpec.scala +++ b/rolling-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/PodDeletionCostAnnotatorSpec.scala @@ -89,7 +89,8 @@ class PodDeletionCostAnnotatorSpec podName = podName, secure = false, apiServiceRequestTimeout = 2.seconds, - customResourceSettings = new CustomResourceSettings(enabled = false, crName = None, 60.seconds) + customResourceSettings = new CustomResourceSettings(enabled = false, crName = None, 60.seconds), + revisionAnnotations = Seq("deployment.kubernetes.io/revision") ) }