Skip to content

Commit

Permalink
add test for specific data op
Browse files Browse the repository at this point in the history
Signed-off-by: xliuqq <[email protected]>
  • Loading branch information
xliuqq committed Sep 21, 2024
1 parent 1f70ba1 commit aea316d
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions pkg/dataflow/affinity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,88 @@ func TestInjectAffinityByRunAfterOp(t *testing.T) {
},
wantErr: false,
},
{
name: "not use runAfter op",
args: args{
runAfter: &datav1alpha1.OperationRef{
ObjectRef: datav1alpha1.ObjectRef{
Kind: "DataLoad",
Name: "runAfter-op",
Namespace: "test",
},
AffinityStrategy: datav1alpha1.AffinityStrategy{
DependOn: &datav1alpha1.ObjectRef{
Kind: "DataLoad",
Name: "test-op",
Namespace: "test",
},
Policy: datav1alpha1.PreferAffinityStrategy,
Prefers: []datav1alpha1.Prefer{
{
Weight: 10,
Name: common.K8sZoneLabelKey,
},
},
},
},
objects: []runtime.Object{
&datav1alpha1.DataLoad{
ObjectMeta: metav1.ObjectMeta{
Name: "test-op",
Namespace: "test",
},
Status: datav1alpha1.OperationStatus{
NodeAffinity: &v1.NodeAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: &v1.NodeSelector{
NodeSelectorTerms: []v1.NodeSelectorTerm{
{
MatchExpressions: []v1.NodeSelectorRequirement{
{
Key: common.K8sNodeNameLabelKey,
Operator: v1.NodeSelectorOpIn,
Values: []string{"node01"},
},
{
Key: common.K8sZoneLabelKey,
Operator: v1.NodeSelectorOpIn,
Values: []string{"zone01"},
},
{
Key: common.K8sRegionLabelKey,
Operator: v1.NodeSelectorOpIn,
Values: []string{"region01"},
},
},
},
},
},
},
},
},
},
opNamespace: "default",
currentAffinity: nil,
},
want: &v1.Affinity{
NodeAffinity: &v1.NodeAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: []v1.PreferredSchedulingTerm{
{
Weight: 10,
Preference: v1.NodeSelectorTerm{
MatchExpressions: []v1.NodeSelectorRequirement{
{
Key: common.K8sZoneLabelKey,
Operator: v1.NodeSelectorOpIn,
Values: []string{"zone01"},
},
},
},
},
},
},
},
wantErr: false,
},
}
testScheme := runtime.NewScheme()
_ = v1.AddToScheme(testScheme)
Expand Down

0 comments on commit aea316d

Please sign in to comment.