-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrkt_api_service_test.go
653 lines (559 loc) · 18.6 KB
/
rkt_api_service_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
// Copyright 2015 The rkt Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +build host coreos src kvm
package main
import (
"bytes"
"encoding/json"
"fmt"
"os"
"path/filepath"
"reflect"
"strings"
"syscall"
"testing"
"time"
"github.com/appc/spec/schema"
"github.com/appc/spec/schema/types"
"github.com/coreos/gexpect"
"github.com/coreos/rkt/api/v1alpha"
"github.com/coreos/rkt/common"
"github.com/coreos/rkt/tests/testutils"
"golang.org/x/net/context"
)
func startAPIService(t *testing.T, ctx *testutils.RktRunCtx) *gexpect.ExpectSubprocess {
noGid := false
gid, err := common.LookupGid(common.RktGroup)
if err != nil {
t.Logf("no %q group, will run api service with root, ONLY DO THIS FOR TESTING!", common.RktGroup)
noGid = true
} else {
if err := ctx.SetupDataDir(); err != nil {
t.Fatalf("failed to setup data directory: %v", err)
}
}
t.Logf("Running rkt api service")
apisvcCmd := fmt.Sprintf("%s api-service", ctx.Cmd())
if noGid {
return startRktAndCheckOutput(t, apisvcCmd, "API service running")
}
return startRktAsGidAndCheckOutput(t, apisvcCmd, "API service running", gid)
}
func stopAPIService(t *testing.T, svc *gexpect.ExpectSubprocess) {
if err := svc.Cmd.Process.Signal(syscall.SIGINT); err != nil {
t.Fatalf("Failed to stop the api service: %v", err)
}
waitOrFail(t, svc, 0)
}
func checkPodState(t *testing.T, rawState string, apiState v1alpha.PodState) {
switch rawState {
case "embryo":
if apiState == v1alpha.PodState_POD_STATE_EMBRYO {
return
}
case "preparing":
if apiState == v1alpha.PodState_POD_STATE_PREPARING {
return
}
case "aborted prepare":
if apiState == v1alpha.PodState_POD_STATE_ABORTED_PREPARE {
return
}
case "running":
if apiState == v1alpha.PodState_POD_STATE_RUNNING {
return
}
case "deleting":
if apiState == v1alpha.PodState_POD_STATE_DELETING {
return
}
case "exited":
if apiState == v1alpha.PodState_POD_STATE_EXITED {
return
}
case "garbage":
if apiState == v1alpha.PodState_POD_STATE_GARBAGE {
return
}
default:
t.Fatalf("Unexpected state: %v", rawState)
}
t.Errorf("Pod state returned by api-service (%q) is not equivalent to the state returned by 'rkt status' (%q)", apiState, rawState)
}
func checkPodApps(t *testing.T, rawPod *podInfo, apiApps []*v1alpha.App, hasAppState bool) {
rawApps := rawPod.apps
if len(rawApps) != len(apiApps) {
t.Errorf("Expected %d apps, saw %d apps returned by api service %v", len(rawApps), len(apiApps), apiApps)
}
for _, app := range apiApps {
appInfo, ok := rawApps[app.Name]
if !ok {
t.Errorf("Expected app (name: %q) in the app list", app.Name)
continue
}
appACName := types.MustACName(app.Name)
runtimeApp := rawPod.manifest.Apps.Get(*appACName)
if runtimeApp == nil {
t.Errorf("Expected app (name: %q) in the pod manifest", app.Name)
}
if hasAppState && appInfo.exitCode != int(app.ExitCode) {
t.Errorf("Expected %v, saw %v", appInfo.exitCode, app.ExitCode)
}
// Image hash in the pod manifest can be partial hash.
if !strings.HasPrefix(app.Image.Id, appInfo.image.id) {
t.Errorf("Expected partial hash of %q, saw %q", appInfo.image.id, app.Image.Id)
}
// Check app annotations.
checkAnnotations(t, runtimeApp.Annotations, app.Annotations)
}
}
func checkPodNetworks(t *testing.T, rawNets map[string]*networkInfo, apiNets []*v1alpha.Network) {
if len(rawNets) != len(apiNets) {
t.Errorf("Expected %d networks, saw %d networks returned by api service", len(rawNets), len(apiNets))
}
// Each network should have a unique name, so iteration over one list is enough given
// the lengths of the two lists are equal.
for _, net := range apiNets {
if netInfo, ok := rawNets[net.Name]; ok {
if netInfo.ipv4 != net.Ipv4 {
t.Errorf("Expected %q, saw %q", netInfo.ipv4, net.Ipv4)
}
} else {
t.Errorf("Expected network (name: %q, ipv4: %q) in networks", netInfo.name, netInfo.ipv4)
}
}
}
// Check the pod's information by 'rkt status'.
func checkPod(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, hasAppState, hasManifest bool, expectedGCTime time.Time) {
t.Logf("API Pod info: %v", p)
podInfo := getPodInfo(t, ctx, p.Id)
t.Logf("Pod info: %+v", podInfo)
if podInfo.id != p.Id {
t.Errorf("Expected %q, saw %q", podInfo.id, p.Id)
}
if podInfo.pid != int(p.Pid) {
t.Errorf("Expected %d, saw %d", podInfo.pid, p.Pid)
}
// The time accuracy returned by 'rkt status' stops at milliseconds.
accuracy := time.Millisecond.Nanoseconds()
if podInfo.createdAt/accuracy != p.CreatedAt/accuracy {
t.Errorf("Expected %d, saw %d", podInfo.createdAt, p.CreatedAt)
}
if podInfo.startedAt/accuracy != p.StartedAt/accuracy {
t.Errorf("Expected %d, saw %d", podInfo.startedAt, p.StartedAt)
}
// If expectedGCTime.IsZero() == true, then p.GcMarkedAt should also be zero.
actualTime := time.Unix(0, p.GcMarkedAt)
if !compareTime(expectedGCTime, actualTime) {
t.Errorf("API service returned an incorrect GC marked time. Got %q, Expect: %q", actualTime, expectedGCTime)
}
checkPodState(t, podInfo.state, p.State)
checkPodApps(t, podInfo, p.Apps, hasAppState)
checkPodNetworks(t, podInfo.networks, p.Networks)
expectedCgroupSuffix := ""
if podInfo.state == "running" {
machineID := fmt.Sprintf("rkt-%s", p.Id)
escapedmID := strings.Replace(machineID, "-", "\\x2d", -1)
expectedCgroupSuffix = fmt.Sprintf("/machine-%s.scope", escapedmID)
}
if !strings.HasSuffix(p.Cgroup, expectedCgroupSuffix) {
t.Errorf("Expected the cgroup suffix to have %q, but saw %q", expectedCgroupSuffix, p.Cgroup)
}
if hasManifest && podInfo.manifest.Annotations != nil {
checkAnnotations(t, podInfo.manifest.Annotations, p.Annotations)
}
msft, err := json.Marshal(podInfo.manifest)
if err != nil {
t.Errorf("Cannot marshal manifest: %v", err)
}
if hasManifest && !bytes.Equal(msft, p.Manifest) {
t.Errorf("Expected %q, saw %q", string(msft), string(p.Manifest))
} else if !hasManifest && p.Manifest != nil {
t.Errorf("Expected nil manifest")
}
}
func checkPodBasicsWithGCTime(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod, expectedGCTime time.Time) {
checkPod(t, ctx, p, false, false, expectedGCTime)
}
func checkPodBasics(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod) {
checkPod(t, ctx, p, false, false, time.Time{})
}
func checkPodDetails(t *testing.T, ctx *testutils.RktRunCtx, p *v1alpha.Pod) {
checkPod(t, ctx, p, true, true, time.Time{})
}
// Check the image's information by 'rkt image list'.
func checkImage(t *testing.T, ctx *testutils.RktRunCtx, m *v1alpha.Image, hasManifest bool) {
imgInfo := getImageInfo(t, ctx, m.Id)
if imgInfo.id != m.Id {
t.Errorf("Expected %q, saw %q", imgInfo.id, m.Id)
}
if imgInfo.name != m.Name {
t.Errorf("Expected %q, saw %q", imgInfo.name, m.Name)
}
if imgInfo.version != m.Version {
t.Errorf("Expected %q, saw %q", imgInfo.version, m.Version)
}
if imgInfo.importTime != m.ImportTimestamp {
t.Errorf("Expected %q, saw %q", imgInfo.importTime, m.ImportTimestamp)
}
if imgInfo.size != m.Size {
t.Errorf("Expected size %d, saw %d", imgInfo.size, m.Size)
}
if hasManifest {
var mfst schema.ImageManifest
err := json.Unmarshal(imgInfo.manifest, &mfst)
if err != nil {
t.Fatal(err)
}
if mfst.Annotations != nil {
checkAnnotations(t, mfst.Annotations, m.Annotations)
}
}
if hasManifest && !bytes.Equal(imgInfo.manifest, m.Manifest) {
t.Errorf("Expected %q, saw %q", string(imgInfo.manifest), string(m.Manifest))
} else if !hasManifest && m.Manifest != nil {
t.Errorf("Expected nil manifest")
}
}
func checkAnnotations(t *testing.T, expected types.Annotations, actual []*v1alpha.KeyValue) {
if len(expected) != len(actual) {
t.Fatalf("Expected annotation counts to equal, expected %d, got %d", len(expected), len(actual))
}
for _, a := range actual {
val, ok := expected.Get(a.Key)
if !ok {
t.Fatalf("Expected annotation for key %q, got nothing", a.Key)
}
if val != a.Value {
t.Fatalf("Incorrect Annotation value, expected %q, got %q", val, a.Value)
}
}
}
func checkImageBasics(t *testing.T, ctx *testutils.RktRunCtx, m *v1alpha.Image) {
checkImage(t, ctx, m, false)
}
func checkImageDetails(t *testing.T, ctx *testutils.RktRunCtx, m *v1alpha.Image) {
checkImage(t, ctx, m, true)
}
func TestAPIServiceGetInfo(t *testing.T) {
ctx := testutils.NewRktRunCtx()
defer ctx.Cleanup()
svc := startAPIService(t, ctx)
defer stopAPIService(t, svc)
c, conn := newAPIClientOrFail(t, "localhost:15441")
defer conn.Close()
resp, err := c.GetInfo(context.Background(), &v1alpha.GetInfoRequest{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
expectedAPIVersion := "1.0.0-alpha"
if resp.Info.ApiVersion != expectedAPIVersion {
t.Errorf("Expected api version to be %q, but saw %q", expectedAPIVersion, resp.Info.ApiVersion)
}
expectedGlobalFlags := &v1alpha.GlobalFlags{
Dir: ctx.DataDir(),
SystemConfigDir: ctx.SystemDir(),
LocalConfigDir: ctx.LocalDir(),
UserConfigDir: ctx.UserDir(),
InsecureFlags: "none",
}
if !reflect.DeepEqual(resp.Info.GlobalFlags, expectedGlobalFlags) {
t.Errorf("Expected global flags to be %v, but saw %v", expectedGlobalFlags, resp.Info.GlobalFlags)
}
}
func NewAPIServiceListInspectPodsTest() testutils.Test {
return testutils.TestFunc(func(t *testing.T) {
ctx := testutils.NewRktRunCtx()
defer ctx.Cleanup()
svc := startAPIService(t, ctx)
defer stopAPIService(t, svc)
c, conn := newAPIClientOrFail(t, "localhost:15441")
defer conn.Close()
resp, err := c.ListPods(context.Background(), &v1alpha.ListPodsRequest{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Pods) != 0 {
t.Errorf("Unexpected result: %v, should see zero pods", resp.Pods)
}
patches := []string{"--exec=/inspect --print-msg=HELLO_API --exit-code=0"}
imageHash := patchImportAndFetchHash("rkt-inspect-print.aci", patches, t, ctx)
imgID, err := types.NewHash(imageHash)
if err != nil {
t.Fatalf("Cannot generate types.Hash from %v: %v", imageHash, err)
}
podManifests := []struct {
mfst schema.PodManifest
net string
expectedExitCode int
}{
{
// 1, Good pod.
schema.PodManifest{
ACKind: schema.PodManifestKind,
ACVersion: schema.AppContainerVersion,
Apps: []schema.RuntimeApp{
{
Name: types.ACName("rkt-inspect"),
Image: schema.RuntimeImage{
Name: types.MustACIdentifier("coreos.com/rkt-inspect"),
ID: *imgID,
},
Annotations: []types.Annotation{{Name: types.ACIdentifier("app-test"), Value: "app-test"}},
},
},
Annotations: []types.Annotation{
{Name: types.ACIdentifier("test"), Value: "test"},
},
},
"default",
0,
},
{
// 2, Bad pod, won't be launched correctly.
schema.PodManifest{
ACKind: schema.PodManifestKind,
ACVersion: schema.AppContainerVersion,
Apps: []schema.RuntimeApp{
{
Name: types.ACName("rkt-inspect"),
Image: schema.RuntimeImage{
Name: types.MustACIdentifier("coreos.com/rkt-inspect"),
ID: *imgID,
},
},
},
},
"non-existed-network",
1,
},
}
// Launch the pods.
for _, entry := range podManifests {
manifestFile := generatePodManifestFile(t, &entry.mfst)
defer os.Remove(manifestFile)
runCmd := fmt.Sprintf("%s run --net=%s --pod-manifest=%s", ctx.Cmd(), entry.net, manifestFile)
waitOrFail(t, spawnOrFail(t, runCmd), entry.expectedExitCode)
}
time.Sleep(delta)
gcCmd := fmt.Sprintf("%s gc --mark-only=true", ctx.Cmd())
waitOrFail(t, spawnOrFail(t, gcCmd), 0)
gcTime := time.Now()
// ListPods(detail=false).
resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Pods) != len(podManifests) {
t.Errorf("Unexpected result: %v, should see %v pods", len(resp.Pods), len(podManifests))
}
for _, p := range resp.Pods {
checkPodBasicsWithGCTime(t, ctx, p, gcTime)
// Test InspectPod().
inspectResp, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: p.Id})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
checkPodDetails(t, ctx, inspectResp.Pod)
}
// ListPods(detail=true).
resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{Detail: true})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Pods) != len(podManifests) {
t.Errorf("Unexpected result: %v, should see %v pods", len(resp.Pods), len(podManifests))
}
for _, p := range resp.Pods {
checkPodDetails(t, ctx, p)
}
// ListPods with corrupt pod directory
// Note that we don't checkPodDetails here, the failure this is testing is
// the api server panicing, which results in a list call hanging for ages
// and then failing.
// TODO: do further validation on the partial pods returned
for _, p := range resp.Pods {
numRemoved := 0
podDir := getPodDir(t, ctx, p.Id)
filepath.Walk(filepath.Join(podDir, "appsinfo"), filepath.WalkFunc(func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.Name() == "manifest" {
os.Remove(path)
numRemoved++
}
return nil
}))
if numRemoved == 0 {
t.Fatalf("Expected to remove at least one app manifest for pod %v", p)
}
}
// ListPods(detail=true).
resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{Detail: true})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Pods) != len(podManifests) {
t.Fatalf("Expected %v pods, got %v pods", len(podManifests), len(resp.Pods))
}
})
}
func TestAPIServiceListInspectImages(t *testing.T) {
ctx := testutils.NewRktRunCtx()
defer ctx.Cleanup()
svc := startAPIService(t, ctx)
defer stopAPIService(t, svc)
c, conn := newAPIClientOrFail(t, "localhost:15441")
defer conn.Close()
resp, err := c.ListImages(context.Background(), &v1alpha.ListImagesRequest{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Images) != 0 {
t.Errorf("Unexpected result: %v, should see zero images", resp.Images)
}
patchImportAndFetchHash("rkt-inspect-sleep.aci", []string{"--exec=/inspect"}, t, ctx)
// ListImages(detail=false).
resp, err = c.ListImages(context.Background(), &v1alpha.ListImagesRequest{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Images) == 0 {
t.Errorf("Unexpected result: %v, should see non-zero images", resp.Images)
}
for _, m := range resp.Images {
checkImageBasics(t, ctx, m)
// Test InspectImage().
inspectResp, err := c.InspectImage(context.Background(), &v1alpha.InspectImageRequest{Id: m.Id})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
checkImageDetails(t, ctx, inspectResp.Image)
}
// ListImages(detail=true).
resp, err = c.ListImages(context.Background(), &v1alpha.ListImagesRequest{Detail: true})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Images) == 0 {
t.Errorf("Unexpected result: %v, should see non-zero images", resp.Images)
}
for _, m := range resp.Images {
checkImageDetails(t, ctx, m)
}
}
func NewAPIServiceCgroupTest() testutils.Test {
return testutils.TestFunc(func(t *testing.T) {
ctx := testutils.NewRktRunCtx()
defer ctx.Cleanup()
svc := startAPIService(t, ctx)
defer stopAPIService(t, svc)
c, conn := newAPIClientOrFail(t, "localhost:15441")
defer conn.Close()
aciFileName := patchTestACI("rkt-inspect-interactive.aci", "--exec=/inspect --read-stdin")
defer os.Remove(aciFileName)
runCmd := fmt.Sprintf("%s --insecure-options=image run --interactive %s", ctx.Cmd(), aciFileName)
child := spawnOrFail(t, runCmd)
var resp *v1alpha.ListPodsResponse
var err error
done := make(chan struct{})
// Wait the pods to be running.
go func() {
for {
// ListPods(detail=false).
resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Pods) != 0 {
allRunning := true
for _, p := range resp.Pods {
if p.State != v1alpha.PodState_POD_STATE_RUNNING || p.Pid == -1 {
allRunning = false
break
}
}
if allRunning {
t.Logf("Pods are running")
close(done)
return
}
}
t.Logf("Pods are not in RUNNING state")
time.Sleep(time.Second)
}
}()
testutils.WaitOrTimeout(t, time.Second*30, done)
var cgroups []string
var subcgroups []string
for _, p := range resp.Pods {
checkPodBasics(t, ctx, p)
// Test InspectPod().
inspectResp, err := c.InspectPod(context.Background(), &v1alpha.InspectPodRequest{Id: p.Id})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
checkPodDetails(t, ctx, inspectResp.Pod)
if p.Cgroup != "" {
cgroups = append(cgroups, p.Cgroup)
subcgroups = append(subcgroups, filepath.Join(p.Cgroup, "system.slice"))
}
}
// ListPods(detail=true). Filter according to the cgroup.
resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{
Detail: true,
Filters: []*v1alpha.PodFilter{{Cgroups: cgroups}},
})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Pods) == 0 {
t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods)
}
for _, p := range resp.Pods {
checkPodDetails(t, ctx, p)
}
resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{
Detail: true,
Filters: []*v1alpha.PodFilter{{PodSubCgroups: subcgroups}},
})
if err != nil {
t.Fatalf("Unexpected error: %v", err)
}
if len(resp.Pods) == 0 {
t.Errorf("Unexpected result: %v, should see non-zero pods", resp.Pods)
}
for _, p := range resp.Pods {
checkPodDetails(t, ctx, p)
}
// Terminate the pod.
if err := child.SendLine("Good bye"); err != nil {
t.Fatalf("Failed to send message to the pod: %v", err)
}
waitOrFail(t, child, 0)
// Check that there's no cgroups returned for non-running pods.
cgroups = []string{}
resp, err = c.ListPods(context.Background(), &v1alpha.ListPodsRequest{})
for _, p := range resp.Pods {
checkPodBasics(t, ctx, p)
if p.Cgroup != "" {
cgroups = append(cgroups, p.Cgroup)
}
}
if len(cgroups) != 0 {
t.Errorf("Unexpected cgroup returned by pods: %v", cgroups)
}
})
}