test of even distribution of replicas for add cluster scenario
Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
This commit is contained in:
parent
2ffe976180
commit
ed33423be5
|
@ -363,6 +363,74 @@ func Test_EvenDistributionOfReplicas(t *testing.T) {
|
|||
},
|
||||
wantErr: false,
|
||||
},
|
||||
// Test Case No.6 of even distribution of replicas: ensure as much inertia as possible in adding cluster scenarios
|
||||
// 1. create deployment (replicas=5), weight=1:1:1
|
||||
// 2. check three member cluster replicas, can be 2:2:1、2:1:2、1:2:2
|
||||
// 3. add a new cluster, and change static weight to 1:1:1:1
|
||||
// 4. check four member cluster replicas, the replica in newly add cluster will be scale from cluster with 2 replicas previously, just like:
|
||||
// * 2:2:1 --> 1:2:1:1 or 2:1:1:1
|
||||
// * 2:1:2 --> 1:1:2:1 or 2:1:1:1
|
||||
// * 1:2:2 --> 1:1:2:1 or 1:2:1:1
|
||||
{
|
||||
name: "replica 5, static weighted 1:1:1, add a new cluster and change static weight to 1:1:1:1, before change",
|
||||
clusters: []*clusterv1alpha1.Cluster{
|
||||
helper.NewCluster(ClusterMember1),
|
||||
helper.NewCluster(ClusterMember2),
|
||||
helper.NewCluster(ClusterMember3),
|
||||
},
|
||||
object: workv1alpha2.ResourceBindingSpec{
|
||||
Replicas: 5,
|
||||
},
|
||||
placement: &policyv1alpha1.Placement{
|
||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
||||
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
||||
WeightPreference: &policyv1alpha1.ClusterPreferences{
|
||||
StaticWeightList: []policyv1alpha1.StaticClusterWeight{
|
||||
{TargetCluster: policyv1alpha1.ClusterAffinity{ClusterNames: []string{ClusterMember1}}, Weight: 1},
|
||||
{TargetCluster: policyv1alpha1.ClusterAffinity{ClusterNames: []string{ClusterMember2}}, Weight: 1},
|
||||
{TargetCluster: policyv1alpha1.ClusterAffinity{ClusterNames: []string{ClusterMember3}}, Weight: 1},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
previousResultToNewResult: map[string][]string{
|
||||
"": {"2:2:1", "2:1:2", "1:2:2"},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "replica 5, static weighted 1:1:1, add a new cluster and change static weight to 1:1:1:1, after change",
|
||||
clusters: []*clusterv1alpha1.Cluster{
|
||||
helper.NewCluster(ClusterMember1),
|
||||
helper.NewCluster(ClusterMember2),
|
||||
helper.NewCluster(ClusterMember3),
|
||||
helper.NewCluster(ClusterMember4),
|
||||
},
|
||||
object: workv1alpha2.ResourceBindingSpec{
|
||||
Replicas: 5,
|
||||
},
|
||||
placement: &policyv1alpha1.Placement{
|
||||
ReplicaScheduling: &policyv1alpha1.ReplicaSchedulingStrategy{
|
||||
ReplicaSchedulingType: policyv1alpha1.ReplicaSchedulingTypeDivided,
|
||||
ReplicaDivisionPreference: policyv1alpha1.ReplicaDivisionPreferenceWeighted,
|
||||
WeightPreference: &policyv1alpha1.ClusterPreferences{
|
||||
StaticWeightList: []policyv1alpha1.StaticClusterWeight{
|
||||
{TargetCluster: policyv1alpha1.ClusterAffinity{ClusterNames: []string{ClusterMember1}}, Weight: 1},
|
||||
{TargetCluster: policyv1alpha1.ClusterAffinity{ClusterNames: []string{ClusterMember2}}, Weight: 1},
|
||||
{TargetCluster: policyv1alpha1.ClusterAffinity{ClusterNames: []string{ClusterMember3}}, Weight: 1},
|
||||
{TargetCluster: policyv1alpha1.ClusterAffinity{ClusterNames: []string{ClusterMember4}}, Weight: 1},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
previousResultToNewResult: map[string][]string{
|
||||
"2:2:1": {"1:2:1:1", "2:1:1:1"},
|
||||
"2:1:2": {"1:1:2:1", "2:1:1:1"},
|
||||
"1:2:2": {"1:1:2:1", "1:2:1:1"},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue