From 69da9aafd9fb19bdfadb3e76997ab8b0e4077b6b Mon Sep 17 00:00:00 2001 From: David Kornel Date: Wed, 7 Aug 2024 15:59:31 +0200 Subject: [PATCH] Change ResoruceItem API of query for ready and deleted resoruce (#160) ## Description Change ResoruceItem API methods to isReady and isDeleted ## Type of Change Please delete options that are not relevant. * Breaking change (fix or feature that would cause existing functionality to not work as expected) ## Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit/integration tests pass locally with my changes Signed-off-by: David Kornel --- .../io/skodjob/testframe/interfaces/ResourceType.java | 8 ++++---- .../io/skodjob/testframe/resources/ResourceCondition.java | 2 +- .../testframe/resources/ClusterRoleBindingType.java | 4 ++-- .../io/skodjob/testframe/resources/ClusterRoleType.java | 4 ++-- .../io/skodjob/testframe/resources/ConfigMapType.java | 4 ++-- .../testframe/resources/CustomResourceDefinitionType.java | 4 ++-- .../io/skodjob/testframe/resources/DeploymentType.java | 4 ++-- .../main/java/io/skodjob/testframe/resources/JobType.java | 4 ++-- .../java/io/skodjob/testframe/resources/LeaseType.java | 4 ++-- .../io/skodjob/testframe/resources/NamespaceType.java | 4 ++-- .../io/skodjob/testframe/resources/NetworkPolicyType.java | 4 ++-- .../io/skodjob/testframe/resources/RoleBindingType.java | 4 ++-- .../java/io/skodjob/testframe/resources/RoleType.java | 4 ++-- .../java/io/skodjob/testframe/resources/SecretType.java | 4 ++-- .../skodjob/testframe/resources/ServiceAccountType.java | 4 ++-- .../java/io/skodjob/testframe/resources/ServiceType.java | 4 ++-- .../resources/ValidatingWebhookConfigurationType.java | 4 ++-- .../io/skodjob/testframe/resources/InstallPlanType.java | 4 ++-- .../io/skodjob/testframe/resources/OperatorGroupType.java | 4 ++-- .../io/skodjob/testframe/resources/SubscriptionType.java | 4 ++-- 20 files changed, 41 insertions(+), 41 deletions(-) diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/ResourceType.java b/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/ResourceType.java index b33f45e..ed53f85 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/ResourceType.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/interfaces/ResourceType.java @@ -61,18 +61,18 @@ public interface ResourceType { void replace(String resourceName, Consumer editor); /** - * Waits for {@link T} to be ready (created/running) + * Confirms that {@link T} is ready (created/running) * * @param resource resource * @return result of the readiness check */ - boolean waitForReadiness(T resource); + boolean isReady(T resource); /** - * Waits for {@link T} to be deleted + * Confirms that {@link T} is deleted * * @param resource resource * @return result of the deletion */ - boolean waitForDeletion(T resource); + boolean isDeleted(T resource); } diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceCondition.java b/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceCondition.java index 1182664..d15e310 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceCondition.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/resources/ResourceCondition.java @@ -27,7 +27,7 @@ public record ResourceCondition(Predicate predicate, S * @return The ResourceCondition representing readiness. */ public static ResourceCondition readiness(ResourceType type) { - return new ResourceCondition<>(type::waitForReadiness, "readiness"); + return new ResourceCondition<>(type::isReady, "readiness"); } /** diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleBindingType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleBindingType.java index 65331a4..64e9f98 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleBindingType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleBindingType.java @@ -98,7 +98,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(ClusterRoleBinding resource) { + public boolean isReady(ClusterRoleBinding resource) { return resource != null; } @@ -109,7 +109,7 @@ public boolean waitForReadiness(ClusterRoleBinding resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(ClusterRoleBinding resource) { + public boolean isDeleted(ClusterRoleBinding resource) { return resource == null; } } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleType.java index 35d7315..c77aed6 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ClusterRoleType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(ClusterRole resource) { + public boolean isReady(ClusterRole resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(ClusterRole resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(ClusterRole resource) { + public boolean isDeleted(ClusterRole resource) { return resource == null; } } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ConfigMapType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ConfigMapType.java index 978c1e4..aba3ee7 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ConfigMapType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ConfigMapType.java @@ -144,7 +144,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(ConfigMap resource) { + public boolean isReady(ConfigMap resource) { return resource != null; } @@ -155,7 +155,7 @@ public boolean waitForReadiness(ConfigMap resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(ConfigMap resource) { + public boolean isDeleted(ConfigMap resource) { return resource == null; } } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/CustomResourceDefinitionType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/CustomResourceDefinitionType.java index ba044a6..516264d 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/CustomResourceDefinitionType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/CustomResourceDefinitionType.java @@ -98,7 +98,7 @@ public void replace(String resourceName, Consumer edit * @return result of the readiness check */ @Override - public boolean waitForReadiness(CustomResourceDefinition resource) { + public boolean isReady(CustomResourceDefinition resource) { return resource != null; } @@ -109,7 +109,7 @@ public boolean waitForReadiness(CustomResourceDefinition resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(CustomResourceDefinition resource) { + public boolean isDeleted(CustomResourceDefinition resource) { return resource == null; } } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/DeploymentType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/DeploymentType.java index 5a01924..9484dcf 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/DeploymentType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/DeploymentType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(Deployment resource) { + public boolean isReady(Deployment resource) { return client.resource(resource).isReady(); } @@ -108,7 +108,7 @@ public boolean waitForReadiness(Deployment resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(Deployment resource) { + public boolean isDeleted(Deployment resource) { return resource == null; } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/JobType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/JobType.java index ab71151..30db1f9 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/JobType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/JobType.java @@ -145,7 +145,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(Job resource) { + public boolean isReady(Job resource) { return client.resource(resource).isReady(); } @@ -156,7 +156,7 @@ public boolean waitForReadiness(Job resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(Job resource) { + public boolean isDeleted(Job resource) { return resource == null; } } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/LeaseType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/LeaseType.java index 6bb0d0a..0d2c70c 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/LeaseType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/LeaseType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(Lease resource) { + public boolean isReady(Lease resource) { return client.resource(resource).isReady(); } @@ -108,7 +108,7 @@ public boolean waitForReadiness(Lease resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(Lease resource) { + public boolean isDeleted(Lease resource) { return resource == null; } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NamespaceType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NamespaceType.java index 9dc9c59..352e4d5 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NamespaceType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NamespaceType.java @@ -113,7 +113,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(Namespace resource) { + public boolean isReady(Namespace resource) { return resource != null; } @@ -124,7 +124,7 @@ public boolean waitForReadiness(Namespace resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(Namespace resource) { + public boolean isDeleted(Namespace resource) { return resource == null; } } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NetworkPolicyType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NetworkPolicyType.java index 3f2252a..1fbd7bf 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NetworkPolicyType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/NetworkPolicyType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(NetworkPolicy resource) { + public boolean isReady(NetworkPolicy resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(NetworkPolicy resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(NetworkPolicy resource) { + public boolean isDeleted(NetworkPolicy resource) { return resource == null; } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleBindingType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleBindingType.java index 610bd9e..42e4b76 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleBindingType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleBindingType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(RoleBinding resource) { + public boolean isReady(RoleBinding resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(RoleBinding resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(RoleBinding resource) { + public boolean isDeleted(RoleBinding resource) { return resource == null; } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleType.java index 7cc43dc..ed108ff 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/RoleType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(Role resource) { + public boolean isReady(Role resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(Role resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(Role resource) { + public boolean isDeleted(Role resource) { return resource == null; } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/SecretType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/SecretType.java index 4926ab5..c7fff03 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/SecretType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/SecretType.java @@ -116,7 +116,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(Secret resource) { + public boolean isReady(Secret resource) { return false; } @@ -127,7 +127,7 @@ public boolean waitForReadiness(Secret resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(Secret resource) { + public boolean isDeleted(Secret resource) { return false; } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceAccountType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceAccountType.java index e1d3f8f..85134ce 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceAccountType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceAccountType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(ServiceAccount resource) { + public boolean isReady(ServiceAccount resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(ServiceAccount resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(ServiceAccount resource) { + public boolean isDeleted(ServiceAccount resource) { return resource == null; } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceType.java index 63de834..116815a 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ServiceType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(Service resource) { + public boolean isReady(Service resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(Service resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(Service resource) { + public boolean isDeleted(Service resource) { return resource == null; } diff --git a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ValidatingWebhookConfigurationType.java b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ValidatingWebhookConfigurationType.java index ec54491..b16001b 100644 --- a/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ValidatingWebhookConfigurationType.java +++ b/test-frame-kubernetes/src/main/java/io/skodjob/testframe/resources/ValidatingWebhookConfigurationType.java @@ -102,7 +102,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(InstallPlan resource) { + public boolean isReady(InstallPlan resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(InstallPlan resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(InstallPlan resource) { + public boolean isDeleted(InstallPlan resource) { return resource == null; } diff --git a/test-frame-openshift/src/main/java/io/skodjob/testframe/resources/OperatorGroupType.java b/test-frame-openshift/src/main/java/io/skodjob/testframe/resources/OperatorGroupType.java index 7f03851..bf6255e 100644 --- a/test-frame-openshift/src/main/java/io/skodjob/testframe/resources/OperatorGroupType.java +++ b/test-frame-openshift/src/main/java/io/skodjob/testframe/resources/OperatorGroupType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(OperatorGroup resource) { + public boolean isReady(OperatorGroup resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(OperatorGroup resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(OperatorGroup resource) { + public boolean isDeleted(OperatorGroup resource) { return resource == null; } diff --git a/test-frame-openshift/src/main/java/io/skodjob/testframe/resources/SubscriptionType.java b/test-frame-openshift/src/main/java/io/skodjob/testframe/resources/SubscriptionType.java index 40e23f0..80494ea 100644 --- a/test-frame-openshift/src/main/java/io/skodjob/testframe/resources/SubscriptionType.java +++ b/test-frame-openshift/src/main/java/io/skodjob/testframe/resources/SubscriptionType.java @@ -97,7 +97,7 @@ public void replace(String resourceName, Consumer editor) { * @return result of the readiness check */ @Override - public boolean waitForReadiness(Subscription resource) { + public boolean isReady(Subscription resource) { return resource != null; } @@ -108,7 +108,7 @@ public boolean waitForReadiness(Subscription resource) { * @return result of the deletion */ @Override - public boolean waitForDeletion(Subscription resource) { + public boolean isDeleted(Subscription resource) { return resource == null; }