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

Function TestDrain

pkg/cmd/drain/drain_test.go:252–940  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

250}
251
252func TestDrain(t *testing.T) {
253 labels := make(map[string]string)
254 labels["my_key"] = "my_value"
255
256 rc := corev1.ReplicationController{
257 ObjectMeta: metav1.ObjectMeta{
258 Name: "rc",
259 Namespace: "default",
260 CreationTimestamp: metav1.Time{Time: time.Now()},
261 Labels: labels,
262 },
263 Spec: corev1.ReplicationControllerSpec{
264 Selector: labels,
265 },
266 }
267
268 rcPod := corev1.Pod{
269 ObjectMeta: metav1.ObjectMeta{
270 Name: "bar",
271 Namespace: "default",
272 CreationTimestamp: metav1.Time{Time: time.Now()},
273 Labels: labels,
274 OwnerReferences: []metav1.OwnerReference{
275 {
276 APIVersion: "v1",
277 Kind: "ReplicationController",
278 Name: "rc",
279 UID: "123",
280 BlockOwnerDeletion: ptr.To(true),
281 Controller: ptr.To(true),
282 },
283 },
284 },
285 Spec: corev1.PodSpec{
286 NodeName: "node",
287 },
288 }
289
290 ds := appsv1.DaemonSet{
291 ObjectMeta: metav1.ObjectMeta{
292 Name: "ds",
293 Namespace: "default",
294 CreationTimestamp: metav1.Time{Time: time.Now()},
295 },
296 Spec: appsv1.DaemonSetSpec{
297 Selector: &metav1.LabelSelector{MatchLabels: labels},
298 },
299 }
300
301 dsPod := corev1.Pod{
302 ObjectMeta: metav1.ObjectMeta{
303 Name: "bar",
304 Namespace: "default",
305 CreationTimestamp: metav1.Time{Time: time.Now()},
306 Labels: labels,
307 OwnerReferences: []metav1.OwnerReference{
308 {
309 APIVersion: "apps/v1",

Callers

nothing calls this directly

Calls 8

CleanupMethod · 0.95
isForMethod · 0.95
NewCmdDrainFunction · 0.85
ToMethod · 0.80
CloseMethod · 0.80
ExecuteMethod · 0.65
StringMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…