Skip to content

Commit fe9dc2e

Browse files
authored
Merge pull request kubernetes#116573 from claudiubelu/fix-kubeadm-unittests
unit tests: Fixes init and rejoin unit tests for Windows
2 parents 204a9a1 + 4f16887 commit fe9dc2e

File tree

4 files changed

+50
-6
lines changed

4 files changed

+50
-6
lines changed

cmd/kubeadm/app/cmd/init_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ localAPIEndpoint:
4242
bootstrapTokens:
4343
- token: "abcdef.0123456789abcdef"
4444
nodeRegistration:
45-
criSocket: unix:///var/run/containerd/containerd.sock
45+
criSocket: %s
4646
name: someName
4747
ignorePreflightErrors:
4848
- c
@@ -51,7 +51,7 @@ nodeRegistration:
5151
apiVersion: %[1]s
5252
kind: ClusterConfiguration
5353
controlPlaneEndpoint: "3.4.5.6"
54-
`, kubeadmapiv1.SchemeGroupVersion.String())
54+
`, kubeadmapiv1.SchemeGroupVersion.String(), expectedCRISocket)
5555

5656
func TestNewInitData(t *testing.T) {
5757
// create temp directory
@@ -113,7 +113,7 @@ func TestNewInitData(t *testing.T) {
113113
cfg: &kubeadmapi.InitConfiguration{
114114
NodeRegistration: kubeadmapi.NodeRegistrationOptions{
115115
Name: "somename",
116-
CRISocket: "unix:///var/run/containerd/containerd.sock",
116+
CRISocket: expectedCRISocket,
117117
IgnorePreflightErrors: []string{"c", "d"},
118118
ImagePullPolicy: "IfNotPresent",
119119
},

cmd/kubeadm/app/cmd/join_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ discovery:
4848
controlPlane:
4949
certificateKey: c39a18bae4a72e71b178661f437363da218a3efb83ddb03f1cd91d9ae1da41bd
5050
nodeRegistration:
51-
criSocket: unix:///var/run/containerd/containerd.sock
51+
criSocket: %s
5252
name: someName
5353
ignorePreflightErrors:
5454
- c
5555
- d
56-
`, kubeadmapiv1.SchemeGroupVersion.String())
56+
`, kubeadmapiv1.SchemeGroupVersion.String(), expectedCRISocket)
5757

5858
func TestNewJoinData(t *testing.T) {
5959
// create temp directory
@@ -218,7 +218,7 @@ func TestNewJoinData(t *testing.T) {
218218
TypeMeta: metav1.TypeMeta{Kind: "", APIVersion: ""},
219219
NodeRegistration: kubeadmapi.NodeRegistrationOptions{
220220
Name: "somename",
221-
CRISocket: "unix:///var/run/containerd/containerd.sock",
221+
CRISocket: expectedCRISocket,
222222
IgnorePreflightErrors: []string{"c", "d"},
223223
ImagePullPolicy: "IfNotPresent",
224224
Taints: []v1.Taint{{Key: "node-role.kubernetes.io/control-plane", Effect: "NoSchedule"}},
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//go:build !windows
2+
// +build !windows
3+
4+
/*
5+
Copyright 2023 The Kubernetes Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package cmd
21+
22+
const expectedCRISocket = "unix://var/run/containerd/containerd.sock"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//go:build windows
2+
// +build windows
3+
4+
/*
5+
Copyright 2023 The Kubernetes Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package cmd
21+
22+
const expectedCRISocket = "npipe://./pipe/containerd-containerd"

0 commit comments

Comments
 (0)