@@ -80,14 +80,16 @@ func TestRevisionValidation(t *testing.T) {
8080 r : & Revision {
8181 ObjectMeta : metav1.ObjectMeta {
8282 Name : "valid-lb-policy" ,
83+ Annotations : map [string ]string {
84+ "serving.knative.dev/load-balancing-policy" : "round-robin" ,
85+ },
8386 },
8487 Spec : RevisionSpec {
8588 PodSpec : corev1.PodSpec {
8689 Containers : []corev1.Container {{
8790 Image : "busybox" ,
8891 }},
8992 },
90- LoadBalancingPolicy : ptr .String ("round-robin" ),
9193 },
9294 },
9395 want : nil ,
@@ -96,14 +98,16 @@ func TestRevisionValidation(t *testing.T) {
9698 r : & Revision {
9799 ObjectMeta : metav1.ObjectMeta {
98100 Name : "valid-lb-policy" ,
101+ Annotations : map [string ]string {
102+ "serving.knative.dev/load-balancing-policy" : "random-choice-2" ,
103+ },
99104 },
100105 Spec : RevisionSpec {
101106 PodSpec : corev1.PodSpec {
102107 Containers : []corev1.Container {{
103108 Image : "busybox" ,
104109 }},
105110 },
106- LoadBalancingPolicy : ptr .String ("random-choice-2" ),
107111 },
108112 },
109113 want : nil ,
@@ -112,14 +116,16 @@ func TestRevisionValidation(t *testing.T) {
112116 r : & Revision {
113117 ObjectMeta : metav1.ObjectMeta {
114118 Name : "valid-lb-policy" ,
119+ Annotations : map [string ]string {
120+ "serving.knative.dev/load-balancing-policy" : "least-connections" ,
121+ },
115122 },
116123 Spec : RevisionSpec {
117124 PodSpec : corev1.PodSpec {
118125 Containers : []corev1.Container {{
119126 Image : "busybox" ,
120127 }},
121128 },
122- LoadBalancingPolicy : ptr .String ("least-connections" ),
123129 },
124130 },
125131 want : nil ,
@@ -128,14 +134,16 @@ func TestRevisionValidation(t *testing.T) {
128134 r : & Revision {
129135 ObjectMeta : metav1.ObjectMeta {
130136 Name : "valid-lb-policy" ,
137+ Annotations : map [string ]string {
138+ "serving.knative.dev/load-balancing-policy" : "first-available" ,
139+ },
131140 },
132141 Spec : RevisionSpec {
133142 PodSpec : corev1.PodSpec {
134143 Containers : []corev1.Container {{
135144 Image : "busybox" ,
136145 }},
137146 },
138- LoadBalancingPolicy : ptr .String ("first-available" ),
139147 },
140148 },
141149 want : nil ,
@@ -144,18 +152,20 @@ func TestRevisionValidation(t *testing.T) {
144152 r : & Revision {
145153 ObjectMeta : metav1.ObjectMeta {
146154 Name : "invalid-lb-policy" ,
155+ Annotations : map [string ]string {
156+ "serving.knative.dev/load-balancing-policy" : "random" ,
157+ },
147158 },
148159 Spec : RevisionSpec {
149160 PodSpec : corev1.PodSpec {
150161 Containers : []corev1.Container {{
151162 Image : "busybox" ,
152163 }},
153164 },
154- LoadBalancingPolicy : ptr .String ("random" ),
155165 },
156166 },
157167 want : apis .ErrInvalidValue (
158- "random" , "spec.loadBalancingPolicy " ,
168+ "random" , "metadata.annotations.serving.knative.dev/load-balancing-policy " ,
159169 "load balancing policy should be one of `random-choice-2`, `round-robin`, `least-connections` or `first-available`" ),
160170 }, {
161171 name : "nil load balancing policy is valid" ,
@@ -169,7 +179,6 @@ func TestRevisionValidation(t *testing.T) {
169179 Image : "busybox" ,
170180 }},
171181 },
172- LoadBalancingPolicy : nil ,
173182 },
174183 },
175184 want : nil ,
0 commit comments