(t *testing.T)
| 426 | } |
| 427 | |
| 428 | func TestContainerExec(t *testing.T) { |
| 429 | t.Parallel() |
| 430 | |
| 431 | client, err := newClient(t, address) |
| 432 | if err != nil { |
| 433 | t.Fatal(err) |
| 434 | } |
| 435 | defer client.Close() |
| 436 | |
| 437 | var ( |
| 438 | image Image |
| 439 | ctx, cancel = testContext(t) |
| 440 | id = t.Name() |
| 441 | ) |
| 442 | defer cancel() |
| 443 | |
| 444 | image, err = client.GetImage(ctx, testImage) |
| 445 | if err != nil { |
| 446 | t.Fatal(err) |
| 447 | } |
| 448 | |
| 449 | container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand)) |
| 450 | if err != nil { |
| 451 | t.Fatal(err) |
| 452 | } |
| 453 | defer container.Delete(ctx, WithSnapshotCleanup) |
| 454 | |
| 455 | task, err := container.NewTask(ctx, empty()) |
| 456 | if err != nil { |
| 457 | t.Fatal(err) |
| 458 | } |
| 459 | defer task.Delete(ctx) |
| 460 | |
| 461 | finishedC, err := task.Wait(ctx) |
| 462 | if err != nil { |
| 463 | t.Fatal(err) |
| 464 | } |
| 465 | |
| 466 | if err := task.Start(ctx); err != nil { |
| 467 | t.Fatal(err) |
| 468 | } |
| 469 | spec, err := container.Spec(ctx) |
| 470 | if err != nil { |
| 471 | t.Fatal(err) |
| 472 | } |
| 473 | |
| 474 | // start an exec process without running the original container process info |
| 475 | processSpec := spec.Process |
| 476 | withExecExitStatus(processSpec, 6) |
| 477 | execID := t.Name() + "_exec" |
| 478 | process, err := task.Exec(ctx, execID, processSpec, empty()) |
| 479 | if err != nil { |
| 480 | t.Fatal(err) |
| 481 | } |
| 482 | processStatusC, err := process.Wait(ctx) |
| 483 | if err != nil { |
| 484 | t.Fatal(err) |
| 485 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…