From d3a87c3c9c8f5d9d42e980501208da3744fde7c0 Mon Sep 17 00:00:00 2001 From: Vacant2333 Date: Sun, 26 Nov 2023 01:33:00 +0800 Subject: [PATCH] add e2e coverage analysis Signed-off-by: Vacant2333 --- test/e2e/clusteroverridepolicy_test.go | 9 +++-- test/e2e/clusterpropagationpolicy_test.go | 3 +- .../clusteroverridepolicy_test.md | 11 ++++++ .../clusterpropagationpolicy_test.md | 30 ++++++++++++++++ .../dependenciesdistributor_test.md | 9 +++++ test/e2e/coverage_docs/failover_test.md | 11 ++++++ test/e2e/coverage_docs/namespace_test.md | 4 +-- .../coverage_docs/propagationpolicy_test.md | 35 +++++++++++++++++++ .../resource_deletion_protection_test.md | 8 +++++ test/e2e/dependenciesdistributor_test.go | 4 +-- test/e2e/failover_test.go | 9 ++--- test/e2e/propagationpolicy_test.go | 4 +-- test/e2e/resource_deletion_protection_test.go | 8 ++--- 13 files changed, 122 insertions(+), 23 deletions(-) create mode 100644 test/e2e/coverage_docs/clusteroverridepolicy_test.md create mode 100644 test/e2e/coverage_docs/clusterpropagationpolicy_test.md create mode 100644 test/e2e/coverage_docs/dependenciesdistributor_test.md create mode 100644 test/e2e/coverage_docs/failover_test.md create mode 100644 test/e2e/coverage_docs/propagationpolicy_test.md create mode 100644 test/e2e/coverage_docs/resource_deletion_protection_test.md diff --git a/test/e2e/clusteroverridepolicy_test.go b/test/e2e/clusteroverridepolicy_test.go index 75cbd397c..af45d11be 100644 --- a/test/e2e/clusteroverridepolicy_test.go +++ b/test/e2e/clusteroverridepolicy_test.go @@ -19,7 +19,7 @@ import ( testhelper "github.com/karmada-io/karmada/test/helper" ) -var _ = ginkgo.Describe("[BasicClusterOverridePolicy] basic cluster override policy testing", func() { +var _ = ginkgo.Describe("The basic ClusterOverridePolicy testing", func() { ginkgo.Context("Namespace propagation testing", func() { var ( randNamespace string @@ -70,7 +70,7 @@ var _ = ginkgo.Describe("[BasicClusterOverridePolicy] basic cluster override pol }) }) - ginkgo.It("Namespace testing", func() { + ginkgo.It("Namespace labelOverride testing", func() { ginkgo.By(fmt.Sprintf("Check if namespace(%s) present on member clusters", ns.Name), func() { for _, clusterName := range framework.ClusterNames() { clusterClient := framework.GetClusterClient(clusterName) @@ -83,10 +83,9 @@ var _ = ginkgo.Describe("[BasicClusterOverridePolicy] basic cluster override pol if apierrors.IsNotFound(err) { return false, nil } - return false, err } - + // Check if the cluster's customLabel is correct value v, ok := clusterNs.Labels[customLabelKey] if ok && v == customLabelVal { return true, nil @@ -99,7 +98,7 @@ var _ = ginkgo.Describe("[BasicClusterOverridePolicy] basic cluster override pol }) }) -var _ = framework.SerialDescribe("Test clusterOverridePolicy with nil resourceSelectors", func() { +var _ = framework.SerialDescribe("The ClusterOverridePolicy with nil resourceSelectors testing", func() { var deploymentNamespace, deploymentName string var propagationPolicyNamespace, propagationPolicyName string var clusterOverridePolicyName string diff --git a/test/e2e/clusterpropagationpolicy_test.go b/test/e2e/clusterpropagationpolicy_test.go index 02acaf7dc..7a75dd8ac 100644 --- a/test/e2e/clusterpropagationpolicy_test.go +++ b/test/e2e/clusterpropagationpolicy_test.go @@ -326,7 +326,6 @@ var _ = ginkgo.Describe("[AdvancedClusterPropagation] propagation testing", func }) ginkgo.Context("Edit ClusterPropagationPolicy fields other than resourceSelector", func() { - ginkgo.When("namespace scope resource", func() { var policy *policyv1alpha1.ClusterPropagationPolicy var deployment *appsv1.Deployment @@ -549,7 +548,7 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() { }) }) - ginkgo.It("high explicit/low priority/implicit priority ClusterPropagationPolicy testing", func() { + ginkgo.It("high explicit/low priority/implicit priority ClusterPropagationPolicy propagation testing", func() { ginkgo.By("check whether the deployment uses the highest explicit priority ClusterPropagationPolicy", func() { framework.WaitDeploymentPresentOnClustersFitWith(framework.ClusterNames(), deployment.Namespace, deployment.Name, func(deployment *appsv1.Deployment) bool { diff --git a/test/e2e/coverage_docs/clusteroverridepolicy_test.md b/test/e2e/coverage_docs/clusteroverridepolicy_test.md new file mode 100644 index 000000000..f0a231bf5 --- /dev/null +++ b/test/e2e/coverage_docs/clusteroverridepolicy_test.md @@ -0,0 +1,11 @@ +### cluster override policy e2e test coverage analysis + +#### The basic ClusterOverridePolicy testing +| Test Case | E2E Describe Text | Comments | +|--------------------------------------------------------------------------|---------------------------------|-----------------------------------------------------------------------------------------| +| Check if the ClusterOverridePolicy will update the namespace label value | Namespace labelOverride testing | [Override Policy](https://karmada.io/zh/docs/next/userguide/scheduling/override-policy) | + +#### The ClusterOverridePolicy with nil resourceSelectors testing +| Test Case | E2E Describe Text | Comments | +|-----------------------------------------------------------------------------------------------------|----------------------------------|-------------------------------------------------------------------------------------------------------------------------------------| +| Check if the ClusterOverridePolicy with nil resourceSelector will update the deployment image value | deployment imageOverride testing | [Override Policy with nil resourceSelector](https://karmada.io/zh/docs/next/userguide/scheduling/override-policy#resource-selector) | diff --git a/test/e2e/coverage_docs/clusterpropagationpolicy_test.md b/test/e2e/coverage_docs/clusterpropagationpolicy_test.md new file mode 100644 index 000000000..9e1a41487 --- /dev/null +++ b/test/e2e/coverage_docs/clusterpropagationpolicy_test.md @@ -0,0 +1,30 @@ +### cluster propagation policy e2e test coverage analysis + +#### Basic propagation testing +| Test Case | E2E Describe Text | Comments | +|----------------------------------------------------|----------------------------------------|------------------------------------------------------------------------------------------------| +| Test the propagation policy for CRD | crd propagation testing | [Resource propagating](https://karmada.io/docs/next/userguide/scheduling/resource-propagating) | +| Test the propagation policy for clusterRole | clusterRole propagation testing | | +| Test the propagation policy for clusterRoleBinding | clusterRoleBinding propagation testing | | + +#### Advanced propagation testing +| Test Case | E2E Describe Text | Comments | +|----------------------------------------------------------------------------|------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| Test add resourceSelector of the propagation policy for the deployment | add resourceSelectors item(namespace scope) | [Update propagationPolicy](https://karmada.io/docs/next/userguide/scheduling/resource-propagating#update-propagationpolicy) | +| Test update resourceSelector of the propagation policy for the deployment | update resourceSelectors item(namespace scope) | | +| Test add resourceSelector of the propagation policy for the clusterRole | add resourceSelectors item(cluster scope) | | +| Test update resourceSelector of the propagation policy for the clusterRole | update resourceSelectors item(cluster scope) | | +| Test update propagateDeps of the propagation policy for deployment | update policy propagateDeps(namespace scope) | | +| Test update placement of the propagation policy for deployment | update policy placement(namespace scope) | | +| Test update placement of the propagation policy for clusterRole | update policy placement(cluster scope) | | + +#### ExplicitPriority propagation testing +| Test Case | E2E Describe Text | Comments | +|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Test the high explicit/low priority/implicit priority propagation for deployment | high explicit/low priority/implicit priority ClusterPropagationPolicy propagation testing | [Configure PropagationPolicy/ClusterPropagationPolicy priority](https://karmada.io/docs/next/userguide/scheduling/resource-propagating#configure-propagationpolicyclusterpropagationpolicy-priority) | +| Test the same explicit priority propagation for deployment | same explicit priority ClusterPropagationPolicy propagation testing | [Choose from same-priority PropagationPolicies](https://karmada.io/docs/next/userguide/scheduling/resource-propagating#choose-from-same-priority-propagationpolicies) | + +#### TODO +1. May need add the test case when the [deployment updates](https://karmada.io/docs/next/userguide/scheduling/resource-propagating#update-deployment). +2. May need add the test case for the **same implicit priority** propagation. +3. May need add the test case for **delete** the clusterPropagationPolicy. diff --git a/test/e2e/coverage_docs/dependenciesdistributor_test.md b/test/e2e/coverage_docs/dependenciesdistributor_test.md new file mode 100644 index 000000000..9d059885b --- /dev/null +++ b/test/e2e/coverage_docs/dependenciesdistributor_test.md @@ -0,0 +1,9 @@ +### dependencies distributor e2e test coverage analysis + +| Test Case | E2E Describe Text | Comments | +|------------------------------------------------------|---------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------| +| Test the configmap will propagate automatically | configmap automatically propagation testing | [Propagate Dependencies](https://karmada.io/docs/next/userguide/scheduling/propagate-dependencies) | +| Test the secret will propagate automatically | secret automatically propagation testing | [Dependencies distributor](https://github.com/karmada-io/karmada/blob/master/docs/proposals/dependencies-automatically-propagation/README.md) | +| Test the PVC will propagate automatically | persistentVolumeClaim automatically propagation testing | | +| Test the serviceAccount will propagate automatically | serviceAccount automatically propagation testing | | +| Test the configmap will propagate automatically | configmap propagate automatically testing | | diff --git a/test/e2e/coverage_docs/failover_test.md b/test/e2e/coverage_docs/failover_test.md new file mode 100644 index 000000000..cef83842d --- /dev/null +++ b/test/e2e/coverage_docs/failover_test.md @@ -0,0 +1,11 @@ +### failover e2e test coverage analysis + +| Test Case | E2E Describe Text | Comments | +|------------------------------------------------------------------------------------|------------------------------------------------|----------------------------------------------------------------------------------------------| +| Test if the deployment of failed cluster is rescheduled to other available cluster | deployment failover testing | [Failover](https://karmada.io/docs/next/userguide/failover/failover-overview) | +| Test if the deployment of taint cluster is rescheduled to other available cluster | taint cluster | | +| Test if the deployment will rescheduled to other available cluster | application failover with purgeMode graciously | [Application failover](https://karmada.io/docs/next/userguide/failover/application-failover) | +| Test if the deployment will never rescheduled to other available cluster | application failover with purgeMode never | | + +#### TODO +1. There are 2 way to evict the deployment of the Graciously PurgeMode, the third case cover the first way only, we may add a test case [when the GracePeriodSeconds is reach out](https://karmada.io/docs/next/userguide/failover/application-failover/#:~:text=after%20a%20timeout%20is%20reached%20before%20evicting%20the%20application). diff --git a/test/e2e/coverage_docs/namespace_test.md b/test/e2e/coverage_docs/namespace_test.md index 0dc56e97b..f0ef5eb17 100644 --- a/test/e2e/coverage_docs/namespace_test.md +++ b/test/e2e/coverage_docs/namespace_test.md @@ -2,6 +2,6 @@ | Test Case | E2E Describe Text | Comments | |-----------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------| -| Create a namespace that needs to be automatically synchronized across all member clusters | create a namespace in karmada-apiserver || -| Delete a namespace, and all member clusters need to automatically synchronize the deletion | delete a namespace from karmada-apiserver || +| Create a namespace that needs to be automatically synchronized across all member clusters | create a namespace in karmada-apiserver | | +| Delete a namespace, and all member clusters need to automatically synchronize the deletion | delete a namespace from karmada-apiserver | | | When a new cluster joins, the namespaces on the Karmada control plane (excluding reserved namespaces) need to be synchronized to that cluster | joining new cluster | [Namespace Management](https://karmada.io/docs/next/userguide/bestpractices/namespace-management/#default-namespace-propagation) | diff --git a/test/e2e/coverage_docs/propagationpolicy_test.md b/test/e2e/coverage_docs/propagationpolicy_test.md new file mode 100644 index 000000000..15a9966f0 --- /dev/null +++ b/test/e2e/coverage_docs/propagationpolicy_test.md @@ -0,0 +1,35 @@ +### propagation policy e2e test coverage analysis + +#### Basic propagation testing +| Test Case | E2E Describe Text | Comments | +|----------------------------------------------------------------|----------------------------------------|------------------------------------------------------------------------------------------------| +| Test the propagationPolicy for deployment | deployment propagation testing | [Resource propagating](https://karmada.io/docs/next/userguide/scheduling/resource-propagating) | +| Test the propagationPolicy for service | service propagation testing | | +| Test the propagationPolicy for pod | pod propagation testing | | +| Test the propagationPolicy for namespace scope custom resource | namespaceScoped cr propagation testing | | +| Test the propagationPolicy for job | job propagation testing | | +| Test the propagationPolicy for role | role propagation testing | | +| Test the propagationPolicy for roleBinding | roleBinding propagation testing | | + +#### ImplicitPriority propagation testing +| Test Case | E2E Describe Text | Comments | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------| +| Test whether the deployment uses the highest priority propagationPolicy when there are three propagationPolicy | priorityMatchName testing | [Configure implicit priority](https://karmada.io/docs/next/userguide/scheduling/resource-propagating/#configure-implicit-priority) | +| Test whether the deployment uses the highest priority propagationPolicy when there are two propagation policies, one with a label selector and the other without | policyMatchLabelSelector testing | | +| Test whether the deployment uses the highest priority propagationPolicy when there is a propagationPolicy match all deployment | priorityMatchAll testing | | + +#### ExplicitPriority propagation testing +| Test Case | E2E Describe Text | Comments | +|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Test the high explicit/low priority/implicit priority propagation for deployment | high explicit/low priority/implicit priority PropagationPolicy propagation testing | [Configure explicit priority](https://karmada.io/docs/next/userguide/scheduling/resource-propagating#configure-explicit-priority) | +| Test the same explicit priority propagation for deployment | same explicit priority PropagationPolicy propagation testing | [Choose from same-priority PropagationPolicies](https://karmada.io/docs/next/userguide/scheduling/resource-propagating#choose-from-same-priority-propagationpolicies) | + +#### Advanced propagation testing +| Test Case | E2E Describe Text | Comments | +|--------------------------------------------------------------------------|-----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| Test add resourceSelector of the propagationPolicy for the deployment | add resourceSelectors item | [Update propagationPolicy](https://karmada.io/docs/next/userguide/scheduling/resource-propagating#update-propagationpolicy) | +| Test update resourceSelector of the propagationPolicy for the deployment | update resourceSelectors item | | +| Test update propagateDeps of the propagationPolicy for the deployment | update policy propagateDeps | | +| Test update placement of the propagationPolicy for the deployment | update policy placement | | +| Test modify the old propagationPolicy to unbind and create a new one | modify the old propagationPolicy to unbind and create a new one | | +| Test delete the old propagationPolicy to unbind and create a new one | delete the old propagationPolicy to unbind and create a new one | | diff --git a/test/e2e/coverage_docs/resource_deletion_protection_test.md b/test/e2e/coverage_docs/resource_deletion_protection_test.md new file mode 100644 index 000000000..d38378472 --- /dev/null +++ b/test/e2e/coverage_docs/resource_deletion_protection_test.md @@ -0,0 +1,8 @@ +### resource deletion protection e2e test coverage analysis + +| Test Case | E2E Describe Text | Comments | +|----------------------------------------------------------------------------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------| +| Test the basic protection for deployment | Delete the protected deployment | [Resource Deletion Protection](https://karmada.io/docs/next/administrator/configuration/resource-deletion-protection/) | +| Test the basic protection for namespace | Delete the protected namespace | | +| Test delete the unprotected namespace that contains a protected Deployment | Delete the no protected namespace, the deployment is protected | | +| Test delete the namespace after the protection has been removed | Delete the namespace after the protection has been removed | | diff --git a/test/e2e/dependenciesdistributor_test.go b/test/e2e/dependenciesdistributor_test.go index 87a7ff8a4..7ee36488e 100644 --- a/test/e2e/dependenciesdistributor_test.go +++ b/test/e2e/dependenciesdistributor_test.go @@ -14,7 +14,7 @@ import ( ) var _ = ginkgo.Describe("[DependenciesDistributor] automatically propagate relevant resources testing", func() { - ginkgo.Context("dependencies propagation with propagationpolicy testing", func() { + ginkgo.Context("dependencies propagation with propagationPolicy testing", func() { var initClusterNames, updateClusterNames []string var policyName string var deploymentName string @@ -327,7 +327,7 @@ var _ = ginkgo.Describe("[DependenciesDistributor] automatically propagate relev }) }) - ginkgo.Context("dependencies propagation with clusterpropagationpolicy testing", func() { + ginkgo.Context("dependencies propagation with clusterPropagationPolicy testing", func() { var initClusterNames, updateClusterNames []string var policyName string var deploymentName string diff --git a/test/e2e/failover_test.go b/test/e2e/failover_test.go index ac2a0d7db..b095b5be3 100644 --- a/test/e2e/failover_test.go +++ b/test/e2e/failover_test.go @@ -219,7 +219,7 @@ var _ = framework.SerialDescribe("failover testing", func() { } }) - ginkgo.By("check whether deployment of failed cluster is rescheduled to other available cluster", func() { + ginkgo.By("check whether deployment of taint cluster is rescheduled to other available cluster", func() { gomega.Eventually(func() int { targetClusterNames = framework.ExtractTargetClustersFrom(controlPlaneClient, deployment) for _, targetClusterName := range targetClusterNames { @@ -307,7 +307,7 @@ var _ = framework.SerialDescribe("failover testing", func() { }) }) - ginkgo.It("application failover", func() { + ginkgo.It("application failover with purgeMode graciously", func() { disabledClusters := framework.ExtractTargetClustersFrom(controlPlaneClient, deployment) ginkgo.By("create an error op", func() { overridePolicy = testhelper.NewOverridePolicyByOverrideRules(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{ @@ -369,7 +369,6 @@ var _ = framework.SerialDescribe("failover testing", func() { framework.RemoveOverridePolicy(karmadaClient, policyNamespace, policyName) }) }) - }) ginkgo.Context("Application failover testing with purgeMode never", func() { @@ -435,7 +434,7 @@ var _ = framework.SerialDescribe("failover testing", func() { }) }) - ginkgo.It("application failover", func() { + ginkgo.It("application failover with purgeMode never", func() { disabledClusters := framework.ExtractTargetClustersFrom(controlPlaneClient, deployment) ginkgo.By("create an error op", func() { overridePolicy = testhelper.NewOverridePolicyByOverrideRules(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{ @@ -497,9 +496,7 @@ var _ = framework.SerialDescribe("failover testing", func() { framework.RemoveOverridePolicy(karmadaClient, policyNamespace, policyName) }) }) - }) - }) // disableCluster will set wrong API endpoint of current cluster diff --git a/test/e2e/propagationpolicy_test.go b/test/e2e/propagationpolicy_test.go index c8b09501f..05c393c16 100644 --- a/test/e2e/propagationpolicy_test.go +++ b/test/e2e/propagationpolicy_test.go @@ -1076,7 +1076,7 @@ var _ = ginkgo.Describe("[AdvancedPropagation] propagation testing", func() { }) }) - ginkgo.It("modify the old PropagationPolicy to unbind and create a new one", func() { + ginkgo.It("modify the old propagationPolicy to unbind and create a new one", func() { framework.CreatePropagationPolicy(karmadaClient, policy01) framework.WaitConfigMapPresentOnClusterFitWith(member1, configmap.Namespace, configmap.Name, func(configmap *corev1.ConfigMap) bool { return true }) @@ -1103,7 +1103,7 @@ var _ = ginkgo.Describe("[AdvancedPropagation] propagation testing", func() { framework.RemovePropagationPolicy(karmadaClient, policy02.Namespace, policy02.Name) }) - ginkgo.It("delete the old PropagationPolicy to unbind and create a new one", func() { + ginkgo.It("delete the old propagationPolicy to unbind and create a new one", func() { framework.CreatePropagationPolicy(karmadaClient, policy01) framework.WaitConfigMapPresentOnClusterFitWith(member1, configmap.Namespace, configmap.Name, func(configmap *corev1.ConfigMap) bool { return true }) diff --git a/test/e2e/resource_deletion_protection_test.go b/test/e2e/resource_deletion_protection_test.go index 46030949b..5cbaf637d 100644 --- a/test/e2e/resource_deletion_protection_test.go +++ b/test/e2e/resource_deletion_protection_test.go @@ -39,7 +39,7 @@ var _ = ginkgo.Describe("[resource deletion protection] deletion protection test framework.CreateDeployment(kubeClient, deployment) }) - ginkgo.It("delete the protected deployment", func() { + ginkgo.It("Delete the protected deployment", func() { framework.UpdateDeploymentLabels(kubeClient, deployment, protectedLabelValues) // the deletion operation should return an error like: @@ -50,7 +50,7 @@ var _ = ginkgo.Describe("[resource deletion protection] deletion protection test gomega.Expect(err).Should(gomega.MatchError(gomega.ContainSubstring(deletionProtectionErrorSubStr))) }) - ginkgo.It("delete the protected namespace", func() { + ginkgo.It("Delete the protected namespace", func() { framework.UpdateNamespaceLabels(kubeClient, namespace, protectedLabelValues) // the deletion operation should return an error too. @@ -58,7 +58,7 @@ var _ = ginkgo.Describe("[resource deletion protection] deletion protection test gomega.Expect(err).Should(gomega.MatchError(gomega.ContainSubstring(deletionProtectionErrorSubStr))) }) - ginkgo.It("delete the no protected namespace, the deployment is protected", func() { + ginkgo.It("Delete the no protected namespace, the deployment is protected", func() { framework.UpdateDeploymentLabels(kubeClient, deployment, protectedLabelValues) // the deletion operation should not return an error, and the namespace @@ -69,7 +69,7 @@ var _ = ginkgo.Describe("[resource deletion protection] deletion protection test gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) }) - ginkgo.It("delete the namespace after the protection has been removed", func() { + ginkgo.It("Delete the namespace after the protection has been removed", func() { framework.UpdateNamespaceLabels(kubeClient, namespace, protectedLabelValues) err := kubeClient.CoreV1().Namespaces().Delete(context.TODO(), namespaceName, metav1.DeleteOptions{}) gomega.Expect(err).Should(gomega.MatchError(gomega.ContainSubstring(deletionProtectionErrorSubStr)))