(t *testing.T)
| 1440 | } |
| 1441 | |
| 1442 | func 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: "/"}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…