Merge pull request #1603 from XiShanYongYe-Chang/move-initialize-into-setup-nodes
[E2E] Declare in container nodes, initialize in setup nodes
This commit is contained in:
commit
68b65f8b7b
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
@ -18,34 +19,44 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = ginkgo.Describe("Aggregated Kubernetes API Endpoint testing", func() {
|
var _ = ginkgo.Describe("Aggregated Kubernetes API Endpoint testing", func() {
|
||||||
member1, member2 := "member1", "member2"
|
var member1, member2 string
|
||||||
|
var saName, saNamespace string
|
||||||
|
var tomServiceAccount *corev1.ServiceAccount
|
||||||
|
var tomClusterRole *rbacv1.ClusterRole
|
||||||
|
var tomClusterRoleBinding *rbacv1.ClusterRoleBinding
|
||||||
|
var tomClusterRoleOnMember *rbacv1.ClusterRole
|
||||||
|
var tomClusterRoleBindingOnMember *rbacv1.ClusterRoleBinding
|
||||||
|
|
||||||
saName := fmt.Sprintf("tom-%s", rand.String(RandomStrLength))
|
ginkgo.BeforeEach(func() {
|
||||||
saNamespace := testNamespace
|
member1, member2 = "member1", "member2"
|
||||||
tomServiceAccount := helper.NewServiceaccount(saNamespace, saName)
|
|
||||||
tomClusterRole := helper.NewClusterRole(tomServiceAccount.Name, []rbacv1.PolicyRule{
|
|
||||||
{
|
|
||||||
APIGroups: []string{"cluster.karmada.io"},
|
|
||||||
Verbs: []string{"*"},
|
|
||||||
Resources: []string{"clusters/proxy"},
|
|
||||||
ResourceNames: []string{member1},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
tomClusterRoleBinding := helper.NewClusterRoleBinding(tomServiceAccount.Name, tomClusterRole.Name, []rbacv1.Subject{
|
|
||||||
{Kind: "ServiceAccount", Name: tomServiceAccount.Name, Namespace: tomServiceAccount.Namespace},
|
|
||||||
{Kind: "Group", Name: "system:serviceaccounts"},
|
|
||||||
{Kind: "Group", Name: "system:serviceaccounts:" + tomServiceAccount.Namespace},
|
|
||||||
})
|
|
||||||
|
|
||||||
tomClusterRoleOnMember := helper.NewClusterRole(tomServiceAccount.Name, []rbacv1.PolicyRule{
|
saName = fmt.Sprintf("tom-%s", rand.String(RandomStrLength))
|
||||||
{
|
saNamespace = testNamespace
|
||||||
APIGroups: []string{"*"},
|
tomServiceAccount = helper.NewServiceaccount(saNamespace, saName)
|
||||||
Verbs: []string{"*"},
|
tomClusterRole = helper.NewClusterRole(tomServiceAccount.Name, []rbacv1.PolicyRule{
|
||||||
Resources: []string{"*"},
|
{
|
||||||
},
|
APIGroups: []string{"cluster.karmada.io"},
|
||||||
})
|
Verbs: []string{"*"},
|
||||||
tomClusterRoleBindingOnMember := helper.NewClusterRoleBinding(tomServiceAccount.Name, tomClusterRoleOnMember.Name, []rbacv1.Subject{
|
Resources: []string{"clusters/proxy"},
|
||||||
{Kind: "ServiceAccount", Name: tomServiceAccount.Name, Namespace: tomServiceAccount.Namespace},
|
ResourceNames: []string{member1},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
tomClusterRoleBinding = helper.NewClusterRoleBinding(tomServiceAccount.Name, tomClusterRole.Name, []rbacv1.Subject{
|
||||||
|
{Kind: "ServiceAccount", Name: tomServiceAccount.Name, Namespace: tomServiceAccount.Namespace},
|
||||||
|
{Kind: "Group", Name: "system:serviceaccounts"},
|
||||||
|
{Kind: "Group", Name: "system:serviceaccounts:" + tomServiceAccount.Namespace},
|
||||||
|
})
|
||||||
|
|
||||||
|
tomClusterRoleOnMember = helper.NewClusterRole(tomServiceAccount.Name, []rbacv1.PolicyRule{
|
||||||
|
{
|
||||||
|
APIGroups: []string{"*"},
|
||||||
|
Verbs: []string{"*"},
|
||||||
|
Resources: []string{"*"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
tomClusterRoleBindingOnMember = helper.NewClusterRoleBinding(tomServiceAccount.Name, tomClusterRoleOnMember.Name, []rbacv1.Subject{
|
||||||
|
{Kind: "ServiceAccount", Name: tomServiceAccount.Name, Namespace: tomServiceAccount.Namespace},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Aggregated Kubernetes API Endpoint testing", func() {
|
ginkgo.Context("Aggregated Kubernetes API Endpoint testing", func() {
|
||||||
|
|
|
@ -14,25 +14,33 @@ import (
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[BasicClusterPropagation] basic cluster propagation testing", func() {
|
var _ = ginkgo.Describe("[BasicClusterPropagation] basic cluster propagation testing", func() {
|
||||||
ginkgo.Context("CustomResourceDefinition propagation testing", func() {
|
ginkgo.Context("CustomResourceDefinition propagation testing", func() {
|
||||||
crdGroup := fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
var crdGroup string
|
||||||
randStr := rand.String(RandomStrLength)
|
var randStr string
|
||||||
crdSpecNames := apiextensionsv1.CustomResourceDefinitionNames{
|
var crdSpecNames apiextensionsv1.CustomResourceDefinitionNames
|
||||||
Kind: fmt.Sprintf("Foo%s", randStr),
|
var crd *apiextensionsv1.CustomResourceDefinition
|
||||||
ListKind: fmt.Sprintf("Foo%sList", randStr),
|
var crdPolicy *policyv1alpha1.ClusterPropagationPolicy
|
||||||
Plural: fmt.Sprintf("foo%ss", randStr),
|
|
||||||
Singular: fmt.Sprintf("foo%s", randStr),
|
ginkgo.BeforeEach(func() {
|
||||||
}
|
crdGroup = fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
||||||
crd := testhelper.NewCustomResourceDefinition(crdGroup, crdSpecNames, apiextensionsv1.NamespaceScoped)
|
randStr = rand.String(RandomStrLength)
|
||||||
crdPolicy := testhelper.NewClusterPropagationPolicy(crd.Name, []policyv1alpha1.ResourceSelector{
|
crdSpecNames = apiextensionsv1.CustomResourceDefinitionNames{
|
||||||
{
|
Kind: fmt.Sprintf("Foo%s", randStr),
|
||||||
APIVersion: crd.APIVersion,
|
ListKind: fmt.Sprintf("Foo%sList", randStr),
|
||||||
Kind: crd.Kind,
|
Plural: fmt.Sprintf("foo%ss", randStr),
|
||||||
Name: crd.Name,
|
Singular: fmt.Sprintf("foo%s", randStr),
|
||||||
},
|
}
|
||||||
}, policyv1alpha1.Placement{
|
crd = testhelper.NewCustomResourceDefinition(crdGroup, crdSpecNames, apiextensionsv1.NamespaceScoped)
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
crdPolicy = testhelper.NewClusterPropagationPolicy(crd.Name, []policyv1alpha1.ResourceSelector{
|
||||||
ClusterNames: framework.ClusterNames(),
|
{
|
||||||
},
|
APIVersion: crd.APIVersion,
|
||||||
|
Kind: crd.Kind,
|
||||||
|
Name: crd.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("crd propagation testing", func() {
|
ginkgo.It("crd propagation testing", func() {
|
||||||
|
|
|
@ -14,152 +14,170 @@ import (
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[DependenciesDistributor] automatically propagate relevant resources testing", func() {
|
var _ = ginkgo.Describe("[DependenciesDistributor] automatically propagate relevant resources testing", func() {
|
||||||
ginkgo.Context("dependencies propagation testing", func() {
|
ginkgo.Context("dependencies propagation testing", func() {
|
||||||
initClusterNames := []string{"member1"}
|
var initClusterNames, updateClusterNames []string
|
||||||
updateClusterNames := []string{"member2"}
|
var policyName string
|
||||||
|
var deploymentName string
|
||||||
|
|
||||||
secretName := secretNamePrefix + rand.String(RandomStrLength)
|
ginkgo.BeforeEach(func() {
|
||||||
configMapName := configMapNamePrefix + rand.String(RandomStrLength)
|
initClusterNames = []string{"member1"}
|
||||||
secret := testhelper.NewSecret(testNamespace, secretName, map[string][]byte{"user": []byte("karmada")})
|
updateClusterNames = []string{"member2"}
|
||||||
configMap := testhelper.NewConfigMap(testNamespace, configMapName, map[string]string{"user": "karmada"})
|
|
||||||
|
|
||||||
ginkgo.It("configmap automatically propagation testing", func() {
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
deploymentName = policyName
|
||||||
deploymentName := policyName
|
|
||||||
|
|
||||||
deployment := testhelper.NewDeploymentReferencesConfigMap(testNamespace, deploymentName, configMapName)
|
|
||||||
policy := testhelper.NewPropagationPolicy(testNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: initClusterNames,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
policy.Spec.PropagateDeps = true
|
|
||||||
|
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
|
||||||
framework.CreateDeployment(kubeClient, deployment)
|
|
||||||
framework.CreateConfigMap(kubeClient, configMap)
|
|
||||||
|
|
||||||
ginkgo.By("check if the configmap is propagated automatically", func() {
|
|
||||||
framework.WaitDeploymentPresentOnClustersFitWith(initClusterNames, deployment.Namespace, deployment.Name,
|
|
||||||
func(deployment *appsv1.Deployment) bool {
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
framework.WaitConfigMapPresentOnClustersFitWith(initClusterNames, configMap.Namespace, configMapName,
|
|
||||||
func(configmap *corev1.ConfigMap) bool {
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
ginkgo.By("updating propagation policy's clusterNames", func() {
|
|
||||||
patch := []map[string]interface{}{
|
|
||||||
{
|
|
||||||
"op": "replace",
|
|
||||||
"path": "/spec/placement/clusterAffinity/clusterNames",
|
|
||||||
"value": updateClusterNames,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
framework.PatchPropagationPolicy(karmadaClient, policy.Namespace, policyName, patch, types.JSONPatchType)
|
|
||||||
framework.WaitDeploymentPresentOnClustersFitWith(updateClusterNames, deployment.Namespace, deploymentName,
|
|
||||||
func(deployment *appsv1.Deployment) bool {
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
framework.WaitConfigMapPresentOnClustersFitWith(updateClusterNames, configMap.Namespace, configMapName,
|
|
||||||
func(configmap *corev1.ConfigMap) bool {
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
ginkgo.By("updating configmap's data", func() {
|
|
||||||
patch := []map[string]interface{}{
|
|
||||||
{
|
|
||||||
"op": "replace",
|
|
||||||
"path": "/data/user",
|
|
||||||
"value": "karmada-e2e",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
framework.UpdateConfigMapWithPatch(kubeClient, configMap.Namespace, configMapName, patch, types.JSONPatchType)
|
|
||||||
framework.WaitConfigMapPresentOnClustersFitWith(updateClusterNames, configMap.Namespace, configMapName,
|
|
||||||
func(configmap *corev1.ConfigMap) bool {
|
|
||||||
for key, value := range configmap.Data {
|
|
||||||
if key == "user" && value == "karmada-e2e" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
|
||||||
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
|
||||||
framework.RemoveConfigMap(kubeClient, configMap.Namespace, configMapName)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("secret automatically propagation testing", func() {
|
ginkgo.When("configmap propagate automatically", func() {
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var configMapName string
|
||||||
deploymentName := policyName
|
var configMap *corev1.ConfigMap
|
||||||
|
|
||||||
deployment := testhelper.NewDeploymentReferencesSecret(testNamespace, deploymentName, secretName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := testhelper.NewPropagationPolicy(testNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
configMapName = configMapNamePrefix + rand.String(RandomStrLength)
|
||||||
{
|
configMap = testhelper.NewConfigMap(testNamespace, configMapName, map[string]string{"user": "karmada"})
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: initClusterNames,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
policy.Spec.PropagateDeps = true
|
ginkgo.It("configmap automatically propagation testing", func() {
|
||||||
|
deployment := testhelper.NewDeploymentReferencesConfigMap(testNamespace, deploymentName, configMapName)
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
policy := testhelper.NewPropagationPolicy(testNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
framework.CreateDeployment(kubeClient, deployment)
|
|
||||||
framework.CreateSecret(kubeClient, secret)
|
|
||||||
|
|
||||||
ginkgo.By("check if the secret is propagated automatically", func() {
|
|
||||||
framework.WaitDeploymentPresentOnClustersFitWith(initClusterNames, deployment.Namespace, deployment.Name,
|
|
||||||
func(deployment *appsv1.Deployment) bool {
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
|
|
||||||
framework.WaitSecretPresentOnClustersFitWith(initClusterNames, secret.Namespace, secretName,
|
|
||||||
func(secret *corev1.Secret) bool {
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
ginkgo.By("make the secret is not referenced by the deployment ", func() {
|
|
||||||
updateVolumes := []corev1.Volume{
|
|
||||||
{
|
{
|
||||||
Name: "vol-configmap",
|
APIVersion: deployment.APIVersion,
|
||||||
VolumeSource: corev1.VolumeSource{
|
Kind: deployment.Kind,
|
||||||
ConfigMap: &corev1.ConfigMapVolumeSource{
|
Name: deployment.Name,
|
||||||
LocalObjectReference: corev1.LocalObjectReference{
|
},
|
||||||
Name: configMapName,
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: initClusterNames,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
policy.Spec.PropagateDeps = true
|
||||||
|
|
||||||
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
|
framework.CreateConfigMap(kubeClient, configMap)
|
||||||
|
|
||||||
|
ginkgo.By("check if the configmap is propagated automatically", func() {
|
||||||
|
framework.WaitDeploymentPresentOnClustersFitWith(initClusterNames, deployment.Namespace, deployment.Name,
|
||||||
|
func(deployment *appsv1.Deployment) bool {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
framework.WaitConfigMapPresentOnClustersFitWith(initClusterNames, configMap.Namespace, configMapName,
|
||||||
|
func(configmap *corev1.ConfigMap) bool {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.By("updating propagation policy's clusterNames", func() {
|
||||||
|
patch := []map[string]interface{}{
|
||||||
|
{
|
||||||
|
"op": "replace",
|
||||||
|
"path": "/spec/placement/clusterAffinity/clusterNames",
|
||||||
|
"value": updateClusterNames,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
framework.PatchPropagationPolicy(karmadaClient, policy.Namespace, policyName, patch, types.JSONPatchType)
|
||||||
|
framework.WaitDeploymentPresentOnClustersFitWith(updateClusterNames, deployment.Namespace, deploymentName,
|
||||||
|
func(deployment *appsv1.Deployment) bool {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
framework.WaitConfigMapPresentOnClustersFitWith(updateClusterNames, configMap.Namespace, configMapName,
|
||||||
|
func(configmap *corev1.ConfigMap) bool {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.By("updating configmap's data", func() {
|
||||||
|
patch := []map[string]interface{}{
|
||||||
|
{
|
||||||
|
"op": "replace",
|
||||||
|
"path": "/data/user",
|
||||||
|
"value": "karmada-e2e",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
framework.UpdateConfigMapWithPatch(kubeClient, configMap.Namespace, configMapName, patch, types.JSONPatchType)
|
||||||
|
framework.WaitConfigMapPresentOnClustersFitWith(updateClusterNames, configMap.Namespace, configMapName,
|
||||||
|
func(configmap *corev1.ConfigMap) bool {
|
||||||
|
for key, value := range configmap.Data {
|
||||||
|
if key == "user" && value == "karmada-e2e" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
||||||
|
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
||||||
|
framework.RemoveConfigMap(kubeClient, configMap.Namespace, configMapName)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.When("secret pragate automatically", func() {
|
||||||
|
var secretName string
|
||||||
|
var secret *corev1.Secret
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
secretName = secretNamePrefix + rand.String(RandomStrLength)
|
||||||
|
secret = testhelper.NewSecret(testNamespace, secretName, map[string][]byte{"user": []byte("karmada")})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.It("secret automatically propagation testing", func() {
|
||||||
|
deployment := testhelper.NewDeploymentReferencesSecret(testNamespace, deploymentName, secretName)
|
||||||
|
policy := testhelper.NewPropagationPolicy(testNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: initClusterNames,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
policy.Spec.PropagateDeps = true
|
||||||
|
|
||||||
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
|
framework.CreateSecret(kubeClient, secret)
|
||||||
|
|
||||||
|
ginkgo.By("check if the secret is propagated automatically", func() {
|
||||||
|
framework.WaitDeploymentPresentOnClustersFitWith(initClusterNames, deployment.Namespace, deployment.Name,
|
||||||
|
func(deployment *appsv1.Deployment) bool {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
framework.WaitSecretPresentOnClustersFitWith(initClusterNames, secret.Namespace, secretName,
|
||||||
|
func(secret *corev1.Secret) bool {
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.By("make the secret is not referenced by the deployment ", func() {
|
||||||
|
updateVolumes := []corev1.Volume{
|
||||||
|
{
|
||||||
|
Name: "vol-configmap",
|
||||||
|
VolumeSource: corev1.VolumeSource{
|
||||||
|
ConfigMap: &corev1.ConfigMapVolumeSource{
|
||||||
|
LocalObjectReference: corev1.LocalObjectReference{
|
||||||
|
Name: "configMap-test",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
|
|
||||||
framework.UpdateDeploymentVolumes(kubeClient, deployment, updateVolumes)
|
framework.UpdateDeploymentVolumes(kubeClient, deployment, updateVolumes)
|
||||||
framework.WaitSecretDisappearOnClusters(initClusterNames, secret.Namespace, secretName)
|
framework.WaitSecretDisappearOnClusters(initClusterNames, secret.Namespace, secretName)
|
||||||
|
})
|
||||||
|
|
||||||
|
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
||||||
|
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
||||||
|
framework.RemoveSecret(kubeClient, secret.Namespace, secretName)
|
||||||
})
|
})
|
||||||
|
|
||||||
framework.RemoveDeployment(kubeClient, deployment.Namespace, deployment.Name)
|
|
||||||
framework.RemovePropagationPolicy(karmadaClient, policy.Namespace, policy.Name)
|
|
||||||
framework.RemoveSecret(kubeClient, secret.Namespace, secretName)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -24,37 +25,45 @@ import (
|
||||||
// failover testing is used to test the rescheduling situation when some initially scheduled clusters fail
|
// failover testing is used to test the rescheduling situation when some initially scheduled clusters fail
|
||||||
var _ = ginkgo.Describe("failover testing", func() {
|
var _ = ginkgo.Describe("failover testing", func() {
|
||||||
ginkgo.Context("Deployment propagation testing", func() {
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
deploymentName := policyName
|
var maxGroups, minGroups, numOfFailedClusters int
|
||||||
deployment := testhelper.NewDeployment(deploymentNamespace, deploymentName)
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
maxGroups := 1
|
|
||||||
minGroups := 1
|
|
||||||
numOfFailedClusters := 1
|
|
||||||
|
|
||||||
// set MaxGroups=MinGroups=1, label is location=CHN.
|
ginkgo.BeforeEach(func() {
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: deployment.APIVersion,
|
deploymentNamespace = testNamespace
|
||||||
Kind: deployment.Kind,
|
deploymentName = policyName
|
||||||
Name: deployment.Name,
|
deployment = testhelper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
},
|
maxGroups = 1
|
||||||
}, policyv1alpha1.Placement{
|
minGroups = 1
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
numOfFailedClusters = 1
|
||||||
LabelSelector: &metav1.LabelSelector{
|
|
||||||
// only test push mode clusters
|
// set MaxGroups=MinGroups=1, label is location=CHN.
|
||||||
// because pull mode clusters cannot be disabled by changing APIEndpoint
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
MatchLabels: pushModeClusterLabels,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
SpreadConstraints: []policyv1alpha1.SpreadConstraint{
|
|
||||||
{
|
{
|
||||||
SpreadByField: policyv1alpha1.SpreadByFieldCluster,
|
APIVersion: deployment.APIVersion,
|
||||||
MaxGroups: maxGroups,
|
Kind: deployment.Kind,
|
||||||
MinGroups: minGroups,
|
Name: deployment.Name,
|
||||||
},
|
},
|
||||||
},
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
LabelSelector: &metav1.LabelSelector{
|
||||||
|
// only test push mode clusters
|
||||||
|
// because pull mode clusters cannot be disabled by changing APIEndpoint
|
||||||
|
MatchLabels: pushModeClusterLabels,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
SpreadConstraints: []policyv1alpha1.SpreadConstraint{
|
||||||
|
{
|
||||||
|
SpreadByField: policyv1alpha1.SpreadByFieldCluster,
|
||||||
|
MaxGroups: maxGroups,
|
||||||
|
MinGroups: minGroups,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("deployment failover testing", func() {
|
ginkgo.It("deployment failover testing", func() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
|
||||||
|
policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
|
||||||
"github.com/karmada-io/karmada/pkg/karmadactl"
|
"github.com/karmada-io/karmada/pkg/karmadactl"
|
||||||
"github.com/karmada-io/karmada/pkg/karmadactl/options"
|
"github.com/karmada-io/karmada/pkg/karmadactl/options"
|
||||||
"github.com/karmada-io/karmada/pkg/util"
|
"github.com/karmada-io/karmada/pkg/util"
|
||||||
|
@ -20,11 +21,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[FederatedResourceQuota] auto-provision testing", func() {
|
var _ = ginkgo.Describe("[FederatedResourceQuota] auto-provision testing", func() {
|
||||||
ginkgo.Context("create a federatedResourceQuota", func() {
|
var frqNamespace, frqName string
|
||||||
frqNamespace := testNamespace
|
var federatedResourceQuota *policyv1alpha1.FederatedResourceQuota
|
||||||
frqName := federatedResourceQuotaPrefix + rand.String(RandomStrLength)
|
|
||||||
federatedResourceQuota := helper.NewFederatedResourceQuota(frqNamespace, frqName)
|
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
frqNamespace = testNamespace
|
||||||
|
frqName = federatedResourceQuotaPrefix + rand.String(RandomStrLength)
|
||||||
|
federatedResourceQuota = helper.NewFederatedResourceQuota(frqNamespace, frqName)
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.Context("create a federatedResourceQuota", func() {
|
||||||
ginkgo.AfterEach(func() {
|
ginkgo.AfterEach(func() {
|
||||||
framework.RemoveFederatedResourceQuota(karmadaClient, frqNamespace, frqName)
|
framework.RemoveFederatedResourceQuota(karmadaClient, frqNamespace, frqName)
|
||||||
})
|
})
|
||||||
|
@ -36,10 +42,6 @@ var _ = ginkgo.Describe("[FederatedResourceQuota] auto-provision testing", func(
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("delete a federatedResourceQuota", func() {
|
ginkgo.Context("delete a federatedResourceQuota", func() {
|
||||||
frqNamespace := testNamespace
|
|
||||||
frqName := federatedResourceQuotaPrefix + rand.String(RandomStrLength)
|
|
||||||
federatedResourceQuota := helper.NewFederatedResourceQuota(frqNamespace, frqName)
|
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreateFederatedResourceQuota(karmadaClient, federatedResourceQuota)
|
framework.CreateFederatedResourceQuota(karmadaClient, federatedResourceQuota)
|
||||||
framework.WaitResourceQuotaPresentOnClusters(framework.ClusterNames(), frqNamespace, frqName)
|
framework.WaitResourceQuotaPresentOnClusters(framework.ClusterNames(), frqNamespace, frqName)
|
||||||
|
@ -52,15 +54,19 @@ var _ = ginkgo.Describe("[FederatedResourceQuota] auto-provision testing", func(
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("join new cluster", func() {
|
ginkgo.Context("join new cluster", func() {
|
||||||
frqNamespace := testNamespace
|
var clusterName string
|
||||||
frqName := federatedResourceQuotaPrefix + rand.String(RandomStrLength)
|
var homeDir string
|
||||||
federatedResourceQuota := helper.NewFederatedResourceQuota(frqNamespace, frqName)
|
var kubeConfigPath string
|
||||||
|
var controlPlane string
|
||||||
|
var clusterContext string
|
||||||
|
|
||||||
clusterName := "member-e2e-" + rand.String(3)
|
ginkgo.BeforeEach(func() {
|
||||||
homeDir := os.Getenv("HOME")
|
clusterName = "member-e2e-" + rand.String(3)
|
||||||
kubeConfigPath := fmt.Sprintf("%s/.kube/%s.config", homeDir, clusterName)
|
homeDir = os.Getenv("HOME")
|
||||||
controlPlane := fmt.Sprintf("%s-control-plane", clusterName)
|
kubeConfigPath = fmt.Sprintf("%s/.kube/%s.config", homeDir, clusterName)
|
||||||
clusterContext := fmt.Sprintf("kind-%s", clusterName)
|
controlPlane = fmt.Sprintf("%s-control-plane", clusterName)
|
||||||
|
clusterContext = fmt.Sprintf("kind-%s", clusterName)
|
||||||
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreateFederatedResourceQuota(karmadaClient, federatedResourceQuota)
|
framework.CreateFederatedResourceQuota(karmadaClient, federatedResourceQuota)
|
||||||
|
@ -134,11 +140,16 @@ var _ = ginkgo.Describe("[FederatedResourceQuota] auto-provision testing", func(
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[FederatedResourceQuota] status collection testing", func() {
|
var _ = ginkgo.Describe("[FederatedResourceQuota] status collection testing", func() {
|
||||||
ginkgo.Context("collect federatedResourceQuota status", func() {
|
var frqNamespace, frqName string
|
||||||
frqNamespace := testNamespace
|
var federatedResourceQuota *policyv1alpha1.FederatedResourceQuota
|
||||||
frqName := federatedResourceQuotaPrefix + rand.String(RandomStrLength)
|
|
||||||
federatedResourceQuota := helper.NewFederatedResourceQuota(frqNamespace, frqName)
|
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
frqNamespace = testNamespace
|
||||||
|
frqName = federatedResourceQuotaPrefix + rand.String(RandomStrLength)
|
||||||
|
federatedResourceQuota = helper.NewFederatedResourceQuota(frqNamespace, frqName)
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.Context("collect federatedResourceQuota status", func() {
|
||||||
ginkgo.AfterEach(func() {
|
ginkgo.AfterEach(func() {
|
||||||
framework.RemoveFederatedResourceQuota(karmadaClient, frqNamespace, frqName)
|
framework.RemoveFederatedResourceQuota(karmadaClient, frqNamespace, frqName)
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
@ -19,45 +20,56 @@ import (
|
||||||
|
|
||||||
var _ = ginkgo.Describe("propagation with fieldSelector testing", func() {
|
var _ = ginkgo.Describe("propagation with fieldSelector testing", func() {
|
||||||
ginkgo.Context("Deployment propagation testing", func() {
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
deploymentName := policyName
|
var originalClusterProviderInfo, originalClusterRegionInfo map[string]string
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
var desiredProvider, undesiredRegion []string
|
||||||
|
var desiredScheduleResult string
|
||||||
|
var filedSelector *policyv1alpha1.FieldSelector
|
||||||
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
originalClusterProviderInfo := make(map[string]string)
|
ginkgo.BeforeEach(func() {
|
||||||
originalClusterRegionInfo := make(map[string]string)
|
policyNamespace = testNamespace
|
||||||
desiredProvider := []string{"huaweicloud"}
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
undesiredRegion := []string{"cn-north-1"}
|
deploymentNamespace = testNamespace
|
||||||
desiredScheduleResult := "member1"
|
deploymentName = policyName
|
||||||
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
|
|
||||||
// desire to schedule to clusters of huaweicloud but not in cn-north-1 region
|
originalClusterProviderInfo = make(map[string]string)
|
||||||
filedSelector := &policyv1alpha1.FieldSelector{
|
originalClusterRegionInfo = make(map[string]string)
|
||||||
MatchExpressions: []corev1.NodeSelectorRequirement{
|
desiredProvider = []string{"huaweicloud"}
|
||||||
{
|
undesiredRegion = []string{"cn-north-1"}
|
||||||
Key: util.ProviderField,
|
desiredScheduleResult = "member1"
|
||||||
Operator: corev1.NodeSelectorOpIn,
|
|
||||||
Values: desiredProvider,
|
// desire to schedule to clusters of huaweicloud but not in cn-north-1 region
|
||||||
|
filedSelector = &policyv1alpha1.FieldSelector{
|
||||||
|
MatchExpressions: []corev1.NodeSelectorRequirement{
|
||||||
|
{
|
||||||
|
Key: util.ProviderField,
|
||||||
|
Operator: corev1.NodeSelectorOpIn,
|
||||||
|
Values: desiredProvider,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: util.RegionField,
|
||||||
|
Operator: corev1.NodeSelectorOpNotIn,
|
||||||
|
Values: undesiredRegion,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
}
|
||||||
Key: util.RegionField,
|
|
||||||
Operator: corev1.NodeSelectorOpNotIn,
|
|
||||||
Values: undesiredRegion,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: deployment.APIVersion,
|
APIVersion: deployment.APIVersion,
|
||||||
Kind: deployment.Kind,
|
Kind: deployment.Kind,
|
||||||
Name: deployment.Name,
|
Name: deployment.Name,
|
||||||
},
|
},
|
||||||
}, policyv1alpha1.Placement{
|
}, policyv1alpha1.Placement{
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
FieldSelector: filedSelector,
|
FieldSelector: filedSelector,
|
||||||
},
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
|
|
@ -176,30 +176,42 @@ func getPrepareInfo() (serviceExport mcsv1alpha1.ServiceExport, serviceImport mc
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[MCS] Multi-Cluster Service testing", func() {
|
var _ = ginkgo.Describe("[MCS] Multi-Cluster Service testing", func() {
|
||||||
serviceExportPolicyName := fmt.Sprintf("%s-%s-policy", serviceExportResource, rand.String(RandomStrLength))
|
var serviceExportPolicyName, serviceImportPolicyName string
|
||||||
serviceImportPolicyName := fmt.Sprintf("%s-%s-policy", serviceImportResource, rand.String(RandomStrLength))
|
var serviceExportPolicy, serviceImportPolicy *policyv1alpha1.ClusterPropagationPolicy
|
||||||
|
var serviceExport mcsv1alpha1.ServiceExport
|
||||||
|
var serviceImport mcsv1alpha1.ServiceImport
|
||||||
|
var exportPolicy, importPolicy *policyv1alpha1.PropagationPolicy
|
||||||
|
var demoDeployment appsv1.Deployment
|
||||||
|
var demoService corev1.Service
|
||||||
|
|
||||||
serviceExportPolicy := testhelper.NewClusterPropagationPolicy(serviceExportPolicyName, []policyv1alpha1.ResourceSelector{
|
ginkgo.BeforeEach(func() {
|
||||||
{
|
serviceExportPolicyName = fmt.Sprintf("%s-%s-policy", serviceExportResource, rand.String(RandomStrLength))
|
||||||
APIVersion: apiextensionsv1.SchemeGroupVersion.String(),
|
serviceImportPolicyName = fmt.Sprintf("%s-%s-policy", serviceImportResource, rand.String(RandomStrLength))
|
||||||
Kind: util.CRDKind,
|
|
||||||
Name: fmt.Sprintf("%s.%s", serviceExportResource, mcsv1alpha1.GroupName),
|
serviceExportPolicy = testhelper.NewClusterPropagationPolicy(serviceExportPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
},
|
{
|
||||||
}, policyv1alpha1.Placement{
|
APIVersion: apiextensionsv1.SchemeGroupVersion.String(),
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
Kind: util.CRDKind,
|
||||||
ClusterNames: framework.ClusterNames(),
|
Name: fmt.Sprintf("%s.%s", serviceExportResource, mcsv1alpha1.GroupName),
|
||||||
},
|
},
|
||||||
})
|
}, policyv1alpha1.Placement{
|
||||||
serviceImportPolicy := testhelper.NewClusterPropagationPolicy(serviceImportPolicyName, []policyv1alpha1.ResourceSelector{
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
{
|
ClusterNames: framework.ClusterNames(),
|
||||||
APIVersion: apiextensionsv1.SchemeGroupVersion.String(),
|
},
|
||||||
Kind: util.CRDKind,
|
})
|
||||||
Name: fmt.Sprintf("%s.%s", serviceImportResource, mcsv1alpha1.GroupName),
|
serviceImportPolicy = testhelper.NewClusterPropagationPolicy(serviceImportPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
},
|
{
|
||||||
}, policyv1alpha1.Placement{
|
APIVersion: apiextensionsv1.SchemeGroupVersion.String(),
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
Kind: util.CRDKind,
|
||||||
ClusterNames: framework.ClusterNames(),
|
Name: fmt.Sprintf("%s.%s", serviceImportResource, mcsv1alpha1.GroupName),
|
||||||
},
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
serviceExport, serviceImport, exportPolicy, importPolicy, demoDeployment, demoService = getPrepareInfo()
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
@ -218,8 +230,6 @@ var _ = ginkgo.Describe("[MCS] Multi-Cluster Service testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Connectivity testing", func() {
|
ginkgo.Context("Connectivity testing", func() {
|
||||||
serviceExport, serviceImport, exportPolicy, importPolicy, demoDeployment, demoService := getPrepareInfo()
|
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
exportClusterClient := framework.GetClusterClient(serviceExportClusterName)
|
exportClusterClient := framework.GetClusterClient(serviceExportClusterName)
|
||||||
gomega.Expect(exportClusterClient).ShouldNot(gomega.BeNil())
|
gomega.Expect(exportClusterClient).ShouldNot(gomega.BeNil())
|
||||||
|
@ -363,8 +373,6 @@ var _ = ginkgo.Describe("[MCS] Multi-Cluster Service testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("EndpointSlices change testing", func() {
|
ginkgo.Context("EndpointSlices change testing", func() {
|
||||||
serviceExport, serviceImport, exportPolicy, importPolicy, demoDeployment, demoService := getPrepareInfo()
|
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
exportClusterClient := framework.GetClusterClient(serviceExportClusterName)
|
exportClusterClient := framework.GetClusterClient(serviceExportClusterName)
|
||||||
gomega.Expect(exportClusterClient).ShouldNot(gomega.BeNil())
|
gomega.Expect(exportClusterClient).ShouldNot(gomega.BeNil())
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
corev1 "k8s.io/api/core/v1"
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
|
@ -21,11 +22,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[namespace auto-provision] namespace auto-provision testing", func() {
|
var _ = ginkgo.Describe("[namespace auto-provision] namespace auto-provision testing", func() {
|
||||||
|
var namespaceName string
|
||||||
|
var namespace *corev1.Namespace
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
namespaceName = "karmada-e2e-ns-" + rand.String(3)
|
||||||
|
namespace = helper.NewNamespace(namespaceName)
|
||||||
|
})
|
||||||
|
|
||||||
ginkgo.When("create a namespace in karmada-apiserver", func() {
|
ginkgo.When("create a namespace in karmada-apiserver", func() {
|
||||||
namespaceName := "karmada-e2e-ns-" + rand.String(3)
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
namespace := helper.NewNamespace(namespaceName)
|
|
||||||
framework.CreateNamespace(kubeClient, namespace)
|
framework.CreateNamespace(kubeClient, namespace)
|
||||||
})
|
})
|
||||||
ginkgo.AfterEach(func() {
|
ginkgo.AfterEach(func() {
|
||||||
|
@ -38,10 +44,7 @@ var _ = ginkgo.Describe("[namespace auto-provision] namespace auto-provision tes
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.When("delete a namespace from karmada apiserver", func() {
|
ginkgo.When("delete a namespace from karmada apiserver", func() {
|
||||||
namespaceName := "karmada-e2e-ns-" + rand.String(3)
|
ginkgo.BeforeEach(func() {
|
||||||
|
|
||||||
ginkgo.It("namespace should be propagated to member clusters", func() {
|
|
||||||
namespace := helper.NewNamespace(namespaceName)
|
|
||||||
framework.CreateNamespace(kubeClient, namespace)
|
framework.CreateNamespace(kubeClient, namespace)
|
||||||
framework.WaitNamespacePresentOnClusters(framework.ClusterNames(), namespaceName)
|
framework.WaitNamespacePresentOnClusters(framework.ClusterNames(), namespaceName)
|
||||||
})
|
})
|
||||||
|
@ -53,15 +56,21 @@ var _ = ginkgo.Describe("[namespace auto-provision] namespace auto-provision tes
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.When("joining new cluster", func() {
|
ginkgo.When("joining new cluster", func() {
|
||||||
clusterName := "member-e2e-" + rand.String(3)
|
var clusterName string
|
||||||
homeDir := os.Getenv("HOME")
|
var homeDir string
|
||||||
kubeConfigPath := fmt.Sprintf("%s/.kube/%s.config", homeDir, clusterName)
|
var kubeConfigPath string
|
||||||
controlPlane := fmt.Sprintf("%s-control-plane", clusterName)
|
var controlPlane string
|
||||||
clusterContext := fmt.Sprintf("kind-%s", clusterName)
|
var clusterContext string
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
clusterName = "member-e2e-" + rand.String(3)
|
||||||
|
homeDir = os.Getenv("HOME")
|
||||||
|
kubeConfigPath = fmt.Sprintf("%s/.kube/%s.config", homeDir, clusterName)
|
||||||
|
controlPlane = fmt.Sprintf("%s-control-plane", clusterName)
|
||||||
|
clusterContext = fmt.Sprintf("kind-%s", clusterName)
|
||||||
|
})
|
||||||
|
|
||||||
namespaceName := "karmada-e2e-ns-" + rand.String(3)
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
namespace := helper.NewNamespace(namespaceName)
|
|
||||||
framework.CreateNamespace(kubeClient, namespace)
|
framework.CreateNamespace(kubeClient, namespace)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -13,52 +13,62 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[OverridePolicy] apply overriders testing", func() {
|
var _ = ginkgo.Describe("[OverridePolicy] apply overriders testing", func() {
|
||||||
ginkgo.Context("Deployment override all images in container list", func() {
|
var propagationPolicyNamespace, propagationPolicyName string
|
||||||
deploymentNamespace := testNamespace
|
var overridePolicyNamespace, overridePolicyName string
|
||||||
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var propagationPolicy *policyv1alpha1.PropagationPolicy
|
||||||
propagationPolicyNamespace := testNamespace
|
var overridePolicy *policyv1alpha1.OverridePolicy
|
||||||
propagationPolicyName := deploymentName
|
|
||||||
overridePolicyNamespace := testNamespace
|
|
||||||
overridePolicyName := deploymentName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.Context("Deployment override all images in container list", func() {
|
||||||
propagationPolicy := helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
var deploymentNamespace, deploymentName string
|
||||||
{
|
var deployment *appsv1.Deployment
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
ginkgo.BeforeEach(func() {
|
||||||
Name: deployment.Name,
|
deploymentNamespace = testNamespace
|
||||||
},
|
deploymentName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
}, policyv1alpha1.Placement{
|
propagationPolicyNamespace = testNamespace
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
propagationPolicyName = deploymentName
|
||||||
|
overridePolicyNamespace = testNamespace
|
||||||
|
overridePolicyName = deploymentName
|
||||||
|
|
||||||
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
|
propagationPolicy = helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
overridePolicy = helper.NewOverridePolicy(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.ClusterAffinity{
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
}, policyv1alpha1.Overriders{
|
||||||
})
|
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
||||||
overridePolicy := helper.NewOverridePolicy(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
{
|
||||||
{
|
Component: "Registry",
|
||||||
APIVersion: deployment.APIVersion,
|
Operator: "replace",
|
||||||
Kind: deployment.Kind,
|
Value: "fictional.registry.us",
|
||||||
Name: deployment.Name,
|
},
|
||||||
},
|
{
|
||||||
}, policyv1alpha1.ClusterAffinity{
|
Component: "Repository",
|
||||||
ClusterNames: framework.ClusterNames(),
|
Operator: "replace",
|
||||||
}, policyv1alpha1.Overriders{
|
Value: "busybox",
|
||||||
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
},
|
||||||
{
|
{
|
||||||
Component: "Registry",
|
Component: "Tag",
|
||||||
Operator: "replace",
|
Operator: "replace",
|
||||||
Value: "fictional.registry.us",
|
Value: "1.0",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
})
|
||||||
Component: "Repository",
|
|
||||||
Operator: "replace",
|
|
||||||
Value: "busybox",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Component: "Tag",
|
|
||||||
Operator: "replace",
|
|
||||||
Value: "1.0",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
@ -91,51 +101,56 @@ var _ = ginkgo.Describe("[OverridePolicy] apply overriders testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Pod override all images in container list", func() {
|
ginkgo.Context("Pod override all images in container list", func() {
|
||||||
podNamespace := testNamespace
|
var podNamespace, podName string
|
||||||
podName := podNamePrefix + rand.String(RandomStrLength)
|
var pod *corev1.Pod
|
||||||
propagationPolicyNamespace := testNamespace
|
|
||||||
propagationPolicyName := podName
|
|
||||||
overridePolicyNamespace := testNamespace
|
|
||||||
overridePolicyName := podName
|
|
||||||
|
|
||||||
pod := helper.NewPod(podNamespace, podName)
|
ginkgo.BeforeEach(func() {
|
||||||
propagationPolicy := helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
podNamespace = testNamespace
|
||||||
{
|
podName = podNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: pod.APIVersion,
|
propagationPolicyNamespace = testNamespace
|
||||||
Kind: pod.Kind,
|
propagationPolicyName = podName
|
||||||
Name: pod.Name,
|
overridePolicyNamespace = testNamespace
|
||||||
},
|
overridePolicyName = podName
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
pod = helper.NewPod(podNamespace, podName)
|
||||||
|
propagationPolicy = helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: pod.APIVersion,
|
||||||
|
Kind: pod.Kind,
|
||||||
|
Name: pod.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
overridePolicy = helper.NewOverridePolicy(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: pod.APIVersion,
|
||||||
|
Kind: pod.Kind,
|
||||||
|
Name: pod.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.ClusterAffinity{
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
}, policyv1alpha1.Overriders{
|
||||||
})
|
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
||||||
overridePolicy := helper.NewOverridePolicy(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
{
|
||||||
{
|
Component: "Registry",
|
||||||
APIVersion: pod.APIVersion,
|
Operator: "replace",
|
||||||
Kind: pod.Kind,
|
Value: "fictional.registry.us",
|
||||||
Name: pod.Name,
|
},
|
||||||
},
|
{
|
||||||
}, policyv1alpha1.ClusterAffinity{
|
Component: "Repository",
|
||||||
ClusterNames: framework.ClusterNames(),
|
Operator: "replace",
|
||||||
}, policyv1alpha1.Overriders{
|
Value: "busybox",
|
||||||
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
},
|
||||||
{
|
{
|
||||||
Component: "Registry",
|
Component: "Tag",
|
||||||
Operator: "replace",
|
Operator: "replace",
|
||||||
Value: "fictional.registry.us",
|
Value: "1.0",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
})
|
||||||
Component: "Repository",
|
|
||||||
Operator: "replace",
|
|
||||||
Value: "busybox",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Component: "Tag",
|
|
||||||
Operator: "replace",
|
|
||||||
Value: "1.0",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
@ -167,44 +182,49 @@ var _ = ginkgo.Describe("[OverridePolicy] apply overriders testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Deployment override specific images in container list", func() {
|
ginkgo.Context("Deployment override specific images in container list", func() {
|
||||||
deploymentNamespace := testNamespace
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deployment *appsv1.Deployment
|
||||||
propagationPolicyNamespace := testNamespace
|
|
||||||
propagationPolicyName := deploymentName
|
|
||||||
overridePolicyNamespace := testNamespace
|
|
||||||
overridePolicyName := deploymentName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
propagationPolicy := helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
deploymentNamespace = testNamespace
|
||||||
{
|
deploymentName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: deployment.APIVersion,
|
propagationPolicyNamespace = testNamespace
|
||||||
Kind: deployment.Kind,
|
propagationPolicyName = deploymentName
|
||||||
Name: deployment.Name,
|
overridePolicyNamespace = testNamespace
|
||||||
},
|
overridePolicyName = deploymentName
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
ClusterNames: framework.ClusterNames(),
|
propagationPolicy = helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
},
|
|
||||||
})
|
|
||||||
overridePolicy := helper.NewOverridePolicy(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
|
||||||
}, policyv1alpha1.Overriders{
|
|
||||||
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
|
||||||
{
|
{
|
||||||
Predicate: &policyv1alpha1.ImagePredicate{
|
APIVersion: deployment.APIVersion,
|
||||||
Path: "/spec/template/spec/containers/0/image",
|
Kind: deployment.Kind,
|
||||||
},
|
Name: deployment.Name,
|
||||||
Component: "Registry",
|
|
||||||
Operator: "replace",
|
|
||||||
Value: "fictional.registry.us",
|
|
||||||
},
|
},
|
||||||
},
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
overridePolicy = helper.NewOverridePolicy(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
}, policyv1alpha1.Overriders{
|
||||||
|
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
||||||
|
{
|
||||||
|
Predicate: &policyv1alpha1.ImagePredicate{
|
||||||
|
Path: "/spec/template/spec/containers/0/image",
|
||||||
|
},
|
||||||
|
Component: "Registry",
|
||||||
|
Operator: "replace",
|
||||||
|
Value: "fictional.registry.us",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
@ -233,16 +253,23 @@ var _ = ginkgo.Describe("[OverridePolicy] apply overriders testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = ginkgo.Describe("OverridePolicy with nil resourceSelectors", func() {
|
var _ = ginkgo.Describe("OverridePolicy with nil resourceSelectors", func() {
|
||||||
ginkgo.Context("Deployment override testing", func() {
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var propagationPolicyNamespace, propagationPolicyName string
|
||||||
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var overridePolicyNamespace, overridePolicyName string
|
||||||
propagationPolicyNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
propagationPolicyName := deploymentName
|
var propagationPolicy *policyv1alpha1.PropagationPolicy
|
||||||
overridePolicyNamespace := testNamespace
|
var overridePolicy *policyv1alpha1.OverridePolicy
|
||||||
overridePolicyName := deploymentName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
propagationPolicy := helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
deploymentNamespace = testNamespace
|
||||||
|
deploymentName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
|
propagationPolicyNamespace = testNamespace
|
||||||
|
propagationPolicyName = deploymentName
|
||||||
|
overridePolicyNamespace = testNamespace
|
||||||
|
overridePolicyName = deploymentName
|
||||||
|
|
||||||
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
|
propagationPolicy = helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: deployment.APIVersion,
|
APIVersion: deployment.APIVersion,
|
||||||
Kind: deployment.Kind,
|
Kind: deployment.Kind,
|
||||||
|
@ -253,7 +280,7 @@ var _ = ginkgo.Describe("OverridePolicy with nil resourceSelectors", func() {
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
overridePolicy := helper.NewOverridePolicy(overridePolicyNamespace, overridePolicyName, nil, policyv1alpha1.ClusterAffinity{
|
overridePolicy = helper.NewOverridePolicy(overridePolicyNamespace, overridePolicyName, nil, policyv1alpha1.ClusterAffinity{
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
}, policyv1alpha1.Overriders{
|
}, policyv1alpha1.Overriders{
|
||||||
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
||||||
|
@ -267,7 +294,9 @@ var _ = ginkgo.Describe("OverridePolicy with nil resourceSelectors", func() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.Context("Deployment override testing", func() {
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, propagationPolicy)
|
framework.CreatePropagationPolicy(karmadaClient, propagationPolicy)
|
||||||
framework.CreateOverridePolicy(karmadaClient, overridePolicy)
|
framework.CreateOverridePolicy(karmadaClient, overridePolicy)
|
||||||
|
@ -294,57 +323,67 @@ var _ = ginkgo.Describe("OverridePolicy with nil resourceSelectors", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = ginkgo.Describe("[OverrideRules] apply overriders testing", func() {
|
var _ = ginkgo.Describe("[OverrideRules] apply overriders testing", func() {
|
||||||
ginkgo.Context("Deployment override all images in container list", func() {
|
var propagationPolicyNamespace, propagationPolicyName string
|
||||||
deploymentNamespace := testNamespace
|
var overridePolicyNamespace, overridePolicyName string
|
||||||
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var propagationPolicy *policyv1alpha1.PropagationPolicy
|
||||||
propagationPolicyNamespace := testNamespace
|
var overridePolicy *policyv1alpha1.OverridePolicy
|
||||||
propagationPolicyName := deploymentName
|
|
||||||
overridePolicyNamespace := testNamespace
|
|
||||||
overridePolicyName := deploymentName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.Context("Deployment override all images in container list", func() {
|
||||||
propagationPolicy := helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
var deploymentNamespace, deploymentName string
|
||||||
{
|
var deployment *appsv1.Deployment
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
ginkgo.BeforeEach(func() {
|
||||||
Name: deployment.Name,
|
deploymentNamespace = testNamespace
|
||||||
},
|
deploymentName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
}, policyv1alpha1.Placement{
|
propagationPolicyNamespace = testNamespace
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
propagationPolicyName = deploymentName
|
||||||
ClusterNames: framework.ClusterNames(),
|
overridePolicyNamespace = testNamespace
|
||||||
},
|
overridePolicyName = deploymentName
|
||||||
})
|
|
||||||
overridePolicy := helper.NewOverridePolicyByOverrideRules(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
{
|
propagationPolicy = helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
APIVersion: deployment.APIVersion,
|
{
|
||||||
Kind: deployment.Kind,
|
APIVersion: deployment.APIVersion,
|
||||||
Name: deployment.Name,
|
Kind: deployment.Kind,
|
||||||
},
|
Name: deployment.Name,
|
||||||
}, []policyv1alpha1.RuleWithCluster{
|
},
|
||||||
{
|
}, policyv1alpha1.Placement{
|
||||||
TargetCluster: &policyv1alpha1.ClusterAffinity{
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
},
|
||||||
Overriders: policyv1alpha1.Overriders{
|
})
|
||||||
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
overridePolicy = helper.NewOverridePolicyByOverrideRules(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
Component: "Registry",
|
APIVersion: deployment.APIVersion,
|
||||||
Operator: "replace",
|
Kind: deployment.Kind,
|
||||||
Value: "fictional.registry.us",
|
Name: deployment.Name,
|
||||||
},
|
},
|
||||||
{
|
}, []policyv1alpha1.RuleWithCluster{
|
||||||
Component: "Repository",
|
{
|
||||||
Operator: "replace",
|
TargetCluster: &policyv1alpha1.ClusterAffinity{
|
||||||
Value: "busybox",
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
},
|
||||||
{
|
Overriders: policyv1alpha1.Overriders{
|
||||||
Component: "Tag",
|
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
||||||
Operator: "replace",
|
{
|
||||||
Value: "1.0",
|
Component: "Registry",
|
||||||
|
Operator: "replace",
|
||||||
|
Value: "fictional.registry.us",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Component: "Repository",
|
||||||
|
Operator: "replace",
|
||||||
|
Value: "busybox",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Component: "Tag",
|
||||||
|
Operator: "replace",
|
||||||
|
Value: "1.0",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
@ -377,56 +416,61 @@ var _ = ginkgo.Describe("[OverrideRules] apply overriders testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Pod override all images in container list", func() {
|
ginkgo.Context("Pod override all images in container list", func() {
|
||||||
podNamespace := testNamespace
|
var podNamespace, podName string
|
||||||
podName := podNamePrefix + rand.String(RandomStrLength)
|
var pod *corev1.Pod
|
||||||
propagationPolicyNamespace := testNamespace
|
|
||||||
propagationPolicyName := podName
|
|
||||||
overridePolicyNamespace := testNamespace
|
|
||||||
overridePolicyName := podName
|
|
||||||
|
|
||||||
pod := helper.NewPod(podNamespace, podName)
|
ginkgo.BeforeEach(func() {
|
||||||
propagationPolicy := helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
podNamespace = testNamespace
|
||||||
{
|
podName = podNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: pod.APIVersion,
|
propagationPolicyNamespace = testNamespace
|
||||||
Kind: pod.Kind,
|
propagationPolicyName = podName
|
||||||
Name: pod.Name,
|
overridePolicyNamespace = testNamespace
|
||||||
},
|
overridePolicyName = podName
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
pod = helper.NewPod(podNamespace, podName)
|
||||||
ClusterNames: framework.ClusterNames(),
|
propagationPolicy = helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
},
|
{
|
||||||
})
|
APIVersion: pod.APIVersion,
|
||||||
overridePolicy := helper.NewOverridePolicyByOverrideRules(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
Kind: pod.Kind,
|
||||||
{
|
Name: pod.Name,
|
||||||
APIVersion: pod.APIVersion,
|
},
|
||||||
Kind: pod.Kind,
|
}, policyv1alpha1.Placement{
|
||||||
Name: pod.Name,
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
},
|
|
||||||
}, []policyv1alpha1.RuleWithCluster{
|
|
||||||
{
|
|
||||||
TargetCluster: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
},
|
||||||
Overriders: policyv1alpha1.Overriders{
|
})
|
||||||
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
overridePolicy = helper.NewOverridePolicyByOverrideRules(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
Component: "Registry",
|
APIVersion: pod.APIVersion,
|
||||||
Operator: "replace",
|
Kind: pod.Kind,
|
||||||
Value: "fictional.registry.us",
|
Name: pod.Name,
|
||||||
},
|
},
|
||||||
{
|
}, []policyv1alpha1.RuleWithCluster{
|
||||||
Component: "Repository",
|
{
|
||||||
Operator: "replace",
|
TargetCluster: &policyv1alpha1.ClusterAffinity{
|
||||||
Value: "busybox",
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
},
|
||||||
{
|
Overriders: policyv1alpha1.Overriders{
|
||||||
Component: "Tag",
|
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
||||||
Operator: "replace",
|
{
|
||||||
Value: "1.0",
|
Component: "Registry",
|
||||||
|
Operator: "replace",
|
||||||
|
Value: "fictional.registry.us",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Component: "Repository",
|
||||||
|
Operator: "replace",
|
||||||
|
Value: "busybox",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Component: "Tag",
|
||||||
|
Operator: "replace",
|
||||||
|
Value: "1.0",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
@ -458,49 +502,54 @@ var _ = ginkgo.Describe("[OverrideRules] apply overriders testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Deployment override specific images in container list", func() {
|
ginkgo.Context("Deployment override specific images in container list", func() {
|
||||||
deploymentNamespace := testNamespace
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deployment *appsv1.Deployment
|
||||||
propagationPolicyNamespace := testNamespace
|
|
||||||
propagationPolicyName := deploymentName
|
|
||||||
overridePolicyNamespace := testNamespace
|
|
||||||
overridePolicyName := deploymentName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
propagationPolicy := helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
deploymentNamespace = testNamespace
|
||||||
{
|
deploymentName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: deployment.APIVersion,
|
propagationPolicyNamespace = testNamespace
|
||||||
Kind: deployment.Kind,
|
propagationPolicyName = deploymentName
|
||||||
Name: deployment.Name,
|
overridePolicyNamespace = testNamespace
|
||||||
},
|
overridePolicyName = deploymentName
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
ClusterNames: framework.ClusterNames(),
|
propagationPolicy = helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
},
|
{
|
||||||
})
|
APIVersion: deployment.APIVersion,
|
||||||
overridePolicy := helper.NewOverridePolicyByOverrideRules(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
Kind: deployment.Kind,
|
||||||
{
|
Name: deployment.Name,
|
||||||
APIVersion: deployment.APIVersion,
|
},
|
||||||
Kind: deployment.Kind,
|
}, policyv1alpha1.Placement{
|
||||||
Name: deployment.Name,
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
},
|
|
||||||
}, []policyv1alpha1.RuleWithCluster{
|
|
||||||
{
|
|
||||||
TargetCluster: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
},
|
||||||
Overriders: policyv1alpha1.Overriders{
|
})
|
||||||
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
overridePolicy = helper.NewOverridePolicyByOverrideRules(overridePolicyNamespace, overridePolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
Predicate: &policyv1alpha1.ImagePredicate{
|
APIVersion: deployment.APIVersion,
|
||||||
Path: "/spec/template/spec/containers/0/image",
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, []policyv1alpha1.RuleWithCluster{
|
||||||
|
{
|
||||||
|
TargetCluster: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
Overriders: policyv1alpha1.Overriders{
|
||||||
|
ImageOverrider: []policyv1alpha1.ImageOverrider{
|
||||||
|
{
|
||||||
|
Predicate: &policyv1alpha1.ImagePredicate{
|
||||||
|
Path: "/spec/template/spec/containers/0/image",
|
||||||
|
},
|
||||||
|
Component: "Registry",
|
||||||
|
Operator: "replace",
|
||||||
|
Value: "fictional.registry.us",
|
||||||
},
|
},
|
||||||
Component: "Registry",
|
|
||||||
Operator: "replace",
|
|
||||||
Value: "fictional.registry.us",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
@ -529,16 +578,23 @@ var _ = ginkgo.Describe("[OverrideRules] apply overriders testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
var _ = ginkgo.Describe("OverrideRules with nil resourceSelectors", func() {
|
var _ = ginkgo.Describe("OverrideRules with nil resourceSelectors", func() {
|
||||||
ginkgo.Context("Deployment override testing", func() {
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var propagationPolicyNamespace, propagationPolicyName string
|
||||||
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var overridePolicyNamespace, overridePolicyName string
|
||||||
propagationPolicyNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
propagationPolicyName := deploymentName
|
var propagationPolicy *policyv1alpha1.PropagationPolicy
|
||||||
overridePolicyNamespace := testNamespace
|
var overridePolicy *policyv1alpha1.OverridePolicy
|
||||||
overridePolicyName := deploymentName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
propagationPolicy := helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
deploymentNamespace = testNamespace
|
||||||
|
deploymentName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
|
propagationPolicyNamespace = testNamespace
|
||||||
|
propagationPolicyName = deploymentName
|
||||||
|
overridePolicyNamespace = testNamespace
|
||||||
|
overridePolicyName = deploymentName
|
||||||
|
|
||||||
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
|
propagationPolicy = helper.NewPropagationPolicy(propagationPolicyNamespace, propagationPolicyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: deployment.APIVersion,
|
APIVersion: deployment.APIVersion,
|
||||||
Kind: deployment.Kind,
|
Kind: deployment.Kind,
|
||||||
|
@ -550,7 +606,7 @@ var _ = ginkgo.Describe("OverrideRules with nil resourceSelectors", func() {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
overridePolicy := helper.NewOverridePolicyByOverrideRules(overridePolicyNamespace, overridePolicyName, nil, []policyv1alpha1.RuleWithCluster{
|
overridePolicy = helper.NewOverridePolicyByOverrideRules(overridePolicyNamespace, overridePolicyName, nil, []policyv1alpha1.RuleWithCluster{
|
||||||
{
|
{
|
||||||
TargetCluster: &policyv1alpha1.ClusterAffinity{
|
TargetCluster: &policyv1alpha1.ClusterAffinity{
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
@ -569,7 +625,9 @@ var _ = ginkgo.Describe("OverrideRules with nil resourceSelectors", func() {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.Context("Deployment override testing", func() {
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, propagationPolicy)
|
framework.CreatePropagationPolicy(karmadaClient, propagationPolicy)
|
||||||
framework.CreateOverridePolicy(karmadaClient, overridePolicy)
|
framework.CreateOverridePolicy(karmadaClient, overridePolicy)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
@ -19,22 +20,29 @@ import (
|
||||||
var _ = ginkgo.Describe("porting workloads testing", func() {
|
var _ = ginkgo.Describe("porting workloads testing", func() {
|
||||||
|
|
||||||
ginkgo.Context("porting workloads from legacy clusters testing", func() {
|
ginkgo.Context("porting workloads from legacy clusters testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
deploymentName := policyName
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: deployment.APIVersion,
|
deploymentNamespace = testNamespace
|
||||||
Kind: deployment.Kind,
|
deploymentName = policyName
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
}, policyv1alpha1.Placement{
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
{
|
||||||
ClusterNames: framework.ClusterNames(),
|
APIVersion: deployment.APIVersion,
|
||||||
},
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("porting Deployments from legacy clusters testing", func() {
|
ginkgo.It("porting Deployments from legacy clusters testing", func() {
|
||||||
|
|
|
@ -29,22 +29,29 @@ import (
|
||||||
// BasicPropagation focus on basic propagation functionality testing.
|
// BasicPropagation focus on basic propagation functionality testing.
|
||||||
var _ = ginkgo.Describe("[BasicPropagation] basic propagation testing", func() {
|
var _ = ginkgo.Describe("[BasicPropagation] basic propagation testing", func() {
|
||||||
ginkgo.Context("Deployment propagation testing", func() {
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
deploymentName := policyName
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
deployment := testhelper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: deployment.APIVersion,
|
deploymentNamespace = testNamespace
|
||||||
Kind: deployment.Kind,
|
deploymentName = policyName
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
deployment = testhelper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
}, policyv1alpha1.Placement{
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
{
|
||||||
ClusterNames: framework.ClusterNames(),
|
APIVersion: deployment.APIVersion,
|
||||||
},
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("deployment propagation testing", func() {
|
ginkgo.It("deployment propagation testing", func() {
|
||||||
|
@ -68,22 +75,29 @@ var _ = ginkgo.Describe("[BasicPropagation] basic propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Service propagation testing", func() {
|
ginkgo.Context("Service propagation testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := serviceNamePrefix + rand.String(RandomStrLength)
|
var serviceNamespace, serviceName string
|
||||||
serviceNamespace := policyNamespace
|
var service *corev1.Service
|
||||||
serviceName := policyName
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
service := testhelper.NewService(serviceNamespace, serviceName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = serviceNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: service.APIVersion,
|
serviceNamespace = policyNamespace
|
||||||
Kind: service.Kind,
|
serviceName = policyName
|
||||||
Name: service.Name,
|
|
||||||
},
|
service = testhelper.NewService(serviceNamespace, serviceName)
|
||||||
}, policyv1alpha1.Placement{
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
{
|
||||||
ClusterNames: framework.ClusterNames(),
|
APIVersion: service.APIVersion,
|
||||||
},
|
Kind: service.Kind,
|
||||||
|
Name: service.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("service propagation testing", func() {
|
ginkgo.It("service propagation testing", func() {
|
||||||
|
@ -109,22 +123,28 @@ var _ = ginkgo.Describe("[BasicPropagation] basic propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Pod propagation testing", func() {
|
ginkgo.Context("Pod propagation testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := podNamePrefix + rand.String(RandomStrLength)
|
var podNamespace, podName string
|
||||||
podNamespace := policyNamespace
|
var pod *corev1.Pod
|
||||||
podName := policyName
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
policyNamespace = testNamespace
|
||||||
|
policyName = podNamePrefix + rand.String(RandomStrLength)
|
||||||
|
podNamespace = policyNamespace
|
||||||
|
podName = policyName
|
||||||
|
|
||||||
pod := testhelper.NewPod(podNamespace, podName)
|
pod = testhelper.NewPod(podNamespace, podName)
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: pod.APIVersion,
|
APIVersion: pod.APIVersion,
|
||||||
Kind: pod.Kind,
|
Kind: pod.Kind,
|
||||||
Name: pod.Name,
|
Name: pod.Name,
|
||||||
},
|
},
|
||||||
}, policyv1alpha1.Placement{
|
}, policyv1alpha1.Placement{
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("pod propagation testing", func() {
|
ginkgo.It("pod propagation testing", func() {
|
||||||
|
@ -150,43 +170,56 @@ var _ = ginkgo.Describe("[BasicPropagation] basic propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("NamespaceScoped CustomResource propagation testing", func() {
|
ginkgo.Context("NamespaceScoped CustomResource propagation testing", func() {
|
||||||
crdGroup := fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
var crdGroup string
|
||||||
randStr := rand.String(RandomStrLength)
|
var randStr string
|
||||||
crdSpecNames := apiextensionsv1.CustomResourceDefinitionNames{
|
var crdSpecNames apiextensionsv1.CustomResourceDefinitionNames
|
||||||
Kind: fmt.Sprintf("Foo%s", randStr),
|
var crd *apiextensionsv1.CustomResourceDefinition
|
||||||
ListKind: fmt.Sprintf("Foo%sList", randStr),
|
var crdPolicy *policyv1alpha1.ClusterPropagationPolicy
|
||||||
Plural: fmt.Sprintf("foo%ss", randStr),
|
var crNamespace, crName string
|
||||||
Singular: fmt.Sprintf("foo%s", randStr),
|
var crGVR schema.GroupVersionResource
|
||||||
}
|
var crAPIVersion string
|
||||||
crd := testhelper.NewCustomResourceDefinition(crdGroup, crdSpecNames, apiextensionsv1.NamespaceScoped)
|
var cr *unstructured.Unstructured
|
||||||
crdPolicy := testhelper.NewClusterPropagationPolicy(crd.Name, []policyv1alpha1.ResourceSelector{
|
var crPolicy *policyv1alpha1.PropagationPolicy
|
||||||
{
|
|
||||||
APIVersion: crd.APIVersion,
|
|
||||||
Kind: crd.Kind,
|
|
||||||
Name: crd.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
crNamespace := testNamespace
|
ginkgo.BeforeEach(func() {
|
||||||
crName := crdNamePrefix + rand.String(RandomStrLength)
|
crdGroup = fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
||||||
crGVR := schema.GroupVersionResource{Group: crd.Spec.Group, Version: "v1alpha1", Resource: crd.Spec.Names.Plural}
|
randStr = rand.String(RandomStrLength)
|
||||||
|
crdSpecNames = apiextensionsv1.CustomResourceDefinitionNames{
|
||||||
|
Kind: fmt.Sprintf("Foo%s", randStr),
|
||||||
|
ListKind: fmt.Sprintf("Foo%sList", randStr),
|
||||||
|
Plural: fmt.Sprintf("foo%ss", randStr),
|
||||||
|
Singular: fmt.Sprintf("foo%s", randStr),
|
||||||
|
}
|
||||||
|
crd = testhelper.NewCustomResourceDefinition(crdGroup, crdSpecNames, apiextensionsv1.NamespaceScoped)
|
||||||
|
crdPolicy = testhelper.NewClusterPropagationPolicy(crd.Name, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: crd.APIVersion,
|
||||||
|
Kind: crd.Kind,
|
||||||
|
Name: crd.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
crAPIVersion := fmt.Sprintf("%s/%s", crd.Spec.Group, "v1alpha1")
|
crNamespace = testNamespace
|
||||||
cr := testhelper.NewCustomResource(crAPIVersion, crd.Spec.Names.Kind, crNamespace, crName)
|
crName = crdNamePrefix + rand.String(RandomStrLength)
|
||||||
crPolicy := testhelper.NewPropagationPolicy(crNamespace, crName, []policyv1alpha1.ResourceSelector{
|
crGVR = schema.GroupVersionResource{Group: crd.Spec.Group, Version: "v1alpha1", Resource: crd.Spec.Names.Plural}
|
||||||
{
|
|
||||||
APIVersion: crAPIVersion,
|
crAPIVersion = fmt.Sprintf("%s/%s", crd.Spec.Group, "v1alpha1")
|
||||||
Kind: crd.Spec.Names.Kind,
|
cr = testhelper.NewCustomResource(crAPIVersion, crd.Spec.Names.Kind, crNamespace, crName)
|
||||||
Name: crName,
|
crPolicy = testhelper.NewPropagationPolicy(crNamespace, crName, []policyv1alpha1.ResourceSelector{
|
||||||
},
|
{
|
||||||
}, policyv1alpha1.Placement{
|
APIVersion: crAPIVersion,
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
Kind: crd.Spec.Names.Kind,
|
||||||
ClusterNames: framework.ClusterNames(),
|
Name: crName,
|
||||||
},
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("namespaceScoped cr propagation testing", func() {
|
ginkgo.It("namespaceScoped cr propagation testing", func() {
|
||||||
|
@ -298,22 +331,29 @@ var _ = ginkgo.Describe("[BasicPropagation] basic propagation testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("Job propagation testing", func() {
|
ginkgo.Context("Job propagation testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := jobNamePrefix + rand.String(RandomStrLength)
|
var jobNamespace, jobName string
|
||||||
jobNamespace := testNamespace
|
var job *batchv1.Job
|
||||||
jobName := policyName
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
job := testhelper.NewJob(jobNamespace, jobName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = jobNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: job.APIVersion,
|
jobNamespace = testNamespace
|
||||||
Kind: job.Kind,
|
jobName = policyName
|
||||||
Name: job.Name,
|
|
||||||
},
|
job = testhelper.NewJob(jobNamespace, jobName)
|
||||||
}, policyv1alpha1.Placement{
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
{
|
||||||
ClusterNames: framework.ClusterNames(),
|
APIVersion: job.APIVersion,
|
||||||
},
|
Kind: job.Kind,
|
||||||
|
Name: job.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("job propagation testing", func() {
|
ginkgo.It("job propagation testing", func() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/pointer"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
@ -27,11 +28,19 @@ import (
|
||||||
// reschedule testing is used to test the rescheduling situation when some initially scheduled clusters are unjoined
|
// reschedule testing is used to test the rescheduling situation when some initially scheduled clusters are unjoined
|
||||||
var _ = ginkgo.Describe("reschedule testing", func() {
|
var _ = ginkgo.Describe("reschedule testing", func() {
|
||||||
ginkgo.Context("Deployment propagation testing", func() {
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
newClusterName := "member-e2e-" + rand.String(3)
|
var newClusterName string
|
||||||
homeDir := os.Getenv("HOME")
|
var homeDir string
|
||||||
kubeConfigPath := fmt.Sprintf("%s/.kube/%s.config", homeDir, newClusterName)
|
var kubeConfigPath string
|
||||||
controlPlane := fmt.Sprintf("%s-control-plane", newClusterName)
|
var controlPlane string
|
||||||
clusterContext := fmt.Sprintf("kind-%s", newClusterName)
|
var clusterContext string
|
||||||
|
|
||||||
|
ginkgo.BeforeEach(func() {
|
||||||
|
newClusterName = "member-e2e-" + rand.String(3)
|
||||||
|
homeDir = os.Getenv("HOME")
|
||||||
|
kubeConfigPath = fmt.Sprintf("%s/.kube/%s.config", homeDir, newClusterName)
|
||||||
|
controlPlane = fmt.Sprintf("%s-control-plane", newClusterName)
|
||||||
|
clusterContext = fmt.Sprintf("kind-%s", newClusterName)
|
||||||
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
ginkgo.By(fmt.Sprintf("Creating cluster: %s", newClusterName), func() {
|
ginkgo.By(fmt.Sprintf("Creating cluster: %s", newClusterName), func() {
|
||||||
|
@ -48,25 +57,32 @@ var _ = ginkgo.Describe("reschedule testing", func() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
deploymentName := policyName
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
deployment := testhelper.NewDeployment(deploymentNamespace, deploymentName)
|
|
||||||
deployment.Spec.Replicas = pointer.Int32Ptr(10)
|
|
||||||
|
|
||||||
// set MaxGroups=MinGroups=1, label is sync-mode=Push.
|
ginkgo.BeforeEach(func() {
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: deployment.APIVersion,
|
deploymentNamespace = testNamespace
|
||||||
Kind: deployment.Kind,
|
deploymentName = policyName
|
||||||
Name: deployment.Name,
|
deployment = testhelper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
},
|
deployment.Spec.Replicas = pointer.Int32Ptr(10)
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
// set MaxGroups=MinGroups=1, label is sync-mode=Push.
|
||||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
{
|
||||||
},
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
||||||
|
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
||||||
|
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("deployment reschedule testing", func() {
|
ginkgo.It("deployment reschedule testing", func() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
@ -18,22 +19,29 @@ import (
|
||||||
var _ = ginkgo.Describe("[resource-status collection] resource status collection testing", func() {
|
var _ = ginkgo.Describe("[resource-status collection] resource status collection testing", func() {
|
||||||
|
|
||||||
ginkgo.Context("DeploymentStatus collection testing", func() {
|
ginkgo.Context("DeploymentStatus collection testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
deploymentName := policyName
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: deployment.APIVersion,
|
deploymentNamespace = testNamespace
|
||||||
Kind: deployment.Kind,
|
deploymentName = policyName
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
}, policyv1alpha1.Placement{
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
{
|
||||||
ClusterNames: framework.ClusterNames(),
|
APIVersion: deployment.APIVersion,
|
||||||
},
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("deployment status collection testing", func() {
|
ginkgo.It("deployment status collection testing", func() {
|
||||||
|
|
|
@ -21,14 +21,19 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
|
var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
|
||||||
ginkgo.Context("InterpreterOperation InterpretReplica testing", func() {
|
var policyNamespace, policyName string
|
||||||
policyNamespace := testNamespace
|
var workloadNamespace, workloadName string
|
||||||
policyName := workloadNamePrefix + rand.String(RandomStrLength)
|
var workload *workloadv1alpha1.Workload
|
||||||
workloadNamespace := testNamespace
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
workloadName := policyName
|
|
||||||
|
|
||||||
workload := testhelper.NewWorkload(workloadNamespace, workloadName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
|
policyName = workloadNamePrefix + rand.String(RandomStrLength)
|
||||||
|
workloadNamespace = testNamespace
|
||||||
|
workloadName = policyName
|
||||||
|
|
||||||
|
workload = testhelper.NewWorkload(workloadNamespace, workloadName)
|
||||||
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: workload.APIVersion,
|
APIVersion: workload.APIVersion,
|
||||||
Kind: workload.Kind,
|
Kind: workload.Kind,
|
||||||
|
@ -39,7 +44,9 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
|
||||||
ClusterNames: framework.ClusterNames(),
|
ClusterNames: framework.ClusterNames(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
ginkgo.Context("InterpreterOperation InterpretReplica testing", func() {
|
||||||
ginkgo.It("InterpretReplica testing", func() {
|
ginkgo.It("InterpretReplica testing", func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
framework.CreateWorkload(dynamicClient, workload)
|
framework.CreateWorkload(dynamicClient, workload)
|
||||||
|
@ -67,26 +74,16 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
|
||||||
// Now only support push mode cluster for Retain testing
|
// Now only support push mode cluster for Retain testing
|
||||||
// TODO(lonelyCZ): support pull mode cluster
|
// TODO(lonelyCZ): support pull mode cluster
|
||||||
ginkgo.Context("InterpreterOperation Retain testing", func() {
|
ginkgo.Context("InterpreterOperation Retain testing", func() {
|
||||||
var waitTime = 5 * time.Second
|
var waitTime time.Duration
|
||||||
var updatedPaused = true
|
var updatedPaused bool
|
||||||
|
var pushModeClusters []string
|
||||||
|
|
||||||
policyNamespace := testNamespace
|
ginkgo.BeforeEach(func() {
|
||||||
policyName := workloadNamePrefix + rand.String(RandomStrLength)
|
waitTime = 5 * time.Second
|
||||||
workloadNamespace := testNamespace
|
updatedPaused = true
|
||||||
workloadName := policyName
|
pushModeClusters = []string{"member1", "member2"}
|
||||||
pushModeClusters := []string{"member1", "member2"}
|
|
||||||
|
|
||||||
workload := testhelper.NewWorkload(workloadNamespace, workloadName)
|
policy.Spec.Placement.ClusterAffinity.ClusterNames = pushModeClusters
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: workload.APIVersion,
|
|
||||||
Kind: workload.Kind,
|
|
||||||
Name: workload.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: pushModeClusters,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("Retain testing", func() {
|
ginkgo.It("Retain testing", func() {
|
||||||
|
@ -126,12 +123,6 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("InterpreterOperation ReviseReplica testing", func() {
|
ginkgo.Context("InterpreterOperation ReviseReplica testing", func() {
|
||||||
policyNamespace := testNamespace
|
|
||||||
policyName := workloadNamePrefix + rand.String(RandomStrLength)
|
|
||||||
workloadNamespace := testNamespace
|
|
||||||
workloadName := policyName
|
|
||||||
workload := testhelper.NewWorkload(workloadNamespace, workloadName)
|
|
||||||
|
|
||||||
ginkgo.It("ReviseReplica testing", func() {
|
ginkgo.It("ReviseReplica testing", func() {
|
||||||
sumWeight := 0
|
sumWeight := 0
|
||||||
staticWeightLists := make([]policyv1alpha1.StaticClusterWeight, 0)
|
staticWeightLists := make([]policyv1alpha1.StaticClusterWeight, 0)
|
||||||
|
@ -146,7 +137,7 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
|
||||||
staticWeightLists = append(staticWeightLists, staticWeightList)
|
staticWeightLists = append(staticWeightLists, staticWeightList)
|
||||||
}
|
}
|
||||||
workload.Spec.Replicas = pointer.Int32Ptr(int32(sumWeight))
|
workload.Spec.Replicas = pointer.Int32Ptr(int32(sumWeight))
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policy = testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: workload.APIVersion,
|
APIVersion: workload.APIVersion,
|
||||||
Kind: workload.Kind,
|
Kind: workload.Kind,
|
||||||
|
@ -181,23 +172,6 @@ var _ = ginkgo.Describe("Resource interpreter webhook testing", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("InterpreterOperation AggregateStatus testing", func() {
|
ginkgo.Context("InterpreterOperation AggregateStatus testing", func() {
|
||||||
policyNamespace := testNamespace
|
|
||||||
policyName := workloadNamePrefix + rand.String(RandomStrLength)
|
|
||||||
workloadNamespace := testNamespace
|
|
||||||
workloadName := policyName
|
|
||||||
workload := testhelper.NewWorkload(workloadNamespace, workloadName)
|
|
||||||
policy := testhelper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: workload.APIVersion,
|
|
||||||
Kind: workload.Kind,
|
|
||||||
Name: workload.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
ginkgo.It("AggregateStatus testing", func() {
|
ginkgo.It("AggregateStatus testing", func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
framework.CreateWorkload(dynamicClient, workload)
|
framework.CreateWorkload(dynamicClient, workload)
|
||||||
|
|
|
@ -36,34 +36,42 @@ var _ = ginkgo.Describe("propagation with label and group constraints testing",
|
||||||
ginkgo.Context("Deployment propagation testing", func() {
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
var groupMatchedClusters []string
|
var groupMatchedClusters []string
|
||||||
var targetClusterNames []string
|
var targetClusterNames []string
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
deploymentName := policyName
|
var maxGroups, minGroups int
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
maxGroups := rand.Intn(2) + 1
|
|
||||||
minGroups := maxGroups
|
|
||||||
|
|
||||||
// set MaxGroups=MinGroups=1 or 2, label is location=CHN.
|
ginkgo.BeforeEach(func() {
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: deployment.APIVersion,
|
deploymentNamespace = testNamespace
|
||||||
Kind: deployment.Kind,
|
deploymentName = policyName
|
||||||
Name: deployment.Name,
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
},
|
maxGroups = rand.Intn(2) + 1
|
||||||
}, policyv1alpha1.Placement{
|
minGroups = maxGroups
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
LabelSelector: &metav1.LabelSelector{
|
// set MaxGroups=MinGroups=1 or 2, label is location=CHN.
|
||||||
MatchLabels: clusterLabels,
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
},
|
|
||||||
},
|
|
||||||
SpreadConstraints: []policyv1alpha1.SpreadConstraint{
|
|
||||||
{
|
{
|
||||||
SpreadByField: policyv1alpha1.SpreadByFieldCluster,
|
APIVersion: deployment.APIVersion,
|
||||||
MaxGroups: maxGroups,
|
Kind: deployment.Kind,
|
||||||
MinGroups: minGroups,
|
Name: deployment.Name,
|
||||||
},
|
},
|
||||||
},
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
LabelSelector: &metav1.LabelSelector{
|
||||||
|
MatchLabels: clusterLabels,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
SpreadConstraints: []policyv1alpha1.SpreadConstraint{
|
||||||
|
{
|
||||||
|
SpreadByField: policyv1alpha1.SpreadByFieldCluster,
|
||||||
|
MaxGroups: maxGroups,
|
||||||
|
MinGroups: minGroups,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("deployment propagation with label and group constraints testing", func() {
|
ginkgo.It("deployment propagation with label and group constraints testing", func() {
|
||||||
|
@ -109,40 +117,50 @@ var _ = ginkgo.Describe("propagation with label and group constraints testing",
|
||||||
ginkgo.Context("CustomResourceDefinition propagation testing", func() {
|
ginkgo.Context("CustomResourceDefinition propagation testing", func() {
|
||||||
var groupMatchedClusters []*clusterv1alpha1.Cluster
|
var groupMatchedClusters []*clusterv1alpha1.Cluster
|
||||||
var targetClusterNames []string
|
var targetClusterNames []string
|
||||||
crdGroup := fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
var crdGroup string
|
||||||
randStr := rand.String(RandomStrLength)
|
var randStr string
|
||||||
crdSpecNames := apiextensionsv1.CustomResourceDefinitionNames{
|
var crdSpecNames apiextensionsv1.CustomResourceDefinitionNames
|
||||||
Kind: fmt.Sprintf("Foo%s", randStr),
|
var crd *apiextensionsv1.CustomResourceDefinition
|
||||||
ListKind: fmt.Sprintf("Foo%sList", randStr),
|
var maxGroups, minGroups int
|
||||||
Plural: fmt.Sprintf("foo%ss", randStr),
|
var crdPolicy *policyv1alpha1.ClusterPropagationPolicy
|
||||||
Singular: fmt.Sprintf("foo%s", randStr),
|
var crdGVR schema.GroupVersionResource
|
||||||
}
|
|
||||||
crd := helper.NewCustomResourceDefinition(crdGroup, crdSpecNames, apiextensionsv1.NamespaceScoped)
|
|
||||||
maxGroups := rand.Intn(2) + 1
|
|
||||||
minGroups := maxGroups
|
|
||||||
|
|
||||||
// set MaxGroups=MinGroups=1 or 2, label is location=CHN.
|
ginkgo.BeforeEach(func() {
|
||||||
crdPolicy := helper.NewClusterPropagationPolicy(crd.Name, []policyv1alpha1.ResourceSelector{
|
crdGroup = fmt.Sprintf("example-%s.karmada.io", rand.String(RandomStrLength))
|
||||||
{
|
randStr = rand.String(RandomStrLength)
|
||||||
APIVersion: crd.APIVersion,
|
crdSpecNames = apiextensionsv1.CustomResourceDefinitionNames{
|
||||||
Kind: crd.Kind,
|
Kind: fmt.Sprintf("Foo%s", randStr),
|
||||||
Name: crd.Name,
|
ListKind: fmt.Sprintf("Foo%sList", randStr),
|
||||||
},
|
Plural: fmt.Sprintf("foo%ss", randStr),
|
||||||
}, policyv1alpha1.Placement{
|
Singular: fmt.Sprintf("foo%s", randStr),
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
}
|
||||||
LabelSelector: &metav1.LabelSelector{
|
crd = helper.NewCustomResourceDefinition(crdGroup, crdSpecNames, apiextensionsv1.NamespaceScoped)
|
||||||
MatchLabels: clusterLabels,
|
maxGroups = rand.Intn(2) + 1
|
||||||
},
|
minGroups = maxGroups
|
||||||
},
|
|
||||||
SpreadConstraints: []policyv1alpha1.SpreadConstraint{
|
// set MaxGroups=MinGroups=1 or 2, label is location=CHN.
|
||||||
|
crdPolicy = helper.NewClusterPropagationPolicy(crd.Name, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
SpreadByField: policyv1alpha1.SpreadByFieldCluster,
|
APIVersion: crd.APIVersion,
|
||||||
MaxGroups: maxGroups,
|
Kind: crd.Kind,
|
||||||
MinGroups: minGroups,
|
Name: crd.Name,
|
||||||
},
|
},
|
||||||
},
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
LabelSelector: &metav1.LabelSelector{
|
||||||
|
MatchLabels: clusterLabels,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
SpreadConstraints: []policyv1alpha1.SpreadConstraint{
|
||||||
|
{
|
||||||
|
SpreadByField: policyv1alpha1.SpreadByFieldCluster,
|
||||||
|
MaxGroups: maxGroups,
|
||||||
|
MinGroups: minGroups,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
crdGVR = schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1", Resource: "customresourcedefinitions"}
|
||||||
})
|
})
|
||||||
crdGVR := schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1", Resource: "customresourcedefinitions"}
|
|
||||||
|
|
||||||
ginkgo.It("crd with specified label and group constraints propagation testing", func() {
|
ginkgo.It("crd with specified label and group constraints propagation testing", func() {
|
||||||
framework.CreateClusterPropagationPolicy(karmadaClient, crdPolicy)
|
framework.CreateClusterPropagationPolicy(karmadaClient, crdPolicy)
|
||||||
|
@ -212,34 +230,42 @@ var _ = ginkgo.Describe("propagation with label and group constraints testing",
|
||||||
ginkgo.Context("Job propagation testing", func() {
|
ginkgo.Context("Job propagation testing", func() {
|
||||||
var groupMatchedClusters []string
|
var groupMatchedClusters []string
|
||||||
var targetClusterNames []string
|
var targetClusterNames []string
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := jobNamePrefix + rand.String(RandomStrLength)
|
var jobNamespace, jobName string
|
||||||
jobNamespace := testNamespace
|
var job *batchv1.Job
|
||||||
jobName := policyName
|
var maxGroups, minGroups int
|
||||||
job := helper.NewJob(jobNamespace, jobName)
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
maxGroups := rand.Intn(2) + 1
|
|
||||||
minGroups := maxGroups
|
|
||||||
|
|
||||||
// set MaxGroups=MinGroups=1 or 2, label is location=CHN.
|
ginkgo.BeforeEach(func() {
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = jobNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: job.APIVersion,
|
jobNamespace = testNamespace
|
||||||
Kind: job.Kind,
|
jobName = policyName
|
||||||
Name: job.Name,
|
job = helper.NewJob(jobNamespace, jobName)
|
||||||
},
|
maxGroups = rand.Intn(2) + 1
|
||||||
}, policyv1alpha1.Placement{
|
minGroups = maxGroups
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
LabelSelector: &metav1.LabelSelector{
|
// set MaxGroups=MinGroups=1 or 2, label is location=CHN.
|
||||||
MatchLabels: clusterLabels,
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
},
|
|
||||||
},
|
|
||||||
SpreadConstraints: []policyv1alpha1.SpreadConstraint{
|
|
||||||
{
|
{
|
||||||
SpreadByField: policyv1alpha1.SpreadByFieldCluster,
|
APIVersion: job.APIVersion,
|
||||||
MaxGroups: maxGroups,
|
Kind: job.Kind,
|
||||||
MinGroups: minGroups,
|
Name: job.Name,
|
||||||
},
|
},
|
||||||
},
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
LabelSelector: &metav1.LabelSelector{
|
||||||
|
MatchLabels: clusterLabels,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
SpreadConstraints: []policyv1alpha1.SpreadConstraint{
|
||||||
|
{
|
||||||
|
SpreadByField: policyv1alpha1.SpreadByFieldCluster,
|
||||||
|
MaxGroups: maxGroups,
|
||||||
|
MinGroups: minGroups,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("Job propagation with label and group constraints testing", func() {
|
ginkgo.It("Job propagation with label and group constraints testing", func() {
|
||||||
|
@ -321,15 +347,19 @@ var _ = ginkgo.Describe("propagation with label and group constraints testing",
|
||||||
`ReplicaSchedulingType` value is `Divided`, `ReplicaDivisionPreference` value is `Weighted`, `WeightPreference` isn't nil, trigger rescheduling when replicas have changed.
|
`ReplicaSchedulingType` value is `Divided`, `ReplicaDivisionPreference` value is `Weighted`, `WeightPreference` isn't nil, trigger rescheduling when replicas have changed.
|
||||||
*/
|
*/
|
||||||
var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing", func() {
|
var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing", func() {
|
||||||
// Case 1: `ReplicaSchedulingType` value is `Duplicated`.
|
var policyNamespace, policyName string
|
||||||
ginkgo.Context("ReplicaSchedulingType is Duplicated.", func() {
|
var deploymentNamespace, deploymentName string
|
||||||
policyNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
deploymentNamespace := policyNamespace
|
|
||||||
deploymentName := policyName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
|
deploymentNamespace = policyNamespace
|
||||||
|
deploymentName = policyName
|
||||||
|
|
||||||
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
{
|
{
|
||||||
APIVersion: deployment.APIVersion,
|
APIVersion: deployment.APIVersion,
|
||||||
Kind: deployment.Kind,
|
Kind: deployment.Kind,
|
||||||
|
@ -343,7 +373,10 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDuplicated,
|
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDuplicated,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// Case 1: `ReplicaSchedulingType` value is `Duplicated`.
|
||||||
|
ginkgo.Context("ReplicaSchedulingType is Duplicated.", func() {
|
||||||
ginkgo.It("replicas duplicated testing", func() {
|
ginkgo.It("replicas duplicated testing", func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
framework.CreateDeployment(kubeClient, deployment)
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
|
@ -363,27 +396,6 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
|
|
||||||
// Case 2: `ReplicaSchedulingType` value is `Duplicated`, trigger rescheduling when replicas have changed.
|
// Case 2: `ReplicaSchedulingType` value is `Duplicated`, trigger rescheduling when replicas have changed.
|
||||||
ginkgo.Context("ReplicaSchedulingType is Duplicated, trigger rescheduling when replicas have changed.", func() {
|
ginkgo.Context("ReplicaSchedulingType is Duplicated, trigger rescheduling when replicas have changed.", func() {
|
||||||
policyNamespace := testNamespace
|
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
|
||||||
deploymentNamespace := policyNamespace
|
|
||||||
deploymentName := policyName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
|
||||||
},
|
|
||||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
|
||||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDuplicated,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
ginkgo.It("replicas duplicated testing when rescheduling", func() {
|
ginkgo.It("replicas duplicated testing when rescheduling", func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
framework.CreateDeployment(kubeClient, deployment)
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
|
@ -411,26 +423,11 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
// Case 3: `ReplicaSchedulingType` value is `Divided`, `ReplicaDivisionPreference` value is `Weighted`,
|
// Case 3: `ReplicaSchedulingType` value is `Divided`, `ReplicaDivisionPreference` value is `Weighted`,
|
||||||
// `WeightPreference` is nil.
|
// `WeightPreference` is nil.
|
||||||
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference is nil.", func() {
|
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference is nil.", func() {
|
||||||
policyNamespace := testNamespace
|
ginkgo.BeforeEach(func() {
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
policy.Spec.Placement.ReplicaScheduling = &policyv1alpha1.ReplicaSchedulingStrategy{
|
||||||
deploymentNamespace := policyNamespace
|
|
||||||
deploymentName := policyName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
|
||||||
},
|
|
||||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
|
||||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
||||||
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("replicas divided and weighted testing", func() {
|
ginkgo.It("replicas divided and weighted testing", func() {
|
||||||
|
@ -457,26 +454,11 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
// `WeightPreference` is nil, trigger rescheduling when replicas have changed.
|
// `WeightPreference` is nil, trigger rescheduling when replicas have changed.
|
||||||
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference is "+
|
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference is "+
|
||||||
"nil, trigger rescheduling when replicas have changed.", func() {
|
"nil, trigger rescheduling when replicas have changed.", func() {
|
||||||
policyNamespace := testNamespace
|
ginkgo.BeforeEach(func() {
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
policy.Spec.Placement.ReplicaScheduling = &policyv1alpha1.ReplicaSchedulingStrategy{
|
||||||
deploymentNamespace := policyNamespace
|
|
||||||
deploymentName := policyName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
|
||||||
},
|
|
||||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
|
||||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
||||||
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("replicas divided and weighted testing when rescheduling", func() {
|
ginkgo.It("replicas divided and weighted testing when rescheduling", func() {
|
||||||
|
@ -507,27 +489,12 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
// Case 5: `ReplicaSchedulingType` value is `Divided`, `ReplicaDivisionPreference` value is `Weighted`,
|
// Case 5: `ReplicaSchedulingType` value is `Divided`, `ReplicaDivisionPreference` value is `Weighted`,
|
||||||
// `WeightPreference` isn't nil.
|
// `WeightPreference` isn't nil.
|
||||||
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference isn't nil.", func() {
|
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference isn't nil.", func() {
|
||||||
policyNamespace := testNamespace
|
ginkgo.BeforeEach(func() {
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
policy.Spec.Placement.ReplicaScheduling = &policyv1alpha1.ReplicaSchedulingStrategy{
|
||||||
deploymentNamespace := policyNamespace
|
|
||||||
deploymentName := policyName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
|
||||||
},
|
|
||||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
|
||||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
||||||
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
||||||
WeightPreference: &policyv1alpha1.ClusterPreferences{},
|
WeightPreference: &policyv1alpha1.ClusterPreferences{},
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("replicas divided and weighted testing", func() {
|
ginkgo.It("replicas divided and weighted testing", func() {
|
||||||
|
@ -580,27 +547,12 @@ var _ = ginkgo.Describe("[ReplicaScheduling] ReplicaSchedulingStrategy testing",
|
||||||
// `WeightPreference` isn't nil, trigger rescheduling when replicas have changed.
|
// `WeightPreference` isn't nil, trigger rescheduling when replicas have changed.
|
||||||
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference isn't "+
|
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference isn't "+
|
||||||
"nil, trigger rescheduling when replicas have changed.", func() {
|
"nil, trigger rescheduling when replicas have changed.", func() {
|
||||||
policyNamespace := testNamespace
|
ginkgo.BeforeEach(func() {
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
policy.Spec.Placement.ReplicaScheduling = &policyv1alpha1.ReplicaSchedulingStrategy{
|
||||||
deploymentNamespace := policyNamespace
|
|
||||||
deploymentName := policyName
|
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
|
||||||
{
|
|
||||||
APIVersion: deployment.APIVersion,
|
|
||||||
Kind: deployment.Kind,
|
|
||||||
Name: deployment.Name,
|
|
||||||
},
|
|
||||||
}, policyv1alpha1.Placement{
|
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
|
||||||
ClusterNames: framework.ClusterNames(),
|
|
||||||
},
|
|
||||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
|
||||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
||||||
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
||||||
WeightPreference: &policyv1alpha1.ClusterPreferences{},
|
WeightPreference: &policyv1alpha1.ClusterPreferences{},
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
@ -671,27 +623,34 @@ var _ = ginkgo.Describe("[JobReplicaScheduling] JobReplicaSchedulingStrategy tes
|
||||||
// `ReplicaSchedulingType` value is `Divided`, `ReplicaDivisionPreference` value is `Weighted`,
|
// `ReplicaSchedulingType` value is `Divided`, `ReplicaDivisionPreference` value is `Weighted`,
|
||||||
// `WeightPreference` isn't nil, `spec.completions` isn't nil.
|
// `WeightPreference` isn't nil, `spec.completions` isn't nil.
|
||||||
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference isn't nil, spec.completions isn`t nil.", func() {
|
ginkgo.Context("ReplicaSchedulingType is Divided, ReplicaDivisionPreference is Weighted, WeightPreference isn't nil, spec.completions isn`t nil.", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := jobNamePrefix + rand.String(RandomStrLength)
|
var jobNamespace, jobName string
|
||||||
jobNamespace := policyNamespace
|
var job *batchv1.Job
|
||||||
jobName := policyName
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
|
||||||
job := helper.NewJob(jobNamespace, jobName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = jobNamePrefix + rand.String(RandomStrLength)
|
||||||
APIVersion: job.APIVersion,
|
jobNamespace = policyNamespace
|
||||||
Kind: job.Kind,
|
jobName = policyName
|
||||||
Name: job.Name,
|
|
||||||
},
|
job = helper.NewJob(jobNamespace, jobName)
|
||||||
}, policyv1alpha1.Placement{
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
{
|
||||||
ClusterNames: framework.ClusterNames(),
|
APIVersion: job.APIVersion,
|
||||||
},
|
Kind: job.Kind,
|
||||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
Name: job.Name,
|
||||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
},
|
||||||
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
}, policyv1alpha1.Placement{
|
||||||
WeightPreference: &policyv1alpha1.ClusterPreferences{},
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
},
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
||||||
|
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
||||||
|
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
||||||
|
WeightPreference: &policyv1alpha1.ClusterPreferences{},
|
||||||
|
},
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.It("job replicas divided and weighted testing", func() {
|
ginkgo.It("job replicas divided and weighted testing", func() {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
@ -19,35 +20,44 @@ import (
|
||||||
|
|
||||||
var _ = ginkgo.Describe("propagation with taint and toleration testing", func() {
|
var _ = ginkgo.Describe("propagation with taint and toleration testing", func() {
|
||||||
ginkgo.Context("Deployment propagation testing", func() {
|
ginkgo.Context("Deployment propagation testing", func() {
|
||||||
policyNamespace := testNamespace
|
var policyNamespace, policyName string
|
||||||
policyName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var deploymentNamespace, deploymentName string
|
||||||
deploymentNamespace := testNamespace
|
var deployment *appsv1.Deployment
|
||||||
deploymentName := policyName
|
var tolerationKey, tolerationValue string
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
var clusterTolerations []corev1.Toleration
|
||||||
tolerationKey := "cluster-toleration.karmada.io"
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
tolerationValue := "member1"
|
|
||||||
|
|
||||||
// set clusterTolerations to tolerate taints in member1.
|
ginkgo.BeforeEach(func() {
|
||||||
clusterTolerations := []corev1.Toleration{
|
policyNamespace = testNamespace
|
||||||
{
|
policyName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
Key: tolerationKey,
|
deploymentNamespace = testNamespace
|
||||||
Operator: corev1.TolerationOpEqual,
|
deploymentName = policyName
|
||||||
Value: tolerationValue,
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
Effect: corev1.TaintEffectNoSchedule,
|
tolerationKey = "cluster-toleration.karmada.io"
|
||||||
},
|
tolerationValue = "member1"
|
||||||
}
|
|
||||||
|
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
// set clusterTolerations to tolerate taints in member1.
|
||||||
{
|
clusterTolerations = []corev1.Toleration{
|
||||||
APIVersion: deployment.APIVersion,
|
{
|
||||||
Kind: deployment.Kind,
|
Key: tolerationKey,
|
||||||
Name: deployment.Name,
|
Operator: corev1.TolerationOpEqual,
|
||||||
},
|
Value: tolerationValue,
|
||||||
}, policyv1alpha1.Placement{
|
Effect: corev1.TaintEffectNoSchedule,
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
},
|
||||||
ClusterNames: framework.ClusterNames(),
|
}
|
||||||
},
|
|
||||||
ClusterTolerations: clusterTolerations,
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: framework.ClusterNames(),
|
||||||
|
},
|
||||||
|
ClusterTolerations: clusterTolerations,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
|
@ -23,29 +24,43 @@ import (
|
||||||
|
|
||||||
var _ = ginkgo.Describe("test unjoin testing", func() {
|
var _ = ginkgo.Describe("test unjoin testing", func() {
|
||||||
ginkgo.Context(" unjoining not ready cluster", func() {
|
ginkgo.Context(" unjoining not ready cluster", func() {
|
||||||
clusterName := "member-e2e-" + rand.String(3)
|
var clusterName string
|
||||||
homeDir := os.Getenv("HOME")
|
var homeDir string
|
||||||
kubeConfigPath := fmt.Sprintf("%s/.kube/%s.config", homeDir, clusterName)
|
var kubeConfigPath string
|
||||||
clusterContext := fmt.Sprintf("kind-%s", clusterName)
|
var clusterContext string
|
||||||
deploymentName := deploymentNamePrefix + rand.String(RandomStrLength)
|
var controlPlane string
|
||||||
deploymentNamespace := testNamespace
|
var deploymentName, deploymentNamespace string
|
||||||
policyName := deploymentName
|
var policyName, policyNamespace string
|
||||||
controlPlane := fmt.Sprintf("%s-control-plane", clusterName)
|
var deployment *appsv1.Deployment
|
||||||
policyNamespace := testNamespace
|
var policy *policyv1alpha1.PropagationPolicy
|
||||||
|
var karmadaConfig karmadactl.KarmadaConfig
|
||||||
|
|
||||||
deployment := helper.NewDeployment(deploymentNamespace, deploymentName)
|
ginkgo.BeforeEach(func() {
|
||||||
policy := helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
clusterName = "member-e2e-" + rand.String(3)
|
||||||
{
|
homeDir = os.Getenv("HOME")
|
||||||
APIVersion: deployment.APIVersion,
|
kubeConfigPath = fmt.Sprintf("%s/.kube/%s.config", homeDir, clusterName)
|
||||||
Kind: deployment.Kind,
|
clusterContext = fmt.Sprintf("kind-%s", clusterName)
|
||||||
Name: deployment.Name,
|
controlPlane = fmt.Sprintf("%s-control-plane", clusterName)
|
||||||
},
|
deploymentName = deploymentNamePrefix + rand.String(RandomStrLength)
|
||||||
}, policyv1alpha1.Placement{
|
deploymentNamespace = testNamespace
|
||||||
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
policyName = deploymentName
|
||||||
ClusterNames: []string{deploymentName},
|
policyNamespace = testNamespace
|
||||||
},
|
|
||||||
|
deployment = helper.NewDeployment(deploymentNamespace, deploymentName)
|
||||||
|
policy = helper.NewPropagationPolicy(policyNamespace, policyName, []policyv1alpha1.ResourceSelector{
|
||||||
|
{
|
||||||
|
APIVersion: deployment.APIVersion,
|
||||||
|
Kind: deployment.Kind,
|
||||||
|
Name: deployment.Name,
|
||||||
|
},
|
||||||
|
}, policyv1alpha1.Placement{
|
||||||
|
ClusterAffinity: &policyv1alpha1.ClusterAffinity{
|
||||||
|
ClusterNames: []string{deploymentName},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
karmadaConfig = karmadactl.NewKarmadaConfig(clientcmd.NewDefaultPathOptions())
|
||||||
})
|
})
|
||||||
karmadaConfig := karmadactl.NewKarmadaConfig(clientcmd.NewDefaultPathOptions())
|
|
||||||
ginkgo.It("Test unjoining not ready cluster", func() {
|
ginkgo.It("Test unjoining not ready cluster", func() {
|
||||||
framework.CreatePropagationPolicy(karmadaClient, policy)
|
framework.CreatePropagationPolicy(karmadaClient, policy)
|
||||||
framework.CreateDeployment(kubeClient, deployment)
|
framework.CreateDeployment(kubeClient, deployment)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/pointer"
|
||||||
|
|
||||||
worklodv1alpha1 "github.com/karmada-io/karmada/examples/customresourceinterpreter/apis/workload/v1alpha1"
|
workloadv1alpha1 "github.com/karmada-io/karmada/examples/customresourceinterpreter/apis/workload/v1alpha1"
|
||||||
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
|
clusterv1alpha1 "github.com/karmada-io/karmada/pkg/apis/cluster/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -430,10 +430,10 @@ func NewClusterWithResource(name string, allocatable, allocating, allocated core
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWorkload will build a workload object.
|
// NewWorkload will build a workload object.
|
||||||
func NewWorkload(namespace string, name string) *worklodv1alpha1.Workload {
|
func NewWorkload(namespace string, name string) *workloadv1alpha1.Workload {
|
||||||
podLabels := map[string]string{"app": "nginx"}
|
podLabels := map[string]string{"app": "nginx"}
|
||||||
|
|
||||||
return &worklodv1alpha1.Workload{
|
return &workloadv1alpha1.Workload{
|
||||||
TypeMeta: metav1.TypeMeta{
|
TypeMeta: metav1.TypeMeta{
|
||||||
APIVersion: "workload.example.io/v1alpha1",
|
APIVersion: "workload.example.io/v1alpha1",
|
||||||
Kind: "Workload",
|
Kind: "Workload",
|
||||||
|
@ -442,7 +442,7 @@ func NewWorkload(namespace string, name string) *worklodv1alpha1.Workload {
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
Spec: worklodv1alpha1.WorkloadSpec{
|
Spec: workloadv1alpha1.WorkloadSpec{
|
||||||
Replicas: pointer.Int32Ptr(3),
|
Replicas: pointer.Int32Ptr(3),
|
||||||
Template: corev1.PodTemplateSpec{
|
Template: corev1.PodTemplateSpec{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
|
Loading…
Reference in New Issue