-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ignore vct hash changes when inplace-only update strategy type
Signed-off-by: Abner-1 <Abner199709@gmail.com>
- Loading branch information
Showing
6 changed files
with
299 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package core | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" | ||
"github.com/openkruise/kruise/pkg/util/inplaceupdate" | ||
) | ||
|
||
func Test_CommonControl_GetUpdateOptions(t *testing.T) { | ||
type fields struct { | ||
CloneSet *appsv1alpha1.CloneSet | ||
} | ||
|
||
defaultOps := &inplaceupdate.UpdateOptions{} | ||
ignoreVCTHashOps := &inplaceupdate.UpdateOptions{IgnoreVolumeClaimTemplatesHashDiff: true} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want *inplaceupdate.UpdateOptions | ||
}{ | ||
{ | ||
name: "inplace only update type", | ||
fields: fields{ | ||
&appsv1alpha1.CloneSet{ | ||
Spec: appsv1alpha1.CloneSetSpec{ | ||
UpdateStrategy: appsv1alpha1.CloneSetUpdateStrategy{ | ||
Type: appsv1alpha1.InPlaceOnlyCloneSetUpdateStrategyType, | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: ignoreVCTHashOps, | ||
}, | ||
{ | ||
name: "inplace if possible update type", | ||
fields: fields{ | ||
&appsv1alpha1.CloneSet{ | ||
Spec: appsv1alpha1.CloneSetSpec{ | ||
UpdateStrategy: appsv1alpha1.CloneSetUpdateStrategy{ | ||
Type: appsv1alpha1.InPlaceIfPossibleCloneSetUpdateStrategyType, | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: defaultOps, | ||
}, | ||
{ | ||
// unexpected case: the method should not be called with recreate update strategy type. | ||
name: "recreate update type", | ||
fields: fields{ | ||
&appsv1alpha1.CloneSet{ | ||
Spec: appsv1alpha1.CloneSetSpec{ | ||
UpdateStrategy: appsv1alpha1.CloneSetUpdateStrategy{ | ||
Type: appsv1alpha1.InPlaceIfPossibleCloneSetUpdateStrategyType, | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: defaultOps, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
c := &commonControl{ | ||
CloneSet: tt.fields.CloneSet, | ||
} | ||
if got := c.GetUpdateOptions(); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("GetUpdateOptions() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters