remove pp/cpp name length limit
Signed-off-by: changzhen <changzhen5@huawei.com>
This commit is contained in:
parent
e7cb1332c5
commit
911cc44974
|
@ -31,9 +31,6 @@ import (
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LabelValueMaxLength is a label's max length
|
|
||||||
const LabelValueMaxLength int = 63
|
|
||||||
|
|
||||||
// ValidatePropagationSpec validates a PropagationSpec before creation or update.
|
// ValidatePropagationSpec validates a PropagationSpec before creation or update.
|
||||||
func ValidatePropagationSpec(spec policyv1alpha1.PropagationSpec) field.ErrorList {
|
func ValidatePropagationSpec(spec policyv1alpha1.PropagationSpec) field.ErrorList {
|
||||||
var allErrs field.ErrorList
|
var allErrs field.ErrorList
|
||||||
|
|
|
@ -19,7 +19,6 @@ package clusterpropagationpolicy
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -30,7 +29,6 @@ import (
|
||||||
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
|
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
"github.com/karmada-io/karmada/pkg/util/helper"
|
"github.com/karmada-io/karmada/pkg/util/helper"
|
||||||
"github.com/karmada-io/karmada/pkg/util/validation"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MutatingAdmission mutates API request if necessary.
|
// MutatingAdmission mutates API request if necessary.
|
||||||
|
@ -67,10 +65,6 @@ func (a *MutatingAdmission) Handle(_ context.Context, req admission.Request) adm
|
||||||
helper.AddTolerations(&policy.Spec.Placement, helper.NewNotReadyToleration(a.DefaultNotReadyTolerationSeconds),
|
helper.AddTolerations(&policy.Spec.Placement, helper.NewNotReadyToleration(a.DefaultNotReadyTolerationSeconds),
|
||||||
helper.NewUnreachableToleration(a.DefaultUnreachableTolerationSeconds))
|
helper.NewUnreachableToleration(a.DefaultUnreachableTolerationSeconds))
|
||||||
|
|
||||||
if len(policy.Name) > validation.LabelValueMaxLength {
|
|
||||||
return admission.Errored(http.StatusBadRequest, fmt.Errorf("ClusterPropagationPolicy's name should be no more than %d characters", validation.LabelValueMaxLength))
|
|
||||||
}
|
|
||||||
|
|
||||||
if helper.ContainsServiceImport(policy.Spec.ResourceSelectors) {
|
if helper.ContainsServiceImport(policy.Spec.ResourceSelectors) {
|
||||||
policy.Spec.PropagateDeps = true
|
policy.Spec.PropagateDeps = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package propagationpolicy
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
|
@ -31,7 +30,6 @@ import (
|
||||||
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
|
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
"github.com/karmada-io/karmada/pkg/util/helper"
|
"github.com/karmada-io/karmada/pkg/util/helper"
|
||||||
"github.com/karmada-io/karmada/pkg/util/validation"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MutatingAdmission mutates API request if necessary.
|
// MutatingAdmission mutates API request if necessary.
|
||||||
|
@ -75,9 +73,6 @@ func (a *MutatingAdmission) Handle(_ context.Context, req admission.Request) adm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(policy.Name) > validation.LabelValueMaxLength {
|
|
||||||
return admission.Errored(http.StatusBadRequest, fmt.Errorf("PropagationPolicy's name should be no more than %d characters", validation.LabelValueMaxLength))
|
|
||||||
}
|
|
||||||
// Set default spread constraints if both 'SpreadByField' and 'SpreadByLabel' not set.
|
// Set default spread constraints if both 'SpreadByField' and 'SpreadByLabel' not set.
|
||||||
helper.SetDefaultSpreadConstraints(policy.Spec.Placement.SpreadConstraints)
|
helper.SetDefaultSpreadConstraints(policy.Spec.Placement.SpreadConstraints)
|
||||||
helper.AddTolerations(&policy.Spec.Placement, helper.NewNotReadyToleration(a.DefaultNotReadyTolerationSeconds),
|
helper.AddTolerations(&policy.Spec.Placement, helper.NewNotReadyToleration(a.DefaultNotReadyTolerationSeconds),
|
||||||
|
|
|
@ -43,13 +43,22 @@ import (
|
||||||
testhelper "github.com/karmada-io/karmada/test/helper"
|
testhelper "github.com/karmada-io/karmada/test/helper"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func() {
|
var _ = ginkgo.Describe("[BasicCase] ClusterPropagationPolicy testing", func() {
|
||||||
|
var policyName string
|
||||||
|
var policy *policyv1alpha1.ClusterPropagationPolicy
|
||||||
|
|
||||||
|
ginkgo.JustBeforeEach(func() {
|
||||||
|
framework.CreateClusterPropagationPolicy(karmadaClient, policy)
|
||||||
|
ginkgo.DeferCleanup(func() {
|
||||||
|
framework.RemoveClusterPropagationPolicy(karmadaClient, policy.Name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
ginkgo.Context("CustomResourceDefinition propagation testing", func() {
|
ginkgo.Context("CustomResourceDefinition propagation testing", func() {
|
||||||
var crdGroup string
|
var crdGroup string
|
||||||
var randStr string
|
var randStr string
|
||||||
var crdSpecNames apiextensionsv1.CustomResourceDefinitionNames
|
var crdSpecNames apiextensionsv1.CustomResourceDefinitionNames
|
||||||
var crd *apiextensionsv1.CustomResourceDefinition
|
var crd *apiextensionsv1.CustomResourceDefinition
|
||||||
var crdPolicy *policyv1alpha1.ClusterPropagationPolicy
|
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
crdGroup = fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
crdGroup = fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
||||||
|
@ -61,7 +70,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
Singular: fmt.Sprintf("foo%s", randStr),
|
Singular: fmt.Sprintf("foo%s", randStr),
|
||||||
}
|
}
|
||||||
crd = testhelper.NewCustomResourceDefinition(crdGroup, crdSpecNames, apiextensionsv1.NamespaceScoped)
|
crd = testhelper.NewCustomResourceDefinition(crdGroup, crdSpecNames, apiextensionsv1.NamespaceScoped)
|
||||||
crdPolicy = testhelper.NewClusterPropagationPolicy(crd.Name, []policyv1alpha1.ResourceSelector{
|
policyName = crd.Name
|
||||||
|
policy = testhelper.NewClusterPropagationPolicy(policyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: crd.APIVersion,
|
APIVersion: crd.APIVersion,
|
||||||
Kind: crd.Kind,
|
Kind: crd.Kind,
|
||||||
|
@ -75,10 +85,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreateClusterPropagationPolicy(karmadaClient, crdPolicy)
|
|
||||||
framework.CreateCRD(dynamicClient, crd)
|
framework.CreateCRD(dynamicClient, crd)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemoveClusterPropagationPolicy(karmadaClient, crdPolicy.Name)
|
|
||||||
framework.RemoveCRD(dynamicClient, crd.Name)
|
framework.RemoveCRD(dynamicClient, crd.Name)
|
||||||
framework.WaitCRDDisappearedOnClusters(framework.ClusterNames(), crd.Name)
|
framework.WaitCRDDisappearedOnClusters(framework.ClusterNames(), crd.Name)
|
||||||
})
|
})
|
||||||
|
@ -94,8 +102,6 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
ginkgo.Context("ClusterRole propagation testing", func() {
|
ginkgo.Context("ClusterRole propagation testing", func() {
|
||||||
var (
|
var (
|
||||||
clusterRoleName string
|
clusterRoleName string
|
||||||
policyName string
|
|
||||||
policy *policyv1alpha1.ClusterPropagationPolicy
|
|
||||||
clusterRole *rbacv1.ClusterRole
|
clusterRole *rbacv1.ClusterRole
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -118,10 +124,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreateClusterPropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateClusterRole(kubeClient, clusterRole)
|
framework.CreateClusterRole(kubeClient, clusterRole)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemoveClusterPropagationPolicy(karmadaClient, policy.Name)
|
|
||||||
framework.RemoveClusterRole(kubeClient, clusterRole.Name)
|
framework.RemoveClusterRole(kubeClient, clusterRole.Name)
|
||||||
framework.WaitClusterRoleDisappearOnClusters(framework.ClusterNames(), clusterRole.Name)
|
framework.WaitClusterRoleDisappearOnClusters(framework.ClusterNames(), clusterRole.Name)
|
||||||
})
|
})
|
||||||
|
@ -138,8 +142,6 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
ginkgo.Context("ClusterRoleBinding propagation testing", func() {
|
ginkgo.Context("ClusterRoleBinding propagation testing", func() {
|
||||||
var (
|
var (
|
||||||
clusterRoleBindingName string
|
clusterRoleBindingName string
|
||||||
policyName string
|
|
||||||
policy *policyv1alpha1.ClusterPropagationPolicy
|
|
||||||
clusterRoleBinding *rbacv1.ClusterRoleBinding
|
clusterRoleBinding *rbacv1.ClusterRoleBinding
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -162,10 +164,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreateClusterPropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateClusterRoleBinding(kubeClient, clusterRoleBinding)
|
framework.CreateClusterRoleBinding(kubeClient, clusterRoleBinding)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemoveClusterPropagationPolicy(karmadaClient, policy.Name)
|
|
||||||
framework.RemoveClusterRoleBinding(kubeClient, clusterRoleBinding.Name)
|
framework.RemoveClusterRoleBinding(kubeClient, clusterRoleBinding.Name)
|
||||||
framework.WaitClusterRoleBindingDisappearOnClusters(framework.ClusterNames(), clusterRoleBinding.Name)
|
framework.WaitClusterRoleBindingDisappearOnClusters(framework.ClusterNames(), clusterRoleBinding.Name)
|
||||||
})
|
})
|
||||||
|
@ -180,13 +180,12 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Deployment propagation testing", func() {
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
var policy *policyv1alpha1.ClusterPropagationPolicy
|
|
||||||
var deployment *appsv1.Deployment
|
var deployment *appsv1.Deployment
|
||||||
var targetMember string
|
var targetMember string
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
targetMember = framework.ClusterNames()[0]
|
targetMember = framework.ClusterNames()[0]
|
||||||
policyName := cppNamePrefix + rand.String(RandomStrLength)
|
policyName = cppNamePrefix + rand.String(RandomStrLength)
|
||||||
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
|
|
||||||
deployment = testhelper.NewDeployment(testNamespace, deploymentName)
|
deployment = testhelper.NewDeployment(testNamespace, deploymentName)
|
||||||
|
@ -204,10 +203,8 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreateClusterPropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateDeployment(kubeClient, deployment)
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemoveClusterPropagationPolicy(karmadaClient, policy.Name)
|
|
||||||
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -227,7 +224,62 @@ var _ = ginkgo.Describe("[BasicClusterPropagation] propagation testing", func()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[AdvancedClusterPropagation] propagation testing", func() {
|
var _ = ginkgo.Describe("[CornerCase] ClusterPropagationPolicy testing", func() {
|
||||||
|
var policyName string
|
||||||
|
var policy *policyv1alpha1.ClusterPropagationPolicy
|
||||||
|
|
||||||
|
ginkgo.JustBeforeEach(func() {
|
||||||
|
framework.CreateClusterPropagationPolicy(karmadaClient, policy)
|
||||||
|
ginkgo.DeferCleanup(func() {
|
||||||
|
framework.RemoveClusterPropagationPolicy(karmadaClient, policy.Name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
|
var deployment *appsv1.Deployment
|
||||||
|
var targetMember string
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
targetMember = framework.ClusterNames()[0]
|
||||||
|
policyName = cppNamePrefix + rand.String(RandomStrLength)
|
||||||
|
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
|
|
||||||
|
deployment = testhelper.NewDeployment(testNamespace, deploymentName)
|
||||||
|
policy = testhelper.NewClusterPropagationPolicy(policyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
}}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: []string{targetMember},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
|
ginkgo.DeferCleanup(func() {
|
||||||
|
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.It("deployment propagation testing", func() {
|
||||||
|
framework.WaitDeploymentPresentOnClusterFitWith(targetMember, deployment.Namespace, deployment.Name,
|
||||||
|
func(d *appsv1.Deployment) bool {
|
||||||
|
return *d.Spec.Replicas == *deployment.Spec.Replicas
|
||||||
|
})
|
||||||
|
|
||||||
|
framework.UpdateDeploymentReplicas(kubeClient, deployment, updateDeploymentReplicas)
|
||||||
|
framework.WaitDeploymentPresentOnClusterFitWith(targetMember, deployment.Namespace, deployment.Name,
|
||||||
|
func(deployment *appsv1.Deployment) bool {
|
||||||
|
return *deployment.Spec.Replicas == updateDeploymentReplicas
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
var _ = ginkgo.Describe("[AdvancedCase] ClusterPropagationPolicy testing", func() {
|
||||||
ginkgo.Context("Edit ClusterPropagationPolicy ResourceSelectors", func() {
|
ginkgo.Context("Edit ClusterPropagationPolicy ResourceSelectors", func() {
|
||||||
ginkgo.When("propagate namespace scope resource", func() {
|
ginkgo.When("propagate namespace scope resource", func() {
|
||||||
var policy *policyv1alpha1.ClusterPropagationPolicy
|
var policy *policyv1alpha1.ClusterPropagationPolicy
|
||||||
|
@ -552,7 +604,7 @@ var _ = ginkgo.Describe("[AdvancedClusterPropagation] propagation testing", func
|
||||||
|
|
||||||
// ImplicitPriority more than one PP matches the object, we should choose the most suitable one.
|
// ImplicitPriority more than one PP matches the object, we should choose the most suitable one.
|
||||||
// Set it to run sequentially to avoid affecting other test cases.
|
// Set it to run sequentially to avoid affecting other test cases.
|
||||||
var _ = framework.SerialDescribe("[ImplicitPriority] propagation testing", func() {
|
var _ = framework.SerialDescribe("[ImplicitPriority] ClusterPropagationPolicy testing", func() {
|
||||||
ginkgo.Context("priorityMatchName/priorityMatchLabel/priorityMatchAll propagation testing", func() {
|
ginkgo.Context("priorityMatchName/priorityMatchLabel/priorityMatchAll propagation testing", func() {
|
||||||
var priorityMatchName, priorityMatchLabelSelector, priorityMatchAll string
|
var priorityMatchName, priorityMatchLabelSelector, priorityMatchAll string
|
||||||
var deploymentNamespace, deploymentName string
|
var deploymentNamespace, deploymentName string
|
||||||
|
@ -652,7 +704,7 @@ var _ = framework.SerialDescribe("[ImplicitPriority] propagation testing", func(
|
||||||
|
|
||||||
// ExplicitPriority more than one CPP matches the object, we should select the one with the highest explicit priority, if the
|
// ExplicitPriority more than one CPP matches the object, we should select the one with the highest explicit priority, if the
|
||||||
// explicit priority is same, select the one with the highest implicit priority.
|
// explicit priority is same, select the one with the highest implicit priority.
|
||||||
var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() {
|
var _ = ginkgo.Describe("[ExplicitPriority] ClusterPropagationPolicy testing", func() {
|
||||||
ginkgo.Context("high explicit/low priority/implicit priority ClusterPropagationPolicy propagation testing", func() {
|
ginkgo.Context("high explicit/low priority/implicit priority ClusterPropagationPolicy propagation testing", func() {
|
||||||
var higherPriorityLabelSelector, lowerPriorityMatchName, implicitPriorityMatchName string
|
var higherPriorityLabelSelector, lowerPriorityMatchName, implicitPriorityMatchName string
|
||||||
var deploymentNamespace, deploymentName string
|
var deploymentNamespace, deploymentName string
|
||||||
|
@ -809,7 +861,7 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() {
|
||||||
|
|
||||||
// Delete when delete a clusterPropagationPolicy, and no more clusterPropagationPolicy matches the object, something like
|
// Delete when delete a clusterPropagationPolicy, and no more clusterPropagationPolicy matches the object, something like
|
||||||
// labels should be cleaned.
|
// labels should be cleaned.
|
||||||
var _ = ginkgo.Describe("[Delete] clusterPropagation testing", func() {
|
var _ = ginkgo.Describe("[DeleteCase] ClusterPropagationPolicy testing", func() {
|
||||||
ginkgo.Context("delete clusterPropagation and remove the labels and annotations from the resource template and reference binding", func() {
|
ginkgo.Context("delete clusterPropagation and remove the labels and annotations from the resource template and reference binding", func() {
|
||||||
var policy *policyv1alpha1.ClusterPropagationPolicy
|
var policy *policyv1alpha1.ClusterPropagationPolicy
|
||||||
var deployment *appsv1.Deployment
|
var deployment *appsv1.Deployment
|
||||||
|
|
|
@ -53,12 +53,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// BasicPropagation focus on basic propagation functionality testing.
|
// BasicPropagation focus on basic propagation functionality testing.
|
||||||
var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
var _ = ginkgo.Describe("[BasicCase] PropagationPolicy testing", func() {
|
||||||
ginkgo.Context("Deployment propagation testing", func() {
|
|
||||||
var policyNamespace, policyName string
|
var policyNamespace, policyName string
|
||||||
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
|
ginkgo.JustBeforeEach(func() {
|
||||||
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
|
ginkgo.DeferCleanup(func() {
|
||||||
|
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
var deploymentNamespace, deploymentName string
|
var deploymentNamespace, deploymentName string
|
||||||
var deployment *appsv1.Deployment
|
var deployment *appsv1.Deployment
|
||||||
var policy *policyv1alpha1.PropagationPolicy
|
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
policyNamespace = testNamespace
|
policyNamespace = testNamespace
|
||||||
|
@ -81,10 +89,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateDeployment(kubeClient, deployment)
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
|
||||||
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
||||||
framework.WaitDeploymentDisappearOnClusters(framework.ClusterNames(), deployment.Namespace, deployment.Name)
|
framework.WaitDeploymentDisappearOnClusters(framework.ClusterNames(), deployment.Namespace, deployment.Name)
|
||||||
})
|
})
|
||||||
|
@ -114,10 +120,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Service propagation testing", func() {
|
ginkgo.Context("Service propagation testing", func() {
|
||||||
var policyNamespace, policyName string
|
|
||||||
var serviceNamespace, serviceName string
|
var serviceNamespace, serviceName string
|
||||||
var service *corev1.Service
|
var service *corev1.Service
|
||||||
var policy *policyv1alpha1.PropagationPolicy
|
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
policyNamespace = testNamespace
|
policyNamespace = testNamespace
|
||||||
|
@ -140,10 +144,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateService(kubeClient, service)
|
framework.CreateService(kubeClient, service)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
|
||||||
framework.RemoveService(kubeClient, service.Namespace, service.Name)
|
framework.RemoveService(kubeClient, service.Namespace, service.Name)
|
||||||
framework.WaitServiceDisappearOnClusters(framework.ClusterNames(), service.Namespace, service.Name)
|
framework.WaitServiceDisappearOnClusters(framework.ClusterNames(), service.Namespace, service.Name)
|
||||||
})
|
})
|
||||||
|
@ -166,10 +168,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Pod propagation testing", func() {
|
ginkgo.Context("Pod propagation testing", func() {
|
||||||
var policyNamespace, policyName string
|
|
||||||
var podNamespace, podName string
|
var podNamespace, podName string
|
||||||
var pod *corev1.Pod
|
var pod *corev1.Pod
|
||||||
var policy *policyv1alpha1.PropagationPolicy
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
policyNamespace = testNamespace
|
policyNamespace = testNamespace
|
||||||
policyName = podNamePrefix + rand.String(RandomStrLength)
|
policyName = podNamePrefix + rand.String(RandomStrLength)
|
||||||
|
@ -191,10 +191,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreatePod(kubeClient, pod)
|
framework.CreatePod(kubeClient, pod)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
|
||||||
framework.RemovePod(kubeClient, pod.Namespace, pod.Name)
|
framework.RemovePod(kubeClient, pod.Namespace, pod.Name)
|
||||||
framework.WaitPodDisappearOnClusters(framework.ClusterNames(), pod.Namespace, pod.Name)
|
framework.WaitPodDisappearOnClusters(framework.ClusterNames(), pod.Namespace, pod.Name)
|
||||||
})
|
})
|
||||||
|
@ -226,7 +224,6 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
var crGVR schema.GroupVersionResource
|
var crGVR schema.GroupVersionResource
|
||||||
var crAPIVersion string
|
var crAPIVersion string
|
||||||
var cr *unstructured.Unstructured
|
var cr *unstructured.Unstructured
|
||||||
var crPolicy *policyv1alpha1.PropagationPolicy
|
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
crdGroup = fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
crdGroup = fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
||||||
|
@ -256,7 +253,7 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
|
|
||||||
crAPIVersion = fmt.Sprintf("%s/%s", crd.Spec.Group, "v1alpha1")
|
crAPIVersion = fmt.Sprintf("%s/%s", crd.Spec.Group, "v1alpha1")
|
||||||
cr = testhelper.NewCustomResource(crAPIVersion, crd.Spec.Names.Kind, crNamespace, crName)
|
cr = testhelper.NewCustomResource(crAPIVersion, crd.Spec.Names.Kind, crNamespace, crName)
|
||||||
crPolicy = testhelper.NewPropagationPolicy(crNamespace, crName, []policyv1alpha1.ResourceSelector{
|
policy = testhelper.NewPropagationPolicy(crNamespace, crName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: crAPIVersion,
|
APIVersion: crAPIVersion,
|
||||||
Kind: crd.Spec.Names.Kind,
|
Kind: crd.Spec.Names.Kind,
|
||||||
|
@ -272,6 +269,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreateClusterPropagationPolicy(karmadaClient, crdPolicy)
|
framework.CreateClusterPropagationPolicy(karmadaClient, crdPolicy)
|
||||||
framework.CreateCRD(dynamicClient, crd)
|
framework.CreateCRD(dynamicClient, crd)
|
||||||
|
framework.WaitCRDPresentOnClusters(karmadaClient, framework.ClusterNames(),
|
||||||
|
fmt.Sprintf("%s/%s", crd.Spec.Group, "v1alpha1"), crd.Spec.Names.Kind)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemoveClusterPropagationPolicy(karmadaClient, crdPolicy.Name)
|
framework.RemoveClusterPropagationPolicy(karmadaClient, crdPolicy.Name)
|
||||||
framework.RemoveCRD(dynamicClient, crd.Name)
|
framework.RemoveCRD(dynamicClient, crd.Name)
|
||||||
|
@ -279,15 +278,6 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("namespaceScoped cr propagation testing", func() {
|
ginkgo.It("namespaceScoped cr propagation testing", func() {
|
||||||
framework.GetCRD(dynamicClient, crd.Name)
|
|
||||||
framework.WaitCRDPresentOnClusters(karmadaClient, framework.ClusterNames(),
|
|
||||||
fmt.Sprintf("%s/%s", crd.Spec.Group, "v1alpha1"), crd.Spec.Names.Kind)
|
|
||||||
|
|
||||||
framework.CreatePropagationPolicy(karmadaClient, crPolicy)
|
|
||||||
ginkgo.DeferCleanup(func() {
|
|
||||||
framework.RemovePropagationPolicy(karmadaClient, crPolicy.Namespace, crPolicy.Name)
|
|
||||||
})
|
|
||||||
|
|
||||||
ginkgo.By(fmt.Sprintf("creating cr(%s/%s)", crNamespace, crName), func() {
|
ginkgo.By(fmt.Sprintf("creating cr(%s/%s)", crNamespace, crName), func() {
|
||||||
_, err := dynamicClient.Resource(crGVR).Namespace(crNamespace).Create(context.TODO(), cr, metav1.CreateOptions{})
|
_, err := dynamicClient.Resource(crGVR).Namespace(crNamespace).Create(context.TODO(), cr, metav1.CreateOptions{})
|
||||||
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
|
||||||
|
@ -383,10 +373,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Job propagation testing", func() {
|
ginkgo.Context("Job propagation testing", func() {
|
||||||
var policyNamespace, policyName string
|
|
||||||
var jobNamespace, jobName string
|
var jobNamespace, jobName string
|
||||||
var job *batchv1.Job
|
var job *batchv1.Job
|
||||||
var policy *policyv1alpha1.PropagationPolicy
|
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
policyNamespace = testNamespace
|
policyNamespace = testNamespace
|
||||||
|
@ -409,10 +397,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateJob(kubeClient, job)
|
framework.CreateJob(kubeClient, job)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
|
||||||
framework.RemoveJob(kubeClient, job.Namespace, job.Name)
|
framework.RemoveJob(kubeClient, job.Namespace, job.Name)
|
||||||
framework.WaitJobDisappearOnClusters(framework.ClusterNames(), job.Namespace, job.Name)
|
framework.WaitJobDisappearOnClusters(framework.ClusterNames(), job.Namespace, job.Name)
|
||||||
})
|
})
|
||||||
|
@ -439,8 +425,6 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
ginkgo.Context("Role propagation testing", func() {
|
ginkgo.Context("Role propagation testing", func() {
|
||||||
var (
|
var (
|
||||||
roleNamespace, roleName string
|
roleNamespace, roleName string
|
||||||
policyName string
|
|
||||||
policy *policyv1alpha1.PropagationPolicy
|
|
||||||
role *rbacv1.Role
|
role *rbacv1.Role
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -464,10 +448,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateRole(kubeClient, role)
|
framework.CreateRole(kubeClient, role)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
|
||||||
framework.RemoveRole(kubeClient, role.Namespace, role.Name)
|
framework.RemoveRole(kubeClient, role.Namespace, role.Name)
|
||||||
framework.WaitRoleDisappearOnClusters(framework.ClusterNames(), role.Namespace, role.Name)
|
framework.WaitRoleDisappearOnClusters(framework.ClusterNames(), role.Namespace, role.Name)
|
||||||
})
|
})
|
||||||
|
@ -484,8 +466,6 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
ginkgo.Context("RoleBinding propagation testing", func() {
|
ginkgo.Context("RoleBinding propagation testing", func() {
|
||||||
var (
|
var (
|
||||||
roleBindingNamespace, roleBindingName string
|
roleBindingNamespace, roleBindingName string
|
||||||
policyName string
|
|
||||||
policy *policyv1alpha1.PropagationPolicy
|
|
||||||
roleBinding *rbacv1.RoleBinding
|
roleBinding *rbacv1.RoleBinding
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -509,10 +489,8 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateRoleBinding(kubeClient, roleBinding)
|
framework.CreateRoleBinding(kubeClient, roleBinding)
|
||||||
ginkgo.DeferCleanup(func() {
|
ginkgo.DeferCleanup(func() {
|
||||||
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
|
||||||
framework.RemoveRoleBinding(kubeClient, roleBinding.Namespace, roleBinding.Name)
|
framework.RemoveRoleBinding(kubeClient, roleBinding.Namespace, roleBinding.Name)
|
||||||
framework.WaitRoleBindingDisappearOnClusters(framework.ClusterNames(), roleBinding.Namespace, roleBinding.Name)
|
framework.WaitRoleBindingDisappearOnClusters(framework.ClusterNames(), roleBinding.Namespace, roleBinding.Name)
|
||||||
})
|
})
|
||||||
|
@ -527,9 +505,67 @@ var _ = ginkgo.Describe("[BasicPropagation] propagation testing", func() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var _ = ginkgo.Describe("[CornerCase] PropagationPolicy testing", func() {
|
||||||
|
var policyNamespace, policyName string
|
||||||
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
|
ginkgo.JustBeforeEach(func() {
|
||||||
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
|
ginkgo.DeferCleanup(func() {
|
||||||
|
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.Context("Propagate Deployment with long pp name (exceed 63 character)", func() {
|
||||||
|
var deploymentNamespace, deploymentName string
|
||||||
|
var deployment *appsv1.Deployment
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
policyNamespace = testNamespace
|
||||||
|
policyName = deploymentNamePrefix + "-longname-longname-longname-longname-longname-longname-" + rand.String(RandomStrLength)
|
||||||
|
deploymentNamespace = testNamespace
|
||||||
|
deploymentName = policyName
|
||||||
|
|
||||||
|
deployment = testhelper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
|
ginkgo.DeferCleanup(func() {
|
||||||
|
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
||||||
|
framework.WaitDeploymentDisappearOnClusters(framework.ClusterNames(), deployment.Namespace, deployment.Name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.It("deployment propagation testing", func() {
|
||||||
|
framework.WaitDeploymentPresentOnClustersFitWith(framework.ClusterNames(), deployment.Namespace, deployment.Name,
|
||||||
|
func(*appsv1.Deployment) bool {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
framework.UpdateDeploymentReplicas(kubeClient, deployment, updateDeploymentReplicas)
|
||||||
|
framework.WaitDeploymentPresentOnClustersFitWith(framework.ClusterNames(), deployment.Namespace, deployment.Name,
|
||||||
|
func(deployment *appsv1.Deployment) bool {
|
||||||
|
return *deployment.Spec.Replicas == updateDeploymentReplicas
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// ImplicitPriority more than one PP matches the object, we should choose the most suitable one.
|
// ImplicitPriority more than one PP matches the object, we should choose the most suitable one.
|
||||||
// Set it to run sequentially to avoid affecting other test cases.
|
// Set it to run sequentially to avoid affecting other test cases.
|
||||||
var _ = framework.SerialDescribe("[ImplicitPriority] propagation testing", func() {
|
var _ = framework.SerialDescribe("[ImplicitPriority] PropagationPolicy testing", func() {
|
||||||
ginkgo.Context("priorityMatchName propagation testing", func() {
|
ginkgo.Context("priorityMatchName propagation testing", func() {
|
||||||
var policyNamespace, priorityMatchName, priorityMatchLabelSelector, priorityMatchAll string
|
var policyNamespace, priorityMatchName, priorityMatchLabelSelector, priorityMatchAll string
|
||||||
var deploymentNamespace, deploymentName string
|
var deploymentNamespace, deploymentName string
|
||||||
|
@ -621,7 +657,7 @@ var _ = framework.SerialDescribe("[ImplicitPriority] propagation testing", func(
|
||||||
|
|
||||||
// ExplicitPriority more than one PP matches the object, we should select the one with the highest explicit priority, if the
|
// ExplicitPriority more than one PP matches the object, we should select the one with the highest explicit priority, if the
|
||||||
// explicit priority is same, select the one with the highest implicit priority.
|
// explicit priority is same, select the one with the highest implicit priority.
|
||||||
var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() {
|
var _ = ginkgo.Describe("[ExplicitPriority] PropagationPolicy testing", func() {
|
||||||
ginkgo.Context("high explicit/low priority/implicit priority PropagationPolicy propagation testing", func() {
|
ginkgo.Context("high explicit/low priority/implicit priority PropagationPolicy propagation testing", func() {
|
||||||
var policyNamespace, higherPriorityLabelSelector, lowerPriorityMatchName, implicitPriorityMatchName string
|
var policyNamespace, higherPriorityLabelSelector, lowerPriorityMatchName, implicitPriorityMatchName string
|
||||||
var deploymentNamespace, deploymentName string
|
var deploymentNamespace, deploymentName string
|
||||||
|
@ -781,7 +817,7 @@ var _ = ginkgo.Describe("[ExplicitPriority] propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
// AdvancedPropagation focus on some advanced propagation testing.
|
// AdvancedPropagation focus on some advanced propagation testing.
|
||||||
var _ = ginkgo.Describe("[AdvancedPropagation] propagation testing", func() {
|
var _ = ginkgo.Describe("[AdvancedCase] PropagationPolicy testing", func() {
|
||||||
ginkgo.Context("Edit PropagationPolicy ResourceSelectors", func() {
|
ginkgo.Context("Edit PropagationPolicy ResourceSelectors", func() {
|
||||||
var policy *policyv1alpha1.PropagationPolicy
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
var deployment01, deployment02 *appsv1.Deployment
|
var deployment01, deployment02 *appsv1.Deployment
|
||||||
|
|
Loading…
Reference in New Issue