This is an automated email from the ASF dual-hosted git repository. roryqi pushed a commit to branch support-annotations in repository https://gitbox.apache.org/repos/asf/incubator-uniffle.git
commit c95b5bf5aec1405ed7cd2118cd67ba9098ba7dd2 Author: Rory <ror...@apache.org> AuthorDate: Fri Jun 21 16:09:26 2024 +0800 Fix ut --- .../sync/shuffleserver/shuffleserver_test.go | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go b/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go index dc151c5df..0a51a52d4 100644 --- a/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go +++ b/deploy/kubernetes/operator/pkg/controller/sync/shuffleserver/shuffleserver_test.go @@ -160,6 +160,11 @@ var ( }, }, } + + testAnotations = map[string]string{ + "key1": "value1", + "key2": "value2", + } ) func buildRssWithLabels() *uniffleapi.RemoteShuffleService { @@ -215,6 +220,12 @@ func withCustomAffinity(affinity *corev1.Affinity) *uniffleapi.RemoteShuffleServ return rss } +func withCustomAnnotations(annotations map[string]string) *uniffleapi.RemoteShuffleService { + rss := utils.BuildRSSWithDefaultValue() + rss.Spec.ShuffleServer.Annotations = annotations + return rss +} + func withCustomImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) *uniffleapi.RemoteShuffleService { rss := utils.BuildRSSWithDefaultValue() rss.Spec.ImagePullSecrets = imagePullSecrets @@ -535,6 +546,23 @@ func TestGenerateSts(t *testing.T) { return false, fmt.Errorf("generated sts should include volumeClaimTemplates: %v", testImagePullSecrets) }, }, + { + name: "set custom annotations", + rss: withCustomAnnotations(testAnotations), + IsValidSts: func(deploy *appsv1.StatefulSet, rss *uniffleapi.RemoteShuffleService) (bool, error) { + if deploy.Spec.Template.Annotations != nil { + for key, value := range testAnotations { + equal := reflect.DeepEqual(deploy.Spec.Template.Annotations[key], value) + if !equal { + return false, fmt.Errorf("generated deploy should include annotations: %v", testAnotations) + } + } + return true, nil + } else { + return false, fmt.Errorf("generated deploy should include annotations: %v", testAnotations) + } + }, + }, } { t.Run(tt.name, func(tc *testing.T) { sts := GenerateSts(nil, tt.rss)