From 39704a4fe8d1982e29e194c1eff4c194827520c9 Mon Sep 17 00:00:00 2001 From: "nikita.smirnov" Date: Fri, 13 Sep 2024 15:14:42 +0400 Subject: [PATCH] [TH2-5226] added 'enable component (min configuration)' test --- .../operator/AbstractTh2Operator.java | 50 ++++++++------- .../util/CustomResourceUtils.java | 46 ++------------ .../util/CustomResourceUtilsTests.java | 62 ++++-------------- .../integration/IntegrationTest.kt | 63 ++++++++++++++++--- .../integration/TestKubernetesUtils.kt | 4 +- .../integration/TestRabbitMQUtils.kt | 2 +- 6 files changed, 104 insertions(+), 123 deletions(-) diff --git a/src/main/java/com/exactpro/th2/infraoperator/operator/AbstractTh2Operator.java b/src/main/java/com/exactpro/th2/infraoperator/operator/AbstractTh2Operator.java index dd9eb554..8eb5bd82 100644 --- a/src/main/java/com/exactpro/th2/infraoperator/operator/AbstractTh2Operator.java +++ b/src/main/java/com/exactpro/th2/infraoperator/operator/AbstractTh2Operator.java @@ -27,7 +27,6 @@ import com.exactpro.th2.infraoperator.spec.strategy.redeploy.NonTerminalException; import com.exactpro.th2.infraoperator.spec.strategy.redeploy.RetryableTaskQueue; import com.exactpro.th2.infraoperator.spec.strategy.redeploy.tasks.TriggerRedeployTask; -import com.exactpro.th2.infraoperator.util.CustomResourceUtils; import io.fabric8.kubernetes.api.model.HasMetadata; import io.fabric8.kubernetes.api.model.OwnerReference; import io.fabric8.kubernetes.api.model.OwnerReferenceBuilder; @@ -48,6 +47,8 @@ import java.util.concurrent.ConcurrentHashMap; import static com.exactpro.th2.infraoperator.operator.HelmReleaseTh2Op.ANTECEDENT_LABEL_KEY_ALIAS; +import static com.exactpro.th2.infraoperator.util.CustomResourceUtils.annotationFor; +import static com.exactpro.th2.infraoperator.util.CustomResourceUtils.extractHashedName; import static com.exactpro.th2.infraoperator.util.ExtractUtils.extractName; import static com.exactpro.th2.infraoperator.util.ExtractUtils.extractNamespace; import static com.exactpro.th2.infraoperator.util.KubernetesUtils.isNotActive; @@ -74,7 +75,7 @@ protected AbstractTh2Operator(KubernetesClient kubClient) { @Override public void eventReceived(Action action, CR resource) { - String resourceLabel = CustomResourceUtils.annotationFor(resource); + String resourceLabel = annotationFor(resource); try { var cachedFingerprint = fingerprints.get(resourceLabel); @@ -148,7 +149,7 @@ protected HelmRelease loadKubObj() { protected void processEvent(Action action, CR resource) throws IOException { - String resourceLabel = CustomResourceUtils.annotationFor(resource); + String resourceLabel = annotationFor(resource); logger.debug("Processing event {} for \"{}\"", action, resourceLabel); if (resource.getSpec().getDisabled()) { @@ -156,13 +157,20 @@ protected void processEvent(Action action, CR resource) throws IOException { deletedEvent(resource); // TODO: work with Th2CustomResource should be encapsulated somewhere // to void issues with choosing the right function to extract the name - Resource helmRelease = kubClient.resources(HelmRelease.class) - .inNamespace(extractNamespace(resource)) + String namespace = extractNamespace(resource); + String helmReleaseName = extractHashedName(resource); + Resource helmReleaseResource = kubClient.resources(HelmRelease.class) + .inNamespace(namespace) // name must be hashed if it exceeds the limit - .withName(CustomResourceUtils.extractHashedName(resource)); - String helmReleaseLabel = CustomResourceUtils.annotationFor(helmRelease.get()); - helmRelease.delete(); - logger.info("Resource \"{}\" has been deleted", helmReleaseLabel); + .withName(helmReleaseName); + HelmRelease helmRelease = helmReleaseResource.get(); + if (helmRelease == null) { + logger.info("Resource \"{}\" hasn't been deleted because it already doesn't exist", annotationFor(namespace, helmReleaseName, HelmRelease.class.getSimpleName())); + } else { + String helmReleaseLabel = annotationFor(helmRelease); + helmReleaseResource.delete(); + logger.info("Resource \"{}\" has been deleted", helmReleaseLabel); + } resource.getStatus().disabled("Resource has been disabled"); logger.info("Resource \"{}\" has been disabled, executing DELETE action", resourceLabel); updateStatus(resource); @@ -215,23 +223,23 @@ protected void deletedEvent(CR resource) { // kubernetes objects will be removed when custom resource removed (through 'OwnerReference') - String resourceLabel = CustomResourceUtils.annotationFor(resource); + String resourceLabel = annotationFor(resource); fingerprints.remove(resourceLabel); // The HelmRelease name is hashed if Th2CustomResource name exceeds the limit OperatorState.INSTANCE.removeHelmReleaseFromCache( - CustomResourceUtils.extractHashedName(resource), + extractHashedName(resource), extractNamespace(resource) ); } protected void errorEvent(CR resource) { - String resourceLabel = CustomResourceUtils.annotationFor(resource); + String resourceLabel = annotationFor(resource); fingerprints.remove(resourceLabel); } protected CR updateStatus(CR resource) { - String resourceLabel = CustomResourceUtils.annotationFor(resource); + String resourceLabel = annotationFor(resource); var resClient = getResourceClient().getInstance(); try { @@ -273,9 +281,7 @@ protected void setupAndCreateKubObj(CR resource) { createKubObj(extractNamespace(resource), kubObj); - logger.info("Generated \"{}\" based on \"{}\"" - , CustomResourceUtils.annotationFor(kubObj) - , CustomResourceUtils.annotationFor(resource)); + logger.info("Generated \"{}\" based on \"{}\"" , annotationFor(kubObj) , annotationFor(resource)); String kubObjType = kubObj.getClass().getSimpleName(); @@ -289,14 +295,14 @@ protected void setupKubObj(CR resource, HelmRelease helmRelease) { mapProperties(resource, helmRelease); logger.info("Generated additional properties from \"{}\" for the resource \"{}\"" - , CustomResourceUtils.annotationFor(resource) - , CustomResourceUtils.annotationFor(helmRelease)); + , annotationFor(resource) + , annotationFor(helmRelease)); helmRelease.getMetadata().setOwnerReferences(List.of(createOwnerReference(resource))); logger.info("Property \"OwnerReference\" with reference to \"{}\" has been set for the resource \"{}\"" - , CustomResourceUtils.annotationFor(resource) - , CustomResourceUtils.annotationFor(helmRelease)); + , annotationFor(resource) + , annotationFor(helmRelease)); } @@ -305,8 +311,8 @@ protected void mapProperties(CR resource, HelmRelease helmRelease) { var kubObjMD = helmRelease.getMetadata(); var resMD = resource.getMetadata(); String resName = resMD.getName(); - String annotation = CustomResourceUtils.annotationFor(resource); - String finalName = CustomResourceUtils.extractHashedName(resource); + String annotation = annotationFor(resource); + String finalName = extractHashedName(resource); if (!finalName.equals(resName)) { logger.info("Name of resource \"{}\" exceeds limitations. Will be substituted with \"{}\"", diff --git a/src/main/java/com/exactpro/th2/infraoperator/util/CustomResourceUtils.java b/src/main/java/com/exactpro/th2/infraoperator/util/CustomResourceUtils.java index a832eb6a..b458e2bd 100644 --- a/src/main/java/com/exactpro/th2/infraoperator/util/CustomResourceUtils.java +++ b/src/main/java/com/exactpro/th2/infraoperator/util/CustomResourceUtils.java @@ -19,18 +19,14 @@ import com.exactpro.th2.infraoperator.spec.Th2CustomResource; import com.exactpro.th2.infraoperator.spec.helmrelease.HelmRelease; import io.fabric8.kubernetes.api.model.HasMetadata; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.List; -import java.util.Objects; import static com.exactpro.th2.infraoperator.util.ExtractUtils.extractName; -import static com.exactpro.th2.infraoperator.util.ExtractUtils.extractNamespace; -import static com.exactpro.th2.infraoperator.util.ExtractUtils.extractType; public class CustomResourceUtils { @@ -53,7 +49,7 @@ public static String annotationFor(String namespace, String kind, String resourc return String.format("%s:%s/%s(commit-%s)", namespace, kind, resourceName, commitHash); } - public static String annotationFor(HasMetadata resource) { + public static String annotationFor(@NotNull HasMetadata resource) { return annotationFor( resource.getMetadata().getNamespace(), resource.getKind(), @@ -62,47 +58,15 @@ public static String annotationFor(HasMetadata resource) { ); } - @Nullable - public static HelmRelease search(List helmReleases, Th2CustomResource resource) { - String resFullName = extractHashedFullName(resource); - return helmReleases.stream() - .filter(hr -> { - var owner = extractOwnerFullName(hr); - return Objects.nonNull(owner) && owner.equals(resFullName); - }).findFirst() - .orElse(null); - } - public static String extractHashedName(Th2CustomResource customResource) { return hashNameIfNeeded(extractName(customResource)); } - private static String extractHashedFullName(Th2CustomResource customResource) { - return concatFullName(extractNamespace(customResource), extractHashedName(customResource)); - } - - @Nullable - private static String extractOwnerFullName(HelmRelease helmRelease) { - var ownerReferences = helmRelease.getMetadata().getOwnerReferences(); - if (!ownerReferences.isEmpty()) { - return concatFullName(extractNamespace(helmRelease), ownerReferences.get(0).getName()); - } else { - logger.warn("[{}<{}>] doesn't have owner resource", extractType(helmRelease), extractFullName(helmRelease)); - return null; - } - } - - private static String extractFullName(HasMetadata obj) { - return concatFullName(extractNamespace(obj), extractName(obj)); - } - - private static String concatFullName(String namespace, String name) { - return namespace + "." + name; - } - public static String hashNameIfNeeded(String resName) { if (resName.length() >= HelmRelease.NAME_LENGTH_LIMIT) { - return digest(resName); + String result = digest(resName); + logger.debug("Resource '{}' name has been hashed to '{}'", resName, result); + return result; } return resName; } diff --git a/src/test/java/com/exactpro/th2/infraoperator/util/CustomResourceUtilsTests.java b/src/test/java/com/exactpro/th2/infraoperator/util/CustomResourceUtilsTests.java index de96bf7c..96c0259b 100644 --- a/src/test/java/com/exactpro/th2/infraoperator/util/CustomResourceUtilsTests.java +++ b/src/test/java/com/exactpro/th2/infraoperator/util/CustomResourceUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2021 Exactpro (Exactpro Systems Limited) + * Copyright 2021-2024 Exactpro (Exactpro Systems Limited) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,74 +16,36 @@ package com.exactpro.th2.infraoperator.util; +import com.exactpro.th2.infraoperator.spec.Th2CustomResource; +import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.ObjectMeta; +import org.junit.jupiter.api.Test; + import static com.exactpro.th2.infraoperator.spec.helmrelease.HelmRelease.NAME_LENGTH_LIMIT; import static com.exactpro.th2.infraoperator.util.CustomResourceUtils.digest; import static com.exactpro.th2.infraoperator.util.CustomResourceUtils.extractHashedName; -import static com.exactpro.th2.infraoperator.util.CustomResourceUtils.search; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.Test; - -import com.exactpro.th2.infraoperator.spec.Th2CustomResource; -import com.exactpro.th2.infraoperator.spec.helmrelease.HelmRelease; - -import io.fabric8.kubernetes.api.model.HasMetadata; -import io.fabric8.kubernetes.api.model.ObjectMeta; -import io.fabric8.kubernetes.api.model.OwnerReference; - class CustomResourceUtilsTests { - private final String sourceNamespace = "namespace"; + private static final String SOURCE_NAMESPACE = "namespace"; - private final String sourceName = "123456789_123456789_123456789"; + private static final String SOURCE_NAME = "123456789_123456789_123456789"; @Test void extractHashedNameTest() { - var currentName = sourceName.substring(0, NAME_LENGTH_LIMIT - 1); + var currentName = SOURCE_NAME.substring(0, NAME_LENGTH_LIMIT - 1); assertEquals(currentName, extractHashedName(createTh2CustomResource(currentName))); - currentName = sourceName.substring(0, NAME_LENGTH_LIMIT); + currentName = SOURCE_NAME.substring(0, NAME_LENGTH_LIMIT); assertEquals(digest(currentName), extractHashedName(createTh2CustomResource(currentName))); - currentName = sourceName.substring(0, NAME_LENGTH_LIMIT + 1); + currentName = SOURCE_NAME.substring(0, NAME_LENGTH_LIMIT + 1); assertEquals(digest(currentName), extractHashedName(createTh2CustomResource(currentName))); } - @Test - void searchTest() { - List helmReleases = new ArrayList<>(); - helmReleases.add(createHelmRelease(sourceName.substring(0, NAME_LENGTH_LIMIT - 1))); - helmReleases.add(createHelmRelease(digest(sourceName.substring(0, NAME_LENGTH_LIMIT)))); - helmReleases.add(createHelmRelease(digest(sourceName.substring(0, NAME_LENGTH_LIMIT + 1)))); - - var th2CustomResource = createTh2CustomResource(sourceName.substring(0, NAME_LENGTH_LIMIT - 1)); - assertEquals(helmReleases.get(0), search(helmReleases, th2CustomResource)); - - th2CustomResource = createTh2CustomResource(sourceName.substring(0, NAME_LENGTH_LIMIT)); - assertEquals(helmReleases.get(1), search(helmReleases, th2CustomResource)); - - th2CustomResource = createTh2CustomResource(sourceName.substring(0, NAME_LENGTH_LIMIT + 1)); - assertEquals(helmReleases.get(2), search(helmReleases, th2CustomResource)); - } - - private HelmRelease createHelmRelease(String name) { - HelmRelease helmRelease = createResource(HelmRelease.class, name); - - List ownerReferences = new ArrayList<>(); - var ownerReference = new OwnerReference(); - ownerReference.setName(name); - ownerReferences.add(ownerReference); - - when(helmRelease.getMetadata().getOwnerReferences()).thenReturn(ownerReferences); - - return helmRelease; - } - private Th2CustomResource createTh2CustomResource(String name) { return createResource(Th2CustomResource.class, name); } @@ -91,7 +53,7 @@ private Th2CustomResource createTh2CustomResource(String name) { private T createResource(Class instanceClass, String name) { T resource = mock(instanceClass); ObjectMeta metaData = mock(ObjectMeta.class); - when(metaData.getNamespace()).thenReturn(sourceNamespace); + when(metaData.getNamespace()).thenReturn(SOURCE_NAMESPACE); when(metaData.getName()).thenReturn(name); when(resource.getMetadata()).thenReturn(metaData); diff --git a/src/test/kotlin/com/exactpro/th2/infraoperator/integration/IntegrationTest.kt b/src/test/kotlin/com/exactpro/th2/infraoperator/integration/IntegrationTest.kt index 583e5416..c71c9b77 100644 --- a/src/test/kotlin/com/exactpro/th2/infraoperator/integration/IntegrationTest.kt +++ b/src/test/kotlin/com/exactpro/th2/infraoperator/integration/IntegrationTest.kt @@ -58,10 +58,15 @@ import com.exactpro.th2.infraoperator.operator.manager.impl.ConfigMapEventHandle import com.exactpro.th2.infraoperator.operator.manager.impl.ConfigMapEventHandler.LOGGING_CM_NAME import com.exactpro.th2.infraoperator.operator.manager.impl.ConfigMapEventHandler.MQ_ROUTER_CM_NAME import com.exactpro.th2.infraoperator.operator.manager.impl.Th2DictionaryEventHandler.DICTIONARY_SUFFIX +import com.exactpro.th2.infraoperator.spec.box.Th2Box +import com.exactpro.th2.infraoperator.spec.corebox.Th2CoreBox +import com.exactpro.th2.infraoperator.spec.estore.Th2Estore import com.exactpro.th2.infraoperator.spec.helmrelease.HelmRelease import com.exactpro.th2.infraoperator.spec.helmrelease.HelmRelease.NAME_LENGTH_LIMIT +import com.exactpro.th2.infraoperator.spec.mstore.Th2Mstore import com.exactpro.th2.infraoperator.spec.shared.PrometheusConfiguration -import com.exactpro.th2.infraoperator.spec.shared.status.RolloutPhase +import com.exactpro.th2.infraoperator.spec.shared.status.RolloutPhase.DISABLED +import com.exactpro.th2.infraoperator.spec.shared.status.RolloutPhase.SUCCEEDED import com.exactpro.th2.infraoperator.spec.strategy.linkresolver.createEstoreQueue import com.exactpro.th2.infraoperator.spec.strategy.linkresolver.createMstoreQueue import com.exactpro.th2.infraoperator.spec.strategy.linkresolver.mq.RabbitMQContext @@ -231,6 +236,7 @@ class IntegrationTest { fun `add mstore`() { val gitHash = RESOURCE_GIT_HASH_COUNTER.incrementAndGet().toString() kubeClient.createTh2Mstore(TH2_NAMESPACE, MESSAGE_STORAGE_BOX_ALIAS, createAnnotations(gitHash, TEST_CONTENT)) + kubeClient.awaitPhase(TH2_NAMESPACE, MESSAGE_STORAGE_BOX_ALIAS, Th2Mstore::class.java, SUCCEEDED) kubeClient.awaitHelmRelease(TH2_NAMESPACE, MESSAGE_STORAGE_BOX_ALIAS) // FIXME: estore should have binding // println("Bindings: ${rabbitMQClient.getQueueBindings(RABBIT_MQ_V_HOST, createEstoreQueue(TH2_NAMESPACE))}") @@ -241,6 +247,7 @@ class IntegrationTest { fun `add estore`() { val gitHash = RESOURCE_GIT_HASH_COUNTER.incrementAndGet().toString() kubeClient.createTh2Estore(TH2_NAMESPACE, EVENT_STORAGE_BOX_ALIAS, createAnnotations(gitHash, TEST_CONTENT)) + kubeClient.awaitPhase(TH2_NAMESPACE, EVENT_STORAGE_BOX_ALIAS, Th2Estore::class.java, SUCCEEDED) kubeClient.awaitHelmRelease(TH2_NAMESPACE, EVENT_STORAGE_BOX_ALIAS) rabbitMQClient.assertBindings( createEstoreQueue(TH2_NAMESPACE), @@ -262,12 +269,8 @@ class IntegrationTest { type: th2-rpt-data-provider """.trimIndent() - kubeClient.createTh2CoreBox( - TH2_NAMESPACE, - name, - createAnnotations(gitHash, spec.hashCode().toString()), - spec - ) + kubeClient.createTh2CoreBox(TH2_NAMESPACE, name, createAnnotations(gitHash, spec.hashCode().toString()), spec) + kubeClient.awaitPhase(TH2_NAMESPACE, name, Th2CoreBox::class.java, SUCCEEDED) kubeClient.awaitHelmRelease(TH2_NAMESPACE, hashNameIfNeeded(name)).assertMinCfg(name) rabbitMQClient.assertBindings( createEstoreQueue(TH2_NAMESPACE), @@ -291,6 +294,7 @@ class IntegrationTest { """.trimIndent() kubeClient.createTh2Box(TH2_NAMESPACE, name, createAnnotations(gitHash, spec.hashCode().toString()), spec) + kubeClient.awaitPhase(TH2_NAMESPACE, name, Th2Box::class.java, SUCCEEDED) kubeClient.awaitHelmRelease(TH2_NAMESPACE, hashNameIfNeeded(name)).assertMinCfg(name) rabbitMQClient.assertBindings( createEstoreQueue(TH2_NAMESPACE), @@ -315,6 +319,7 @@ class IntegrationTest { """.trimIndent() kubeClient.createTh2Box(TH2_NAMESPACE, name, createAnnotations(gitHash, spec.hashCode().toString()), spec) + kubeClient.awaitPhase(TH2_NAMESPACE, name, Th2Box::class.java, SUCCEEDED) kubeClient.awaitHelmRelease(TH2_NAMESPACE, hashNameIfNeeded(name)).assertMinCfg(name) rabbitMQClient.assertBindings( createEstoreQueue(TH2_NAMESPACE), @@ -334,8 +339,50 @@ class IntegrationTest { """.trimIndent() kubeClient.modifyTh2Box(TH2_NAMESPACE, name, createAnnotations(gitHash, spec.hashCode().toString()), spec) + kubeClient.awaitPhase(TH2_NAMESPACE, name, Th2Box::class.java, DISABLED) + kubeClient.awaitNoHelmRelease(TH2_NAMESPACE, name) + rabbitMQClient.assertBindings( + createEstoreQueue(TH2_NAMESPACE), + RABBIT_MQ_V_HOST, + setOf( + "link[$TH2_NAMESPACE:$EVENT_STORAGE_BOX_ALIAS:$EVENT_STORAGE_PIN_ALIAS]", + "key[$TH2_NAMESPACE:$name:$EVENT_STORAGE_PIN_ALIAS]" + ) + ) + } + + @Timeout(30_000) + @ParameterizedTest + @ValueSource(strings = ["th2-component", "th2-component-more-than-$NAME_LENGTH_LIMIT-characters"]) + fun `enabled component (min configuration)`(name: String) { + var gitHash = RESOURCE_GIT_HASH_COUNTER.incrementAndGet().toString() + var spec = """ + imageName: $IMAGE + imageVersion: $VERSION + type: th2-codec + disabled: true + """.trimIndent() + + kubeClient.createTh2Box(TH2_NAMESPACE, name, createAnnotations(gitHash, spec.hashCode().toString()), spec) + kubeClient.awaitPhase(TH2_NAMESPACE, name, Th2Box::class.java, DISABLED) kubeClient.awaitNoHelmRelease(TH2_NAMESPACE, name) - kubeClient.awaitPhase(TH2_NAMESPACE, name, RolloutPhase.DISABLED) + rabbitMQClient.assertBindings( + createEstoreQueue(TH2_NAMESPACE), + RABBIT_MQ_V_HOST, + setOf("link[$TH2_NAMESPACE:$EVENT_STORAGE_BOX_ALIAS:$EVENT_STORAGE_PIN_ALIAS]") + ) + + gitHash = RESOURCE_GIT_HASH_COUNTER.incrementAndGet().toString() + spec = """ + imageName: $IMAGE + imageVersion: $VERSION + type: th2-codec + disabled: false + """.trimIndent() + + kubeClient.modifyTh2Box(TH2_NAMESPACE, name, createAnnotations(gitHash, spec.hashCode().toString()), spec) + kubeClient.awaitPhase(TH2_NAMESPACE, name, Th2Box::class.java, SUCCEEDED) + kubeClient.awaitHelmRelease(TH2_NAMESPACE, hashNameIfNeeded(name)).assertMinCfg(name) rabbitMQClient.assertBindings( createEstoreQueue(TH2_NAMESPACE), RABBIT_MQ_V_HOST, diff --git a/src/test/kotlin/com/exactpro/th2/infraoperator/integration/TestKubernetesUtils.kt b/src/test/kotlin/com/exactpro/th2/infraoperator/integration/TestKubernetesUtils.kt index e60a3f17..3377aeff 100644 --- a/src/test/kotlin/com/exactpro/th2/infraoperator/integration/TestKubernetesUtils.kt +++ b/src/test/kotlin/com/exactpro/th2/infraoperator/integration/TestKubernetesUtils.kt @@ -17,6 +17,7 @@ package com.exactpro.th2.infraoperator.integration import com.exactpro.th2.infraoperator.operator.manager.impl.ConfigMapEventHandler.SECRET_TYPE_OPAQUE +import com.exactpro.th2.infraoperator.spec.Th2CustomResource import com.exactpro.th2.infraoperator.spec.Th2Spec import com.exactpro.th2.infraoperator.spec.box.Th2Box import com.exactpro.th2.infraoperator.spec.corebox.Th2CoreBox @@ -151,13 +152,14 @@ fun KubernetesClient.deleteConfigMap( fun KubernetesClient.awaitPhase( namespace: String, name: String, + resourceType: Class, phase: RolloutPhase, timeout: Long = 5_000, unit: TimeUnit = TimeUnit.MILLISECONDS, ) { await("awaitStatus ($name $phase)") .timeout(timeout, unit) - .until { resources(Th2Box::class.java)?.inNamespace(namespace)?.withName(name)?.get()?.status?.phase == phase } + .until { resources(resourceType)?.inNamespace(namespace)?.withName(name)?.get()?.status?.phase == phase } } fun KubernetesClient.createTh2Mstore( diff --git a/src/test/kotlin/com/exactpro/th2/infraoperator/integration/TestRabbitMQUtils.kt b/src/test/kotlin/com/exactpro/th2/infraoperator/integration/TestRabbitMQUtils.kt index 00ce9b4a..7de1ed76 100644 --- a/src/test/kotlin/com/exactpro/th2/infraoperator/integration/TestRabbitMQUtils.kt +++ b/src/test/kotlin/com/exactpro/th2/infraoperator/integration/TestRabbitMQUtils.kt @@ -123,7 +123,7 @@ fun Client.assertBindings( timeout: Long = 5_000, unit: TimeUnit = TimeUnit.MILLISECONDS, ) { - await("assertBindings('$queue'), bindings: $routingKeys") + await("assertBindings('$queue'), routing keys: $routingKeys") .timeout(timeout, unit) .until { getQueueBindings(vHost, queue).size == routingKeys.size }