@@ -93,7 +93,7 @@ func TestStatefulSetDefault(t *testing.T) {
9393 },
9494 Spec : corev1.PodSpec {
9595 NodeSelector : map [string ]string {
96- "cloud.google.com/gke-tpu-accelerator" : string (slice .TypeTpu7x ),
96+ core . TPUAcceleratorLabel : string (slice .TypeTpu7x ),
9797 },
9898 },
9999 },
@@ -111,8 +111,48 @@ func TestStatefulSetDefault(t *testing.T) {
111111 },
112112 Spec : corev1.PodSpec {
113113 NodeSelector : map [string ]string {
114- "cloud.google.com/gke-tpu-accelerator" : string (slice .TypeTpu7x ),
115- core .TPUTopologyAnnotation : "4x4x12" ,
114+ core .TPUAcceleratorLabel : string (slice .TypeTpu7x ),
115+ core .TPUTopologyAnnotation : "4x4x12" ,
116+ },
117+ },
118+ },
119+ },
120+ },
121+ },
122+ "relevant statefulset, with tpu topology node selector already present" : {
123+ sts : & appsv1.StatefulSet {
124+ ObjectMeta : metav1.ObjectMeta {
125+ Name : baseName ,
126+ Namespace : baseNamespace ,
127+ },
128+ Spec : appsv1.StatefulSetSpec {
129+ Template : corev1.PodTemplateSpec {
130+ ObjectMeta : metav1.ObjectMeta {
131+ Annotations : map [string ]string {core .TPUSliceTopologyAnnotation : "4x4x12" },
132+ },
133+ Spec : corev1.PodSpec {
134+ NodeSelector : map [string ]string {
135+ core .TPUAcceleratorLabel : string (slice .TypeTpu7x ),
136+ core .TPUTopologyAnnotation : "4x4x12" ,
137+ },
138+ },
139+ },
140+ },
141+ },
142+ wantSts : & appsv1.StatefulSet {
143+ ObjectMeta : metav1.ObjectMeta {
144+ Name : baseName ,
145+ Namespace : baseNamespace ,
146+ },
147+ Spec : appsv1.StatefulSetSpec {
148+ Template : corev1.PodTemplateSpec {
149+ ObjectMeta : metav1.ObjectMeta {
150+ Annotations : map [string ]string {core .TPUSliceTopologyAnnotation : "4x4x12" },
151+ },
152+ Spec : corev1.PodSpec {
153+ NodeSelector : map [string ]string {
154+ core .TPUAcceleratorLabel : string (slice .TypeTpu7x ),
155+ core .TPUTopologyAnnotation : "4x4x12" ,
116156 },
117157 },
118158 },
0 commit comments