MCPcopy
hub / github.com/kubernetes/kubectl / TestGenerateNodeDebugPod

Function TestGenerateNodeDebugPod

pkg/cmd/debug/debug_test.go:1442–1852  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1440}
1441
1442func TestGenerateNodeDebugPod(t *testing.T) {
1443 defer func(old func(int) string) { nameSuffixFunc = old }(nameSuffixFunc)
1444 var suffixCounter int
1445 nameSuffixFunc = func(int) string {
1446 suffixCounter++
1447 return fmt.Sprint(suffixCounter)
1448 }
1449
1450 for _, tc := range []struct {
1451 name string
1452 node *corev1.Node
1453 opts *DebugOptions
1454 expected *corev1.Pod
1455 }{
1456 {
1457 name: "minimum options",
1458 node: &corev1.Node{
1459 ObjectMeta: metav1.ObjectMeta{
1460 Name: "node-XXX",
1461 },
1462 },
1463 opts: &DebugOptions{
1464 Image: "busybox",
1465 PullPolicy: corev1.PullIfNotPresent,
1466 Profile: ProfileLegacy,
1467 },
1468 expected: &corev1.Pod{
1469 ObjectMeta: metav1.ObjectMeta{
1470 Name: "node-debugger-node-XXX-1",
1471 Labels: map[string]string{
1472 "app.kubernetes.io/managed-by": "kubectl-debug",
1473 },
1474 },
1475 Spec: corev1.PodSpec{
1476 Containers: []corev1.Container{
1477 {
1478 Name: "debugger",
1479 Image: "busybox",
1480 ImagePullPolicy: corev1.PullIfNotPresent,
1481 TerminationMessagePolicy: corev1.TerminationMessageReadFile,
1482 VolumeMounts: []corev1.VolumeMount{
1483 {
1484 MountPath: "/host",
1485 Name: "host-root",
1486 },
1487 },
1488 },
1489 },
1490 HostIPC: true,
1491 HostNetwork: true,
1492 HostPID: true,
1493 NodeName: "node-XXX",
1494 RestartPolicy: corev1.RestartPolicyNever,
1495 Volumes: []corev1.Volume{
1496 {
1497 Name: "host-root",
1498 VolumeSource: corev1.VolumeSource{
1499 HostPath: &corev1.HostPathVolumeSource{Path: "/"},

Callers

nothing calls this directly

Calls 6

NewProfileApplierFunction · 0.85
ToMethod · 0.80
generateNodeDebugPodMethod · 0.80
DiffMethod · 0.80
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…