Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
| ... | ... |
@@ -42,6 +42,7 @@ linters: |
| 42 | 42 |
- revive # Metalinter; drop-in replacement for golint. |
| 43 | 43 |
- spancheck # Detects mistakes with OpenTelemetry/Census spans. |
| 44 | 44 |
- staticcheck |
| 45 |
+ - thelper |
|
| 45 | 46 |
- unconvert # Detects unnecessary type conversions. |
| 46 | 47 |
- unused |
| 47 | 48 |
- usestdlibvars # Detects the possibility to use variables/constants from the Go standard library. |
| ... | ... |
@@ -164,6 +165,30 @@ linters: |
| 164 | 164 |
- record-error # check that `span.RecordError(err)` is called when an error is returned |
| 165 | 165 |
- set-status # check that `span.SetStatus(codes.Error, msg)` is called when an error is returned |
| 166 | 166 |
|
| 167 |
+ thelper: |
|
| 168 |
+ test: |
|
| 169 |
+ # Check *testing.T is first param (or after context.Context) of helper function. |
|
| 170 |
+ first: false |
|
| 171 |
+ # Check t.Helper() begins helper function. |
|
| 172 |
+ begin: false |
|
| 173 |
+ benchmark: |
|
| 174 |
+ # Check *testing.B is first param (or after context.Context) of helper function. |
|
| 175 |
+ first: false |
|
| 176 |
+ # Check b.Helper() begins helper function. |
|
| 177 |
+ begin: false |
|
| 178 |
+ tb: |
|
| 179 |
+ # Check *testing.TB is first param (or after context.Context) of helper function. |
|
| 180 |
+ first: false |
|
| 181 |
+ # Check *testing.TB param has name tb. |
|
| 182 |
+ name: false |
|
| 183 |
+ # Check tb.Helper() begins helper function. |
|
| 184 |
+ begin: false |
|
| 185 |
+ fuzz: |
|
| 186 |
+ # Check *testing.F is first param (or after context.Context) of helper function. |
|
| 187 |
+ first: false |
|
| 188 |
+ # Check f.Helper() begins helper function. |
|
| 189 |
+ begin: false |
|
| 190 |
+ |
|
| 167 | 191 |
usestdlibvars: |
| 168 | 192 |
# Suggest the use of http.MethodXX. |
| 169 | 193 |
http-method: true |
| ... | ... |
@@ -18,12 +18,12 @@ type DockerBenchmarkSuite struct {
|
| 18 | 18 |
ds *DockerSuite |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (s *DockerBenchmarkSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 22 |
- s.ds.TearDownTest(ctx, c) |
|
| 21 |
+func (s *DockerBenchmarkSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 22 |
+ s.ds.TearDownTest(ctx, t) |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
-func (s *DockerBenchmarkSuite) OnTimeout(c *testing.T) {
|
|
| 26 |
- s.ds.OnTimeout(c) |
|
| 25 |
+func (s *DockerBenchmarkSuite) OnTimeout(t *testing.T) {
|
|
| 26 |
+ s.ds.OnTimeout(t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
func (s *DockerBenchmarkSuite) BenchmarkConcurrentContainerActions(c *testing.B) {
|
| ... | ... |
@@ -418,19 +418,19 @@ func TestDockerHubPullSuite(t *testing.T) {
|
| 418 | 418 |
|
| 419 | 419 |
type DockerSuite struct{}
|
| 420 | 420 |
|
| 421 |
-func (s *DockerSuite) OnTimeout(c *testing.T) {
|
|
| 421 |
+func (s *DockerSuite) OnTimeout(t *testing.T) {
|
|
| 422 | 422 |
if testEnv.IsRemoteDaemon() {
|
| 423 | 423 |
return |
| 424 | 424 |
} |
| 425 | 425 |
path := filepath.Join(os.Getenv("DEST"), "docker.pid")
|
| 426 | 426 |
b, err := os.ReadFile(path) |
| 427 | 427 |
if err != nil {
|
| 428 |
- c.Fatalf("Failed to get daemon PID from %s\n", path)
|
|
| 428 |
+ t.Fatalf("Failed to get daemon PID from %s\n", path)
|
|
| 429 | 429 |
} |
| 430 | 430 |
|
| 431 | 431 |
rawPid, err := strconv.ParseInt(string(b), 10, 32) |
| 432 | 432 |
if err != nil {
|
| 433 |
- c.Fatalf("Failed to parse pid from %s: %s\n", path, err)
|
|
| 433 |
+ t.Fatalf("Failed to parse pid from %s: %s\n", path, err)
|
|
| 434 | 434 |
} |
| 435 | 435 |
|
| 436 | 436 |
daemonPid := int(rawPid) |
| ... | ... |
@@ -439,8 +439,8 @@ func (s *DockerSuite) OnTimeout(c *testing.T) {
|
| 439 | 439 |
} |
| 440 | 440 |
} |
| 441 | 441 |
|
| 442 |
-func (s *DockerSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 443 |
- testEnv.Clean(ctx, c) |
|
| 442 |
+func (s *DockerSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 443 |
+ testEnv.Clean(ctx, t) |
|
| 444 | 444 |
} |
| 445 | 445 |
|
| 446 | 446 |
type DockerRegistrySuite struct {
|
| ... | ... |
@@ -449,25 +449,25 @@ type DockerRegistrySuite struct {
|
| 449 | 449 |
d *daemon.Daemon |
| 450 | 450 |
} |
| 451 | 451 |
|
| 452 |
-func (s *DockerRegistrySuite) OnTimeout(c *testing.T) {
|
|
| 452 |
+func (s *DockerRegistrySuite) OnTimeout(t *testing.T) {
|
|
| 453 | 453 |
s.d.DumpStackAndQuit() |
| 454 | 454 |
} |
| 455 | 455 |
|
| 456 |
-func (s *DockerRegistrySuite) SetUpTest(ctx context.Context, c *testing.T) {
|
|
| 457 |
- testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) |
|
| 458 |
- s.reg = registry.NewV2(c) |
|
| 459 |
- s.reg.WaitReady(c) |
|
| 460 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 456 |
+func (s *DockerRegistrySuite) SetUpTest(ctx context.Context, t *testing.T) {
|
|
| 457 |
+ testRequires(t, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) |
|
| 458 |
+ s.reg = registry.NewV2(t) |
|
| 459 |
+ s.reg.WaitReady(t) |
|
| 460 |
+ s.d = daemon.New(t, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 461 | 461 |
} |
| 462 | 462 |
|
| 463 |
-func (s *DockerRegistrySuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 463 |
+func (s *DockerRegistrySuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 464 | 464 |
if s.reg != nil {
|
| 465 | 465 |
s.reg.Close() |
| 466 | 466 |
} |
| 467 | 467 |
if s.d != nil {
|
| 468 |
- s.d.Stop(c) |
|
| 468 |
+ s.d.Stop(t) |
|
| 469 | 469 |
} |
| 470 |
- s.ds.TearDownTest(ctx, c) |
|
| 470 |
+ s.ds.TearDownTest(ctx, t) |
|
| 471 | 471 |
} |
| 472 | 472 |
|
| 473 | 473 |
type DockerRegistryAuthHtpasswdSuite struct {
|
| ... | ... |
@@ -476,27 +476,27 @@ type DockerRegistryAuthHtpasswdSuite struct {
|
| 476 | 476 |
d *daemon.Daemon |
| 477 | 477 |
} |
| 478 | 478 |
|
| 479 |
-func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(c *testing.T) {
|
|
| 479 |
+func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(t *testing.T) {
|
|
| 480 | 480 |
s.d.DumpStackAndQuit() |
| 481 | 481 |
} |
| 482 | 482 |
|
| 483 |
-func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(ctx context.Context, c *testing.T) {
|
|
| 484 |
- testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) |
|
| 485 |
- s.reg = registry.NewV2(c, registry.Htpasswd) |
|
| 486 |
- s.reg.WaitReady(c) |
|
| 487 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 483 |
+func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(ctx context.Context, t *testing.T) {
|
|
| 484 |
+ testRequires(t, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) |
|
| 485 |
+ s.reg = registry.NewV2(t, registry.Htpasswd) |
|
| 486 |
+ s.reg.WaitReady(t) |
|
| 487 |
+ s.d = daemon.New(t, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 488 | 488 |
} |
| 489 | 489 |
|
| 490 |
-func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 490 |
+func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 491 | 491 |
if s.reg != nil {
|
| 492 | 492 |
out, err := s.d.Cmd("logout", privateRegistryURL)
|
| 493 |
- assert.NilError(c, err, out) |
|
| 493 |
+ assert.NilError(t, err, out) |
|
| 494 | 494 |
s.reg.Close() |
| 495 | 495 |
} |
| 496 | 496 |
if s.d != nil {
|
| 497 |
- s.d.Stop(c) |
|
| 497 |
+ s.d.Stop(t) |
|
| 498 | 498 |
} |
| 499 |
- s.ds.TearDownTest(ctx, c) |
|
| 499 |
+ s.ds.TearDownTest(ctx, t) |
|
| 500 | 500 |
} |
| 501 | 501 |
|
| 502 | 502 |
type DockerRegistryAuthTokenSuite struct {
|
| ... | ... |
@@ -505,33 +505,33 @@ type DockerRegistryAuthTokenSuite struct {
|
| 505 | 505 |
d *daemon.Daemon |
| 506 | 506 |
} |
| 507 | 507 |
|
| 508 |
-func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *testing.T) {
|
|
| 508 |
+func (s *DockerRegistryAuthTokenSuite) OnTimeout(t *testing.T) {
|
|
| 509 | 509 |
s.d.DumpStackAndQuit() |
| 510 | 510 |
} |
| 511 | 511 |
|
| 512 |
-func (s *DockerRegistryAuthTokenSuite) SetUpTest(ctx context.Context, c *testing.T) {
|
|
| 513 |
- testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) |
|
| 514 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 512 |
+func (s *DockerRegistryAuthTokenSuite) SetUpTest(ctx context.Context, t *testing.T) {
|
|
| 513 |
+ testRequires(t, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon) |
|
| 514 |
+ s.d = daemon.New(t, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 515 | 515 |
} |
| 516 | 516 |
|
| 517 |
-func (s *DockerRegistryAuthTokenSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 517 |
+func (s *DockerRegistryAuthTokenSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 518 | 518 |
if s.reg != nil {
|
| 519 | 519 |
out, err := s.d.Cmd("logout", privateRegistryURL)
|
| 520 |
- assert.NilError(c, err, out) |
|
| 520 |
+ assert.NilError(t, err, out) |
|
| 521 | 521 |
s.reg.Close() |
| 522 | 522 |
} |
| 523 | 523 |
if s.d != nil {
|
| 524 |
- s.d.Stop(c) |
|
| 524 |
+ s.d.Stop(t) |
|
| 525 | 525 |
} |
| 526 |
- s.ds.TearDownTest(ctx, c) |
|
| 526 |
+ s.ds.TearDownTest(ctx, t) |
|
| 527 | 527 |
} |
| 528 | 528 |
|
| 529 |
-func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(c *testing.T, tokenURL string) {
|
|
| 529 |
+func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(t *testing.T, tokenURL string) {
|
|
| 530 | 530 |
if s == nil {
|
| 531 |
- c.Fatal("registry suite isn't initialized")
|
|
| 531 |
+ t.Fatal("registry suite isn't initialized")
|
|
| 532 | 532 |
} |
| 533 |
- s.reg = registry.NewV2(c, registry.Token(tokenURL)) |
|
| 534 |
- s.reg.WaitReady(c) |
|
| 533 |
+ s.reg = registry.NewV2(t, registry.Token(tokenURL)) |
|
| 534 |
+ s.reg.WaitReady(t) |
|
| 535 | 535 |
} |
| 536 | 536 |
|
| 537 | 537 |
type DockerDaemonSuite struct {
|
| ... | ... |
@@ -539,24 +539,24 @@ type DockerDaemonSuite struct {
|
| 539 | 539 |
d *daemon.Daemon |
| 540 | 540 |
} |
| 541 | 541 |
|
| 542 |
-func (s *DockerDaemonSuite) OnTimeout(c *testing.T) {
|
|
| 542 |
+func (s *DockerDaemonSuite) OnTimeout(t *testing.T) {
|
|
| 543 | 543 |
s.d.DumpStackAndQuit() |
| 544 | 544 |
} |
| 545 | 545 |
|
| 546 |
-func (s *DockerDaemonSuite) SetUpTest(ctx context.Context, c *testing.T) {
|
|
| 547 |
- testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) |
|
| 548 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 546 |
+func (s *DockerDaemonSuite) SetUpTest(ctx context.Context, t *testing.T) {
|
|
| 547 |
+ testRequires(t, DaemonIsLinux, testEnv.IsLocalDaemon) |
|
| 548 |
+ s.d = daemon.New(t, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 549 | 549 |
} |
| 550 | 550 |
|
| 551 |
-func (s *DockerDaemonSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 552 |
- testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) |
|
| 551 |
+func (s *DockerDaemonSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 552 |
+ testRequires(t, DaemonIsLinux, testEnv.IsLocalDaemon) |
|
| 553 | 553 |
if s.d != nil {
|
| 554 |
- s.d.Stop(c) |
|
| 554 |
+ s.d.Stop(t) |
|
| 555 | 555 |
} |
| 556 |
- s.ds.TearDownTest(ctx, c) |
|
| 556 |
+ s.ds.TearDownTest(ctx, t) |
|
| 557 | 557 |
} |
| 558 | 558 |
|
| 559 |
-func (s *DockerDaemonSuite) TearDownSuite(ctx context.Context, c *testing.T) {
|
|
| 559 |
+func (s *DockerDaemonSuite) TearDownSuite(ctx context.Context, t *testing.T) {
|
|
| 560 | 560 |
filepath.Walk(testdaemon.SockRoot, func(path string, fi os.FileInfo, err error) error {
|
| 561 | 561 |
if err != nil {
|
| 562 | 562 |
// ignore errors here |
| ... | ... |
@@ -581,7 +581,7 @@ type DockerSwarmSuite struct {
|
| 581 | 581 |
portIndex int |
| 582 | 582 |
} |
| 583 | 583 |
|
| 584 |
-func (s *DockerSwarmSuite) OnTimeout(c *testing.T) {
|
|
| 584 |
+func (s *DockerSwarmSuite) OnTimeout(t *testing.T) {
|
|
| 585 | 585 |
s.daemonsLock.Lock() |
| 586 | 586 |
defer s.daemonsLock.Unlock() |
| 587 | 587 |
for _, d := range s.daemons {
|
| ... | ... |
@@ -589,24 +589,24 @@ func (s *DockerSwarmSuite) OnTimeout(c *testing.T) {
|
| 589 | 589 |
} |
| 590 | 590 |
} |
| 591 | 591 |
|
| 592 |
-func (s *DockerSwarmSuite) SetUpTest(ctx context.Context, c *testing.T) {
|
|
| 593 |
- testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) |
|
| 592 |
+func (s *DockerSwarmSuite) SetUpTest(ctx context.Context, t *testing.T) {
|
|
| 593 |
+ testRequires(t, DaemonIsLinux, testEnv.IsLocalDaemon) |
|
| 594 | 594 |
} |
| 595 | 595 |
|
| 596 |
-func (s *DockerSwarmSuite) AddDaemon(ctx context.Context, c *testing.T, joinSwarm, manager bool) *daemon.Daemon {
|
|
| 597 |
- c.Helper() |
|
| 598 |
- d := daemon.New(c, dockerBinary, dockerdBinary, |
|
| 596 |
+func (s *DockerSwarmSuite) AddDaemon(ctx context.Context, t *testing.T, joinSwarm, manager bool) *daemon.Daemon {
|
|
| 597 |
+ t.Helper() |
|
| 598 |
+ d := daemon.New(t, dockerBinary, dockerdBinary, |
|
| 599 | 599 |
testdaemon.WithEnvironment(testEnv.Execution), |
| 600 | 600 |
testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex), |
| 601 | 601 |
) |
| 602 | 602 |
if joinSwarm {
|
| 603 | 603 |
if len(s.daemons) > 0 {
|
| 604 |
- d.StartAndSwarmJoin(ctx, c, s.daemons[0].Daemon, manager) |
|
| 604 |
+ d.StartAndSwarmJoin(ctx, t, s.daemons[0].Daemon, manager) |
|
| 605 | 605 |
} else {
|
| 606 |
- d.StartAndSwarmInit(ctx, c) |
|
| 606 |
+ d.StartAndSwarmInit(ctx, t) |
|
| 607 | 607 |
} |
| 608 | 608 |
} else {
|
| 609 |
- d.StartNodeWithBusybox(ctx, c) |
|
| 609 |
+ d.StartNodeWithBusybox(ctx, t) |
|
| 610 | 610 |
} |
| 611 | 611 |
|
| 612 | 612 |
s.daemonsLock.Lock() |
| ... | ... |
@@ -617,22 +617,22 @@ func (s *DockerSwarmSuite) AddDaemon(ctx context.Context, c *testing.T, joinSwar |
| 617 | 617 |
return d |
| 618 | 618 |
} |
| 619 | 619 |
|
| 620 |
-func (s *DockerSwarmSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 621 |
- testRequires(c, DaemonIsLinux) |
|
| 620 |
+func (s *DockerSwarmSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 621 |
+ testRequires(t, DaemonIsLinux) |
|
| 622 | 622 |
s.daemonsLock.Lock() |
| 623 | 623 |
for _, d := range s.daemons {
|
| 624 | 624 |
if d != nil {
|
| 625 |
- if c.Failed() {
|
|
| 626 |
- d.TailLogsT(c, 100) |
|
| 625 |
+ if t.Failed() {
|
|
| 626 |
+ d.TailLogsT(t, 100) |
|
| 627 | 627 |
} |
| 628 |
- d.Stop(c) |
|
| 629 |
- d.Cleanup(c) |
|
| 628 |
+ d.Stop(t) |
|
| 629 |
+ d.Cleanup(t) |
|
| 630 | 630 |
} |
| 631 | 631 |
} |
| 632 | 632 |
s.daemons = nil |
| 633 | 633 |
s.portIndex = 0 |
| 634 | 634 |
s.daemonsLock.Unlock() |
| 635 |
- s.ds.TearDownTest(ctx, c) |
|
| 635 |
+ s.ds.TearDownTest(ctx, t) |
|
| 636 | 636 |
} |
| 637 | 637 |
|
| 638 | 638 |
type DockerPluginSuite struct {
|
| ... | ... |
@@ -652,28 +652,28 @@ func (ps *DockerPluginSuite) getPluginRepoWithTag() string {
|
| 652 | 652 |
return ps.getPluginRepo() + ":" + "latest" |
| 653 | 653 |
} |
| 654 | 654 |
|
| 655 |
-func (ps *DockerPluginSuite) SetUpSuite(ctx context.Context, c *testing.T) {
|
|
| 656 |
- testRequires(c, DaemonIsLinux, RegistryHosting) |
|
| 657 |
- ps.registry = registry.NewV2(c) |
|
| 658 |
- ps.registry.WaitReady(c) |
|
| 655 |
+func (ps *DockerPluginSuite) SetUpSuite(ctx context.Context, t *testing.T) {
|
|
| 656 |
+ testRequires(t, DaemonIsLinux, RegistryHosting) |
|
| 657 |
+ ps.registry = registry.NewV2(t) |
|
| 658 |
+ ps.registry.WaitReady(t) |
|
| 659 | 659 |
|
| 660 | 660 |
ctx, cancel := context.WithTimeout(ctx, 60*time.Second) |
| 661 | 661 |
defer cancel() |
| 662 | 662 |
|
| 663 | 663 |
err := plugin.CreateInRegistry(ctx, ps.getPluginRepo(), nil) |
| 664 |
- assert.NilError(c, err, "failed to create plugin") |
|
| 664 |
+ assert.NilError(t, err, "failed to create plugin") |
|
| 665 | 665 |
} |
| 666 | 666 |
|
| 667 |
-func (ps *DockerPluginSuite) TearDownSuite(ctx context.Context, c *testing.T) {
|
|
| 667 |
+func (ps *DockerPluginSuite) TearDownSuite(ctx context.Context, t *testing.T) {
|
|
| 668 | 668 |
if ps.registry != nil {
|
| 669 | 669 |
ps.registry.Close() |
| 670 | 670 |
} |
| 671 | 671 |
} |
| 672 | 672 |
|
| 673 |
-func (ps *DockerPluginSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 674 |
- ps.ds.TearDownTest(ctx, c) |
|
| 673 |
+func (ps *DockerPluginSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 674 |
+ ps.ds.TearDownTest(ctx, t) |
|
| 675 | 675 |
} |
| 676 | 676 |
|
| 677 |
-func (ps *DockerPluginSuite) OnTimeout(c *testing.T) {
|
|
| 678 |
- ps.ds.OnTimeout(c) |
|
| 677 |
+func (ps *DockerPluginSuite) OnTimeout(t *testing.T) {
|
|
| 678 |
+ ps.ds.OnTimeout(t) |
|
| 679 | 679 |
} |
| ... | ... |
@@ -15,8 +15,8 @@ import ( |
| 15 | 15 |
// CheckServiceTasksInState returns the number of tasks with a matching state, |
| 16 | 16 |
// and optional message substring. |
| 17 | 17 |
func (d *Daemon) CheckServiceTasksInState(ctx context.Context, service string, state swarm.TaskState, message string) func(*testing.T) (interface{}, string) {
|
| 18 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 19 |
- tasks := d.GetServiceTasks(ctx, c, service) |
|
| 18 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 19 |
+ tasks := d.GetServiceTasks(ctx, t, service) |
|
| 20 | 20 |
var count int |
| 21 | 21 |
for _, task := range tasks {
|
| 22 | 22 |
if task.Status.State == state {
|
| ... | ... |
@@ -32,8 +32,8 @@ func (d *Daemon) CheckServiceTasksInState(ctx context.Context, service string, s |
| 32 | 32 |
// CheckServiceTasksInStateWithError returns the number of tasks with a matching state, |
| 33 | 33 |
// and optional message substring. |
| 34 | 34 |
func (d *Daemon) CheckServiceTasksInStateWithError(ctx context.Context, service string, state swarm.TaskState, errorMessage string) func(*testing.T) (interface{}, string) {
|
| 35 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 36 |
- tasks := d.GetServiceTasks(ctx, c, service) |
|
| 35 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 36 |
+ tasks := d.GetServiceTasks(ctx, t, service) |
|
| 37 | 37 |
var count int |
| 38 | 38 |
for _, task := range tasks {
|
| 39 | 39 |
if task.Status.State == state {
|
| ... | ... |
@@ -53,8 +53,8 @@ func (d *Daemon) CheckServiceRunningTasks(ctx context.Context, service string) f |
| 53 | 53 |
|
| 54 | 54 |
// CheckServiceUpdateState returns the current update state for the specified service |
| 55 | 55 |
func (d *Daemon) CheckServiceUpdateState(ctx context.Context, service string) func(*testing.T) (interface{}, string) {
|
| 56 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 57 |
- service := d.GetService(ctx, c, service) |
|
| 56 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 57 |
+ service := d.GetService(ctx, t, service) |
|
| 58 | 58 |
if service.UpdateStatus == nil {
|
| 59 | 59 |
return "", "" |
| 60 | 60 |
} |
| ... | ... |
@@ -64,34 +64,34 @@ func (d *Daemon) CheckServiceUpdateState(ctx context.Context, service string) fu |
| 64 | 64 |
|
| 65 | 65 |
// CheckPluginRunning returns the runtime state of the plugin |
| 66 | 66 |
func (d *Daemon) CheckPluginRunning(ctx context.Context, plugin string) func(c *testing.T) (interface{}, string) {
|
| 67 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 68 |
- apiclient := d.NewClientT(c) |
|
| 67 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 68 |
+ apiclient := d.NewClientT(t) |
|
| 69 | 69 |
resp, _, err := apiclient.PluginInspectWithRaw(ctx, plugin) |
| 70 | 70 |
if cerrdefs.IsNotFound(err) {
|
| 71 | 71 |
return false, fmt.Sprintf("%v", err)
|
| 72 | 72 |
} |
| 73 |
- assert.NilError(c, err) |
|
| 73 |
+ assert.NilError(t, err) |
|
| 74 | 74 |
return resp.Enabled, fmt.Sprintf("%+v", resp)
|
| 75 | 75 |
} |
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 | 78 |
// CheckPluginImage returns the runtime state of the plugin |
| 79 | 79 |
func (d *Daemon) CheckPluginImage(ctx context.Context, plugin string) func(c *testing.T) (interface{}, string) {
|
| 80 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 81 |
- apiclient := d.NewClientT(c) |
|
| 80 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 81 |
+ apiclient := d.NewClientT(t) |
|
| 82 | 82 |
resp, _, err := apiclient.PluginInspectWithRaw(ctx, plugin) |
| 83 | 83 |
if cerrdefs.IsNotFound(err) {
|
| 84 | 84 |
return false, fmt.Sprintf("%v", err)
|
| 85 | 85 |
} |
| 86 |
- assert.NilError(c, err) |
|
| 86 |
+ assert.NilError(t, err) |
|
| 87 | 87 |
return resp.PluginReference, fmt.Sprintf("%+v", resp)
|
| 88 | 88 |
} |
| 89 | 89 |
} |
| 90 | 90 |
|
| 91 | 91 |
// CheckServiceTasks returns the number of tasks for the specified service |
| 92 | 92 |
func (d *Daemon) CheckServiceTasks(ctx context.Context, service string) func(*testing.T) (interface{}, string) {
|
| 93 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 94 |
- tasks := d.GetServiceTasks(ctx, c, service) |
|
| 93 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 94 |
+ tasks := d.GetServiceTasks(ctx, t, service) |
|
| 95 | 95 |
return len(tasks), "" |
| 96 | 96 |
} |
| 97 | 97 |
} |
| ... | ... |
@@ -6,7 +6,7 @@ import ( |
| 6 | 6 |
"github.com/docker/docker/integration-cli/daemon" |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 |
-func (s *DockerSwarmSuite) getDaemon(c *testing.T, nodeID string) *daemon.Daemon {
|
|
| 9 |
+func (s *DockerSwarmSuite) getDaemon(t *testing.T, nodeID string) *daemon.Daemon {
|
|
| 10 | 10 |
s.daemonsLock.Lock() |
| 11 | 11 |
defer s.daemonsLock.Unlock() |
| 12 | 12 |
for _, d := range s.daemons {
|
| ... | ... |
@@ -14,11 +14,11 @@ func (s *DockerSwarmSuite) getDaemon(c *testing.T, nodeID string) *daemon.Daemon |
| 14 | 14 |
return d |
| 15 | 15 |
} |
| 16 | 16 |
} |
| 17 |
- c.Fatalf("could not find node with id: %s", nodeID)
|
|
| 17 |
+ t.Fatalf("could not find node with id: %s", nodeID)
|
|
| 18 | 18 |
return nil |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 | 21 |
// nodeCmd executes a command on a given node via the normal docker socket |
| 22 |
-func (s *DockerSwarmSuite) nodeCmd(c *testing.T, id string, args ...string) (string, error) {
|
|
| 23 |
- return s.getDaemon(c, id).Cmd(args...) |
|
| 22 |
+func (s *DockerSwarmSuite) nodeCmd(t *testing.T, id string, args ...string) (string, error) {
|
|
| 23 |
+ return s.getDaemon(t, id).Cmd(args...) |
|
| 24 | 24 |
} |
| ... | ... |
@@ -555,14 +555,14 @@ type buildLine struct {
|
| 555 | 555 |
} |
| 556 | 556 |
} |
| 557 | 557 |
|
| 558 |
-func getImageIDsFromBuild(c *testing.T, output []byte) []string {
|
|
| 558 |
+func getImageIDsFromBuild(t *testing.T, output []byte) []string {
|
|
| 559 | 559 |
var ids []string |
| 560 | 560 |
for _, line := range bytes.Split(output, []byte("\n")) {
|
| 561 | 561 |
if len(line) == 0 {
|
| 562 | 562 |
continue |
| 563 | 563 |
} |
| 564 | 564 |
entry := buildLine{}
|
| 565 |
- assert.NilError(c, json.Unmarshal(line, &entry)) |
|
| 565 |
+ assert.NilError(t, json.Unmarshal(line, &entry)) |
|
| 566 | 566 |
if entry.Aux.ID != "" {
|
| 567 | 567 |
ids = append(ids, entry.Aux.ID) |
| 568 | 568 |
} |
| ... | ... |
@@ -361,8 +361,8 @@ func (s *DockerAPISuite) TestContainerAPIPause(c *testing.T) {
|
| 361 | 361 |
// Problematic on Windows as Windows does not support pause |
| 362 | 362 |
testRequires(c, DaemonIsLinux) |
| 363 | 363 |
|
| 364 |
- getPaused := func(c *testing.T) []string {
|
|
| 365 |
- return strings.Fields(cli.DockerCmd(c, "ps", "-f", "status=paused", "-q", "-a").Combined()) |
|
| 364 |
+ getPaused := func(t *testing.T) []string {
|
|
| 365 |
+ return strings.Fields(cli.DockerCmd(t, "ps", "-f", "status=paused", "-q", "-a").Combined()) |
|
| 366 | 366 |
} |
| 367 | 367 |
|
| 368 | 368 |
out := cli.DockerCmd(c, "run", "-d", "busybox", "sleep", "30").Combined() |
| ... | ... |
@@ -564,7 +564,7 @@ func (s *DockerAPISuite) TestContainerAPICreateOtherNetworkModes(c *testing.T) {
|
| 564 | 564 |
UtilCreateNetworkMode(c, "container:web1") |
| 565 | 565 |
} |
| 566 | 566 |
|
| 567 |
-func UtilCreateNetworkMode(c *testing.T, networkMode container.NetworkMode) {
|
|
| 567 |
+func UtilCreateNetworkMode(t *testing.T, networkMode container.NetworkMode) {
|
|
| 568 | 568 |
config := container.Config{
|
| 569 | 569 |
Image: "busybox", |
| 570 | 570 |
} |
| ... | ... |
@@ -574,16 +574,16 @@ func UtilCreateNetworkMode(c *testing.T, networkMode container.NetworkMode) {
|
| 574 | 574 |
} |
| 575 | 575 |
|
| 576 | 576 |
apiClient, err := client.NewClientWithOpts(client.FromEnv) |
| 577 |
- assert.NilError(c, err) |
|
| 577 |
+ assert.NilError(t, err) |
|
| 578 | 578 |
defer apiClient.Close() |
| 579 | 579 |
|
| 580 |
- ctr, err := apiClient.ContainerCreate(testutil.GetContext(c), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
|
|
| 581 |
- assert.NilError(c, err) |
|
| 580 |
+ ctr, err := apiClient.ContainerCreate(testutil.GetContext(t), &config, &hostConfig, &network.NetworkingConfig{}, nil, "")
|
|
| 581 |
+ assert.NilError(t, err) |
|
| 582 | 582 |
|
| 583 |
- containerJSON, err := apiClient.ContainerInspect(testutil.GetContext(c), ctr.ID) |
|
| 584 |
- assert.NilError(c, err) |
|
| 583 |
+ containerJSON, err := apiClient.ContainerInspect(testutil.GetContext(t), ctr.ID) |
|
| 584 |
+ assert.NilError(t, err) |
|
| 585 | 585 |
|
| 586 |
- assert.Equal(c, containerJSON.HostConfig.NetworkMode, networkMode, "Mismatched NetworkMode") |
|
| 586 |
+ assert.Equal(t, containerJSON.HostConfig.NetworkMode, networkMode, "Mismatched NetworkMode") |
|
| 587 | 587 |
} |
| 588 | 588 |
|
| 589 | 589 |
func (s *DockerAPISuite) TestContainerAPICreateWithCpuSharesCpuset(c *testing.T) {
|
| ... | ... |
@@ -193,9 +193,9 @@ func (s *DockerAPISuite) TestExecStateCleanup(c *testing.T) {
|
| 193 | 193 |
|
| 194 | 194 |
stateDir := "/var/run/docker/containerd/" + cid |
| 195 | 195 |
|
| 196 |
- checkReadDir := func(c *testing.T) (interface{}, string) {
|
|
| 196 |
+ checkReadDir := func(t *testing.T) (interface{}, string) {
|
|
| 197 | 197 |
fi, err := os.ReadDir(stateDir) |
| 198 |
- assert.NilError(c, err) |
|
| 198 |
+ assert.NilError(t, err) |
|
| 199 | 199 |
return len(fi), "" |
| 200 | 200 |
} |
| 201 | 201 |
|
| ... | ... |
@@ -223,63 +223,63 @@ func (s *DockerAPISuite) TestExecStateCleanup(c *testing.T) {
|
| 223 | 223 |
assert.Assert(c, os.IsNotExist(err)) |
| 224 | 224 |
} |
| 225 | 225 |
|
| 226 |
-func createExec(c *testing.T, name string) string {
|
|
| 227 |
- return createExecCmd(c, name, "true") |
|
| 226 |
+func createExec(t *testing.T, name string) string {
|
|
| 227 |
+ return createExecCmd(t, name, "true") |
|
| 228 | 228 |
} |
| 229 | 229 |
|
| 230 |
-func createExecCmd(c *testing.T, name string, cmd string) string {
|
|
| 231 |
- _, reader, err := request.Post(testutil.GetContext(c), fmt.Sprintf("/containers/%s/exec", name), request.JSONBody(map[string]interface{}{"Cmd": []string{cmd}}))
|
|
| 232 |
- assert.NilError(c, err) |
|
| 230 |
+func createExecCmd(t *testing.T, name string, cmd string) string {
|
|
| 231 |
+ _, reader, err := request.Post(testutil.GetContext(t), fmt.Sprintf("/containers/%s/exec", name), request.JSONBody(map[string]interface{}{"Cmd": []string{cmd}}))
|
|
| 232 |
+ assert.NilError(t, err) |
|
| 233 | 233 |
b, err := io.ReadAll(reader) |
| 234 |
- assert.NilError(c, err) |
|
| 234 |
+ assert.NilError(t, err) |
|
| 235 | 235 |
defer reader.Close() |
| 236 | 236 |
createResp := struct {
|
| 237 | 237 |
ID string `json:"Id"` |
| 238 | 238 |
}{}
|
| 239 |
- assert.NilError(c, json.Unmarshal(b, &createResp), string(b)) |
|
| 239 |
+ assert.NilError(t, json.Unmarshal(b, &createResp), string(b)) |
|
| 240 | 240 |
return createResp.ID |
| 241 | 241 |
} |
| 242 | 242 |
|
| 243 |
-func startExec(c *testing.T, id string, code int) {
|
|
| 244 |
- resp, body, err := request.Post(testutil.GetContext(c), fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON)
|
|
| 245 |
- assert.NilError(c, err) |
|
| 243 |
+func startExec(t *testing.T, id string, code int) {
|
|
| 244 |
+ resp, body, err := request.Post(testutil.GetContext(t), fmt.Sprintf("/exec/%s/start", id), request.RawString(`{"Detach": true}`), request.JSON)
|
|
| 245 |
+ assert.NilError(t, err) |
|
| 246 | 246 |
|
| 247 | 247 |
b, err := request.ReadBody(body) |
| 248 |
- assert.NilError(c, err, "response body: %s", b) |
|
| 249 |
- assert.Equal(c, resp.StatusCode, code, "response body: %s", b) |
|
| 248 |
+ assert.NilError(t, err, "response body: %s", b) |
|
| 249 |
+ assert.Equal(t, resp.StatusCode, code, "response body: %s", b) |
|
| 250 | 250 |
} |
| 251 | 251 |
|
| 252 |
-func inspectExec(ctx context.Context, c *testing.T, id string, out interface{}) {
|
|
| 252 |
+func inspectExec(ctx context.Context, t *testing.T, id string, out interface{}) {
|
|
| 253 | 253 |
resp, body, err := request.Get(ctx, fmt.Sprintf("/exec/%s/json", id))
|
| 254 |
- assert.NilError(c, err) |
|
| 254 |
+ assert.NilError(t, err) |
|
| 255 | 255 |
defer body.Close() |
| 256 |
- assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 256 |
+ assert.Equal(t, resp.StatusCode, http.StatusOK) |
|
| 257 | 257 |
err = json.NewDecoder(body).Decode(out) |
| 258 |
- assert.NilError(c, err) |
|
| 258 |
+ assert.NilError(t, err) |
|
| 259 | 259 |
} |
| 260 | 260 |
|
| 261 |
-func waitForExec(ctx context.Context, c *testing.T, id string) {
|
|
| 261 |
+func waitForExec(ctx context.Context, t *testing.T, id string) {
|
|
| 262 | 262 |
timeout := time.After(60 * time.Second) |
| 263 | 263 |
var execJSON struct{ Running bool }
|
| 264 | 264 |
for {
|
| 265 | 265 |
select {
|
| 266 | 266 |
case <-timeout: |
| 267 |
- c.Fatal("timeout waiting for exec to start")
|
|
| 267 |
+ t.Fatal("timeout waiting for exec to start")
|
|
| 268 | 268 |
default: |
| 269 | 269 |
} |
| 270 | 270 |
|
| 271 |
- inspectExec(ctx, c, id, &execJSON) |
|
| 271 |
+ inspectExec(ctx, t, id, &execJSON) |
|
| 272 | 272 |
if !execJSON.Running {
|
| 273 | 273 |
break |
| 274 | 274 |
} |
| 275 | 275 |
} |
| 276 | 276 |
} |
| 277 | 277 |
|
| 278 |
-func inspectContainer(ctx context.Context, c *testing.T, id string, out interface{}) {
|
|
| 278 |
+func inspectContainer(ctx context.Context, t *testing.T, id string, out interface{}) {
|
|
| 279 | 279 |
resp, body, err := request.Get(ctx, "/containers/"+id+"/json") |
| 280 |
- assert.NilError(c, err) |
|
| 280 |
+ assert.NilError(t, err) |
|
| 281 | 281 |
defer body.Close() |
| 282 |
- assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 282 |
+ assert.Equal(t, resp.StatusCode, http.StatusOK) |
|
| 283 | 283 |
err = json.NewDecoder(body).Decode(out) |
| 284 |
- assert.NilError(c, err) |
|
| 284 |
+ assert.NilError(t, err) |
|
| 285 | 285 |
} |
| ... | ... |
@@ -171,14 +171,14 @@ func (s *DockerAPISuite) TestLogsAPIUntil(c *testing.T) {
|
| 171 | 171 |
c.Fatal(err) |
| 172 | 172 |
} |
| 173 | 173 |
|
| 174 |
- extractBody := func(c *testing.T, cfg container.LogsOptions) []string {
|
|
| 175 |
- reader, err := apiClient.ContainerLogs(testutil.GetContext(c), name, cfg) |
|
| 176 |
- assert.NilError(c, err) |
|
| 174 |
+ extractBody := func(t *testing.T, cfg container.LogsOptions) []string {
|
|
| 175 |
+ reader, err := apiClient.ContainerLogs(testutil.GetContext(t), name, cfg) |
|
| 176 |
+ assert.NilError(t, err) |
|
| 177 | 177 |
|
| 178 | 178 |
actualStdout := new(bytes.Buffer) |
| 179 | 179 |
actualStderr := io.Discard |
| 180 | 180 |
_, err = stdcopy.StdCopy(actualStdout, actualStderr, reader) |
| 181 |
- assert.NilError(c, err) |
|
| 181 |
+ assert.NilError(t, err) |
|
| 182 | 182 |
|
| 183 | 183 |
return strings.Split(actualStdout.String(), "\n") |
| 184 | 184 |
} |
| ... | ... |
@@ -208,14 +208,14 @@ func (s *DockerAPISuite) TestLogsAPIUntilDefaultValue(c *testing.T) {
|
| 208 | 208 |
c.Fatal(err) |
| 209 | 209 |
} |
| 210 | 210 |
|
| 211 |
- extractBody := func(c *testing.T, cfg container.LogsOptions) []string {
|
|
| 212 |
- reader, err := apiClient.ContainerLogs(testutil.GetContext(c), name, cfg) |
|
| 213 |
- assert.NilError(c, err) |
|
| 211 |
+ extractBody := func(t *testing.T, cfg container.LogsOptions) []string {
|
|
| 212 |
+ reader, err := apiClient.ContainerLogs(testutil.GetContext(t), name, cfg) |
|
| 213 |
+ assert.NilError(t, err) |
|
| 214 | 214 |
|
| 215 | 215 |
actualStdout := new(bytes.Buffer) |
| 216 | 216 |
actualStderr := io.Discard |
| 217 | 217 |
_, err = stdcopy.StdCopy(actualStdout, actualStderr, reader) |
| 218 |
- assert.NilError(c, err) |
|
| 218 |
+ assert.NilError(t, err) |
|
| 219 | 219 |
|
| 220 | 220 |
return strings.Split(actualStdout.String(), "\n") |
| 221 | 221 |
} |
| ... | ... |
@@ -203,23 +203,23 @@ func (s *DockerAPISuite) TestAPICreateDeletePredefinedNetworks(c *testing.T) {
|
| 203 | 203 |
createDeletePredefinedNetwork(c, "host") |
| 204 | 204 |
} |
| 205 | 205 |
|
| 206 |
-func createDeletePredefinedNetwork(c *testing.T, name string) {
|
|
| 206 |
+func createDeletePredefinedNetwork(t *testing.T, name string) {
|
|
| 207 | 207 |
// Create pre-defined network |
| 208 | 208 |
config := network.CreateRequest{Name: name}
|
| 209 | 209 |
expectedStatus := http.StatusForbidden |
| 210 |
- createNetwork(c, config, expectedStatus) |
|
| 211 |
- deleteNetwork(c, name, false) |
|
| 210 |
+ createNetwork(t, config, expectedStatus) |
|
| 211 |
+ deleteNetwork(t, name, false) |
|
| 212 | 212 |
} |
| 213 | 213 |
|
| 214 |
-func isNetworkAvailable(c *testing.T, name string) bool {
|
|
| 215 |
- resp, body, err := request.Get(testutil.GetContext(c), "/networks") |
|
| 216 |
- assert.NilError(c, err) |
|
| 214 |
+func isNetworkAvailable(t *testing.T, name string) bool {
|
|
| 215 |
+ resp, body, err := request.Get(testutil.GetContext(t), "/networks") |
|
| 216 |
+ assert.NilError(t, err) |
|
| 217 | 217 |
defer resp.Body.Close() |
| 218 |
- assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 218 |
+ assert.Equal(t, resp.StatusCode, http.StatusOK) |
|
| 219 | 219 |
|
| 220 | 220 |
var nJSON []network.Inspect |
| 221 | 221 |
err = json.NewDecoder(body).Decode(&nJSON) |
| 222 |
- assert.NilError(c, err) |
|
| 222 |
+ assert.NilError(t, err) |
|
| 223 | 223 |
|
| 224 | 224 |
for _, n := range nJSON {
|
| 225 | 225 |
if n.Name == name {
|
| ... | ... |
@@ -229,19 +229,19 @@ func isNetworkAvailable(c *testing.T, name string) bool {
|
| 229 | 229 |
return false |
| 230 | 230 |
} |
| 231 | 231 |
|
| 232 |
-func getNetworkIDByName(c *testing.T, name string) string {
|
|
| 232 |
+func getNetworkIDByName(t *testing.T, name string) string {
|
|
| 233 | 233 |
filterJSON, err := filters.ToJSON(filters.NewArgs(filters.Arg("name", name)))
|
| 234 |
- assert.NilError(c, err) |
|
| 234 |
+ assert.NilError(t, err) |
|
| 235 | 235 |
v := url.Values{}
|
| 236 | 236 |
v.Set("filters", filterJSON)
|
| 237 | 237 |
|
| 238 |
- resp, body, err := request.Get(testutil.GetContext(c), "/networks?"+v.Encode()) |
|
| 239 |
- assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 240 |
- assert.NilError(c, err) |
|
| 238 |
+ resp, body, err := request.Get(testutil.GetContext(t), "/networks?"+v.Encode()) |
|
| 239 |
+ assert.Equal(t, resp.StatusCode, http.StatusOK) |
|
| 240 |
+ assert.NilError(t, err) |
|
| 241 | 241 |
|
| 242 | 242 |
var nJSON []network.Inspect |
| 243 | 243 |
err = json.NewDecoder(body).Decode(&nJSON) |
| 244 |
- assert.NilError(c, err) |
|
| 244 |
+ assert.NilError(t, err) |
|
| 245 | 245 |
var res string |
| 246 | 246 |
for _, n := range nJSON {
|
| 247 | 247 |
// Find exact match |
| ... | ... |
@@ -249,70 +249,70 @@ func getNetworkIDByName(c *testing.T, name string) string {
|
| 249 | 249 |
res = n.ID |
| 250 | 250 |
} |
| 251 | 251 |
} |
| 252 |
- assert.Assert(c, res != "") |
|
| 252 |
+ assert.Assert(t, res != "") |
|
| 253 | 253 |
|
| 254 | 254 |
return res |
| 255 | 255 |
} |
| 256 | 256 |
|
| 257 |
-func getNetworkResource(c *testing.T, id string) *network.Inspect {
|
|
| 258 |
- _, obj, err := request.Get(testutil.GetContext(c), "/networks/"+id) |
|
| 259 |
- assert.NilError(c, err) |
|
| 257 |
+func getNetworkResource(t *testing.T, id string) *network.Inspect {
|
|
| 258 |
+ _, obj, err := request.Get(testutil.GetContext(t), "/networks/"+id) |
|
| 259 |
+ assert.NilError(t, err) |
|
| 260 | 260 |
|
| 261 | 261 |
nr := network.Inspect{}
|
| 262 | 262 |
err = json.NewDecoder(obj).Decode(&nr) |
| 263 |
- assert.NilError(c, err) |
|
| 263 |
+ assert.NilError(t, err) |
|
| 264 | 264 |
|
| 265 | 265 |
return &nr |
| 266 | 266 |
} |
| 267 | 267 |
|
| 268 |
-func createNetwork(c *testing.T, config network.CreateRequest, expectedStatusCode int) string {
|
|
| 269 |
- c.Helper() |
|
| 268 |
+func createNetwork(t *testing.T, config network.CreateRequest, expectedStatusCode int) string {
|
|
| 269 |
+ t.Helper() |
|
| 270 | 270 |
|
| 271 |
- resp, body, err := request.Post(testutil.GetContext(c), "/networks/create", request.JSONBody(config)) |
|
| 272 |
- assert.NilError(c, err) |
|
| 271 |
+ resp, body, err := request.Post(testutil.GetContext(t), "/networks/create", request.JSONBody(config)) |
|
| 272 |
+ assert.NilError(t, err) |
|
| 273 | 273 |
defer resp.Body.Close() |
| 274 | 274 |
|
| 275 | 275 |
if expectedStatusCode >= 0 {
|
| 276 |
- assert.Equal(c, resp.StatusCode, expectedStatusCode) |
|
| 276 |
+ assert.Equal(t, resp.StatusCode, expectedStatusCode) |
|
| 277 | 277 |
} else {
|
| 278 |
- assert.Assert(c, resp.StatusCode != -expectedStatusCode) |
|
| 278 |
+ assert.Assert(t, resp.StatusCode != -expectedStatusCode) |
|
| 279 | 279 |
} |
| 280 | 280 |
|
| 281 | 281 |
if expectedStatusCode == http.StatusCreated || expectedStatusCode < 0 {
|
| 282 | 282 |
var nr network.CreateResponse |
| 283 | 283 |
err = json.NewDecoder(body).Decode(&nr) |
| 284 |
- assert.NilError(c, err) |
|
| 284 |
+ assert.NilError(t, err) |
|
| 285 | 285 |
|
| 286 | 286 |
return nr.ID |
| 287 | 287 |
} |
| 288 | 288 |
return "" |
| 289 | 289 |
} |
| 290 | 290 |
|
| 291 |
-func connectNetwork(c *testing.T, nid, cid string) {
|
|
| 292 |
- resp, _, err := request.Post(testutil.GetContext(c), "/networks/"+nid+"/connect", request.JSONBody(network.ConnectOptions{
|
|
| 291 |
+func connectNetwork(t *testing.T, nid, cid string) {
|
|
| 292 |
+ resp, _, err := request.Post(testutil.GetContext(t), "/networks/"+nid+"/connect", request.JSONBody(network.ConnectOptions{
|
|
| 293 | 293 |
Container: cid, |
| 294 | 294 |
})) |
| 295 |
- assert.NilError(c, err) |
|
| 296 |
- assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 295 |
+ assert.NilError(t, err) |
|
| 296 |
+ assert.Equal(t, resp.StatusCode, http.StatusOK) |
|
| 297 | 297 |
} |
| 298 | 298 |
|
| 299 |
-func disconnectNetwork(c *testing.T, nid, cid string) {
|
|
| 299 |
+func disconnectNetwork(t *testing.T, nid, cid string) {
|
|
| 300 | 300 |
config := network.ConnectOptions{
|
| 301 | 301 |
Container: cid, |
| 302 | 302 |
} |
| 303 | 303 |
|
| 304 |
- resp, _, err := request.Post(testutil.GetContext(c), "/networks/"+nid+"/disconnect", request.JSONBody(config)) |
|
| 305 |
- assert.NilError(c, err) |
|
| 306 |
- assert.Equal(c, resp.StatusCode, http.StatusOK) |
|
| 304 |
+ resp, _, err := request.Post(testutil.GetContext(t), "/networks/"+nid+"/disconnect", request.JSONBody(config)) |
|
| 305 |
+ assert.NilError(t, err) |
|
| 306 |
+ assert.Equal(t, resp.StatusCode, http.StatusOK) |
|
| 307 | 307 |
} |
| 308 | 308 |
|
| 309 |
-func deleteNetwork(c *testing.T, id string, shouldSucceed bool) {
|
|
| 310 |
- resp, _, err := request.Delete(testutil.GetContext(c), "/networks/"+id) |
|
| 311 |
- assert.NilError(c, err) |
|
| 309 |
+func deleteNetwork(t *testing.T, id string, shouldSucceed bool) {
|
|
| 310 |
+ resp, _, err := request.Delete(testutil.GetContext(t), "/networks/"+id) |
|
| 311 |
+ assert.NilError(t, err) |
|
| 312 | 312 |
defer resp.Body.Close() |
| 313 | 313 |
if !shouldSucceed {
|
| 314 |
- assert.Assert(c, resp.StatusCode != http.StatusOK) |
|
| 314 |
+ assert.Assert(t, resp.StatusCode != http.StatusOK) |
|
| 315 | 315 |
return |
| 316 | 316 |
} |
| 317 |
- assert.Equal(c, resp.StatusCode, http.StatusNoContent) |
|
| 317 |
+ assert.Equal(t, resp.StatusCode, http.StatusNoContent) |
|
| 318 | 318 |
} |
| ... | ... |
@@ -174,14 +174,14 @@ func (s *DockerAPISuite) TestAPIStatsNetworkStatsVersioning(c *testing.T) {
|
| 174 | 174 |
assert.Assert(c, jsonBlobHasGTE121NetworkStats(statsJSONBlob), "Stats JSON blob from API does not look like a >=v1.21 API stats structure", statsJSONBlob) |
| 175 | 175 |
} |
| 176 | 176 |
|
| 177 |
-func getNetworkStats(c *testing.T, id string) map[string]container.NetworkStats {
|
|
| 177 |
+func getNetworkStats(t *testing.T, id string) map[string]container.NetworkStats {
|
|
| 178 | 178 |
var st *container.StatsResponse |
| 179 | 179 |
|
| 180 |
- _, body, err := request.Get(testutil.GetContext(c), "/containers/"+id+"/stats?stream=false") |
|
| 181 |
- assert.NilError(c, err) |
|
| 180 |
+ _, body, err := request.Get(testutil.GetContext(t), "/containers/"+id+"/stats?stream=false") |
|
| 181 |
+ assert.NilError(t, err) |
|
| 182 | 182 |
|
| 183 | 183 |
err = json.NewDecoder(body).Decode(&st) |
| 184 |
- assert.NilError(c, err) |
|
| 184 |
+ assert.NilError(t, err) |
|
| 185 | 185 |
body.Close() |
| 186 | 186 |
|
| 187 | 187 |
return st.Networks |
| ... | ... |
@@ -191,16 +191,16 @@ func getNetworkStats(c *testing.T, id string) map[string]container.NetworkStats |
| 191 | 191 |
// container with id using an API call with version apiVersion. Since the |
| 192 | 192 |
// stats result type differs between API versions, we simply return |
| 193 | 193 |
// map[string]interface{}.
|
| 194 |
-func getStats(c *testing.T, id string) map[string]interface{} {
|
|
| 195 |
- c.Helper() |
|
| 194 |
+func getStats(t *testing.T, id string) map[string]interface{} {
|
|
| 195 |
+ t.Helper() |
|
| 196 | 196 |
stats := make(map[string]interface{})
|
| 197 | 197 |
|
| 198 |
- _, body, err := request.Get(testutil.GetContext(c), "/containers/"+id+"/stats?stream=false") |
|
| 199 |
- assert.NilError(c, err) |
|
| 198 |
+ _, body, err := request.Get(testutil.GetContext(t), "/containers/"+id+"/stats?stream=false") |
|
| 199 |
+ assert.NilError(t, err) |
|
| 200 | 200 |
defer body.Close() |
| 201 | 201 |
|
| 202 | 202 |
err = json.NewDecoder(body).Decode(&stats) |
| 203 |
- assert.NilError(c, err, "failed to decode stat: %s", err) |
|
| 203 |
+ assert.NilError(t, err, "failed to decode stat: %s", err) |
|
| 204 | 204 |
|
| 205 | 205 |
return stats |
| 206 | 206 |
} |
| ... | ... |
@@ -224,8 +224,8 @@ func (s *DockerSwarmSuite) TestAPISwarmServicesUpdateStartFirst(c *testing.T) {
|
| 224 | 224 |
|
| 225 | 225 |
checkStartingTasks := func(expected int) []swarm.Task {
|
| 226 | 226 |
var startingTasks []swarm.Task |
| 227 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 228 |
- tasks := d.GetServiceTasks(ctx, c, id) |
|
| 227 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 228 |
+ tasks := d.GetServiceTasks(ctx, t, id) |
|
| 229 | 229 |
startingTasks = nil |
| 230 | 230 |
for _, t := range tasks {
|
| 231 | 231 |
if t.Status.State == swarm.TaskStateStarting {
|
| ... | ... |
@@ -228,7 +228,7 @@ func (s *DockerSwarmSuite) TestAPISwarmPromoteDemote(c *testing.T) {
|
| 228 | 228 |
// back to manager quickly might cause the node to pause for awhile |
| 229 | 229 |
// while waiting for the role to change to worker, and the test can |
| 230 | 230 |
// time out during this interval. |
| 231 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 231 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 232 | 232 |
certBytes, err := os.ReadFile(filepath.Join(d2.Folder, "root", "swarm", "certificates", "swarm-node.crt")) |
| 233 | 233 |
if err != nil {
|
| 234 | 234 |
return "", fmt.Sprintf("error: %v", err)
|
| ... | ... |
@@ -324,12 +324,12 @@ func (s *DockerSwarmSuite) TestAPISwarmLeaderElection(c *testing.T) {
|
| 324 | 324 |
) |
| 325 | 325 |
var lastErr error |
| 326 | 326 |
checkLeader := func(nodes ...*daemon.Daemon) checkF {
|
| 327 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 327 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 328 | 328 |
// clear these out before each run |
| 329 | 329 |
leader = nil |
| 330 | 330 |
followers = nil |
| 331 | 331 |
for _, d := range nodes {
|
| 332 |
- n := d.GetNode(ctx, c, d.NodeID(), func(err error) bool {
|
|
| 332 |
+ n := d.GetNode(ctx, t, d.NodeID(), func(err error) bool {
|
|
| 333 | 333 |
if strings.Contains(err.Error(), context.DeadlineExceeded.Error()) || strings.Contains(err.Error(), "swarm does not have a leader") {
|
| 334 | 334 |
lastErr = err |
| 335 | 335 |
return true |
| ... | ... |
@@ -412,8 +412,8 @@ func (s *DockerSwarmSuite) TestAPISwarmRaftQuorum(c *testing.T) {
|
| 412 | 412 |
defer cli.Close() |
| 413 | 413 |
|
| 414 | 414 |
// d1 will eventually step down from leader because there is no longer an active quorum, wait for that to happen |
| 415 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 416 |
- _, err := cli.ServiceCreate(testutil.GetContext(c), service.Spec, swarm.ServiceCreateOptions{})
|
|
| 415 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 416 |
+ _, err := cli.ServiceCreate(testutil.GetContext(t), service.Spec, swarm.ServiceCreateOptions{})
|
|
| 417 | 417 |
return err.Error(), "" |
| 418 | 418 |
}, checker.Contains("Make sure more than half of the managers are online.")), poll.WithTimeout(defaultReconciliationTimeout*2))
|
| 419 | 419 |
|
| ... | ... |
@@ -745,21 +745,21 @@ func setGlobalMode(s *swarm.Service) {
|
| 745 | 745 |
} |
| 746 | 746 |
} |
| 747 | 747 |
|
| 748 |
-func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerCount int) {
|
|
| 748 |
+func checkClusterHealth(t *testing.T, cl []*daemon.Daemon, managerCount, workerCount int) {
|
|
| 749 | 749 |
var totalMCount, totalWCount int |
| 750 | 750 |
|
| 751 |
- ctx := testutil.GetContext(c) |
|
| 751 |
+ ctx := testutil.GetContext(t) |
|
| 752 | 752 |
for _, d := range cl {
|
| 753 | 753 |
var info swarm.Info |
| 754 | 754 |
|
| 755 | 755 |
// check info in a poll.WaitOn(), because if the cluster doesn't have a leader, `info` will return an error |
| 756 |
- checkInfo := func(c *testing.T) (interface{}, string) {
|
|
| 757 |
- client := d.NewClientT(c) |
|
| 756 |
+ checkInfo := func(t *testing.T) (interface{}, string) {
|
|
| 757 |
+ client := d.NewClientT(t) |
|
| 758 | 758 |
daemonInfo, err := client.Info(ctx) |
| 759 | 759 |
info = daemonInfo.Swarm |
| 760 | 760 |
return err, "cluster not ready in time" |
| 761 | 761 |
} |
| 762 |
- poll.WaitOn(c, pollCheck(c, checkInfo, checker.IsNil()), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 762 |
+ poll.WaitOn(t, pollCheck(t, checkInfo, checker.IsNil()), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 763 | 763 |
if !info.ControlAvailable {
|
| 764 | 764 |
totalWCount++ |
| 765 | 765 |
continue |
| ... | ... |
@@ -769,44 +769,44 @@ func checkClusterHealth(c *testing.T, cl []*daemon.Daemon, managerCount, workerC |
| 769 | 769 |
totalMCount++ |
| 770 | 770 |
var mCount, wCount int |
| 771 | 771 |
|
| 772 |
- for _, n := range d.ListNodes(ctx, c) {
|
|
| 773 |
- waitReady := func(c *testing.T) (interface{}, string) {
|
|
| 772 |
+ for _, n := range d.ListNodes(ctx, t) {
|
|
| 773 |
+ waitReady := func(t *testing.T) (interface{}, string) {
|
|
| 774 | 774 |
if n.Status.State == swarm.NodeStateReady {
|
| 775 | 775 |
return true, "" |
| 776 | 776 |
} |
| 777 |
- nn := d.GetNode(ctx, c, n.ID) |
|
| 777 |
+ nn := d.GetNode(ctx, t, n.ID) |
|
| 778 | 778 |
n = *nn |
| 779 | 779 |
return n.Status.State == swarm.NodeStateReady, fmt.Sprintf("state of node %s, reported by %s", n.ID, d.NodeID())
|
| 780 | 780 |
} |
| 781 |
- poll.WaitOn(c, pollCheck(c, waitReady, checker.True()), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 781 |
+ poll.WaitOn(t, pollCheck(t, waitReady, checker.True()), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 782 | 782 |
|
| 783 |
- waitActive := func(c *testing.T) (interface{}, string) {
|
|
| 783 |
+ waitActive := func(t *testing.T) (interface{}, string) {
|
|
| 784 | 784 |
if n.Spec.Availability == swarm.NodeAvailabilityActive {
|
| 785 | 785 |
return true, "" |
| 786 | 786 |
} |
| 787 |
- nn := d.GetNode(ctx, c, n.ID) |
|
| 787 |
+ nn := d.GetNode(ctx, t, n.ID) |
|
| 788 | 788 |
n = *nn |
| 789 | 789 |
return n.Spec.Availability == swarm.NodeAvailabilityActive, fmt.Sprintf("availability of node %s, reported by %s", n.ID, d.NodeID())
|
| 790 | 790 |
} |
| 791 |
- poll.WaitOn(c, pollCheck(c, waitActive, checker.True()), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 791 |
+ poll.WaitOn(t, pollCheck(t, waitActive, checker.True()), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 792 | 792 |
|
| 793 | 793 |
if n.Spec.Role == swarm.NodeRoleManager {
|
| 794 |
- assert.Assert(c, n.ManagerStatus != nil, "manager status of node %s (manager), reported by %s", n.ID, d.NodeID()) |
|
| 794 |
+ assert.Assert(t, n.ManagerStatus != nil, "manager status of node %s (manager), reported by %s", n.ID, d.NodeID()) |
|
| 795 | 795 |
if n.ManagerStatus.Leader {
|
| 796 | 796 |
leaderFound = true |
| 797 | 797 |
} |
| 798 | 798 |
mCount++ |
| 799 | 799 |
} else {
|
| 800 |
- assert.Assert(c, n.ManagerStatus == nil, "manager status of node %s (worker), reported by %s", n.ID, d.NodeID()) |
|
| 800 |
+ assert.Assert(t, n.ManagerStatus == nil, "manager status of node %s (worker), reported by %s", n.ID, d.NodeID()) |
|
| 801 | 801 |
wCount++ |
| 802 | 802 |
} |
| 803 | 803 |
} |
| 804 |
- assert.Equal(c, leaderFound, true, "lack of leader reported by node %s", info.NodeID) |
|
| 805 |
- assert.Equal(c, mCount, managerCount, "managers count reported by node %s", info.NodeID) |
|
| 806 |
- assert.Equal(c, wCount, workerCount, "workers count reported by node %s", info.NodeID) |
|
| 804 |
+ assert.Equal(t, leaderFound, true, "lack of leader reported by node %s", info.NodeID) |
|
| 805 |
+ assert.Equal(t, mCount, managerCount, "managers count reported by node %s", info.NodeID) |
|
| 806 |
+ assert.Equal(t, wCount, workerCount, "workers count reported by node %s", info.NodeID) |
|
| 807 | 807 |
} |
| 808 |
- assert.Equal(c, totalMCount, managerCount) |
|
| 809 |
- assert.Equal(c, totalWCount, workerCount) |
|
| 808 |
+ assert.Equal(t, totalMCount, managerCount) |
|
| 809 |
+ assert.Equal(t, totalWCount, workerCount) |
|
| 810 | 810 |
} |
| 811 | 811 |
|
| 812 | 812 |
func (s *DockerSwarmSuite) TestAPISwarmRestartCluster(c *testing.T) {
|
| ... | ... |
@@ -22,12 +22,12 @@ type DockerAPISuite struct {
|
| 22 | 22 |
ds *DockerSuite |
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
-func (s *DockerAPISuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 26 |
- s.ds.TearDownTest(ctx, c) |
|
| 25 |
+func (s *DockerAPISuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 26 |
+ s.ds.TearDownTest(ctx, t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
-func (s *DockerAPISuite) OnTimeout(c *testing.T) {
|
|
| 30 |
- s.ds.OnTimeout(c) |
|
| 29 |
+func (s *DockerAPISuite) OnTimeout(t *testing.T) {
|
|
| 30 |
+ s.ds.OnTimeout(t) |
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
func (s *DockerAPISuite) TestAPIOptionsRoute(c *testing.T) {
|
| ... | ... |
@@ -23,12 +23,12 @@ type DockerCLIAttachSuite struct {
|
| 23 | 23 |
ds *DockerSuite |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-func (s *DockerCLIAttachSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 27 |
- s.ds.TearDownTest(ctx, c) |
|
| 26 |
+func (s *DockerCLIAttachSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 27 |
+ s.ds.TearDownTest(ctx, t) |
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-func (s *DockerCLIAttachSuite) OnTimeout(c *testing.T) {
|
|
| 31 |
- s.ds.OnTimeout(c) |
|
| 30 |
+func (s *DockerCLIAttachSuite) OnTimeout(t *testing.T) {
|
|
| 31 |
+ s.ds.OnTimeout(t) |
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 | 34 |
func (s *DockerCLIAttachSuite) TestAttachMultipleAndRestart(c *testing.T) {
|
| ... | ... |
@@ -38,12 +38,12 @@ type DockerCLIBuildSuite struct {
|
| 38 | 38 |
ds *DockerSuite |
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 |
-func (s *DockerCLIBuildSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 42 |
- s.ds.TearDownTest(ctx, c) |
|
| 41 |
+func (s *DockerCLIBuildSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 42 |
+ s.ds.TearDownTest(ctx, t) |
|
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 |
-func (s *DockerCLIBuildSuite) OnTimeout(c *testing.T) {
|
|
| 46 |
- s.ds.OnTimeout(c) |
|
| 45 |
+func (s *DockerCLIBuildSuite) OnTimeout(t *testing.T) {
|
|
| 46 |
+ s.ds.OnTimeout(t) |
|
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 | 49 |
func (s *DockerCLIBuildSuite) TestBuildJSONEmptyRun(c *testing.T) {
|
| ... | ... |
@@ -2009,8 +2009,8 @@ func (s *DockerCLIBuildSuite) TestBuildAddLocalAndRemoteFilesWithAndWithoutCache |
| 2009 | 2009 |
} |
| 2010 | 2010 |
} |
| 2011 | 2011 |
|
| 2012 |
-func testContextTar(c *testing.T, comp compression.Compression) {
|
|
| 2013 |
- ctx := fakecontext.New(c, "", |
|
| 2012 |
+func testContextTar(t *testing.T, comp compression.Compression) {
|
|
| 2013 |
+ ctx := fakecontext.New(t, "", |
|
| 2014 | 2014 |
fakecontext.WithDockerfile(`FROM busybox |
| 2015 | 2015 |
ADD foo /foo |
| 2016 | 2016 |
CMD ["cat", "/foo"]`), |
| ... | ... |
@@ -2021,11 +2021,11 @@ CMD ["cat", "/foo"]`), |
| 2021 | 2021 |
defer ctx.Close() |
| 2022 | 2022 |
buildContext, err := archive.Tar(ctx.Dir, comp) |
| 2023 | 2023 |
if err != nil {
|
| 2024 |
- c.Fatalf("failed to build context tar: %v", err)
|
|
| 2024 |
+ t.Fatalf("failed to build context tar: %v", err)
|
|
| 2025 | 2025 |
} |
| 2026 | 2026 |
const name = "contexttar" |
| 2027 | 2027 |
|
| 2028 |
- cli.BuildCmd(c, name, build.WithStdinContext(buildContext)) |
|
| 2028 |
+ cli.BuildCmd(t, name, build.WithStdinContext(buildContext)) |
|
| 2029 | 2029 |
} |
| 2030 | 2030 |
|
| 2031 | 2031 |
func (s *DockerCLIBuildSuite) TestBuildContextTarGzip(c *testing.T) {
|
| ... | ... |
@@ -2093,15 +2093,15 @@ func (s *DockerCLIBuildSuite) TestBuildDockerfileStdinDockerignoreIgnored(c *tes |
| 2093 | 2093 |
s.testBuildDockerfileStdinNoExtraFiles(c, true, true) |
| 2094 | 2094 |
} |
| 2095 | 2095 |
|
| 2096 |
-func (s *DockerCLIBuildSuite) testBuildDockerfileStdinNoExtraFiles(c *testing.T, hasDockerignore, ignoreDockerignore bool) {
|
|
| 2096 |
+func (s *DockerCLIBuildSuite) testBuildDockerfileStdinNoExtraFiles(t *testing.T, hasDockerignore, ignoreDockerignore bool) {
|
|
| 2097 | 2097 |
const name = "stdindockerfilenoextra" |
| 2098 | 2098 |
tmpDir, err := os.MkdirTemp("", "fake-context")
|
| 2099 |
- assert.NilError(c, err) |
|
| 2099 |
+ assert.NilError(t, err) |
|
| 2100 | 2100 |
defer os.RemoveAll(tmpDir) |
| 2101 | 2101 |
|
| 2102 | 2102 |
writeFile := func(filename, content string) {
|
| 2103 | 2103 |
err = os.WriteFile(filepath.Join(tmpDir, filename), []byte(content), 0o600) |
| 2104 |
- assert.NilError(c, err) |
|
| 2104 |
+ assert.NilError(t, err) |
|
| 2105 | 2105 |
} |
| 2106 | 2106 |
|
| 2107 | 2107 |
writeFile("foo", "bar")
|
| ... | ... |
@@ -2123,13 +2123,13 @@ func (s *DockerCLIBuildSuite) testBuildDockerfileStdinNoExtraFiles(c *testing.T, |
| 2123 | 2123 |
`FROM busybox |
| 2124 | 2124 |
COPY . /baz`), |
| 2125 | 2125 |
}) |
| 2126 |
- result.Assert(c, icmd.Success) |
|
| 2126 |
+ result.Assert(t, icmd.Success) |
|
| 2127 | 2127 |
|
| 2128 |
- result = cli.DockerCmd(c, "run", "--rm", name, "ls", "-A", "/baz") |
|
| 2128 |
+ result = cli.DockerCmd(t, "run", "--rm", name, "ls", "-A", "/baz") |
|
| 2129 | 2129 |
if hasDockerignore && !ignoreDockerignore {
|
| 2130 |
- assert.Equal(c, result.Stdout(), ".dockerignore\nfoo\n") |
|
| 2130 |
+ assert.Equal(t, result.Stdout(), ".dockerignore\nfoo\n") |
|
| 2131 | 2131 |
} else {
|
| 2132 |
- assert.Equal(c, result.Stdout(), "foo\n") |
|
| 2132 |
+ assert.Equal(t, result.Stdout(), "foo\n") |
|
| 2133 | 2133 |
} |
| 2134 | 2134 |
} |
| 2135 | 2135 |
|
| ... | ... |
@@ -30,510 +30,510 @@ var ( |
| 30 | 30 |
digestRegex = lazyregexp.New(`Digest: ([\S]+)`) |
| 31 | 31 |
) |
| 32 | 32 |
|
| 33 |
-func setupImage(c *testing.T) (digest.Digest, error) {
|
|
| 34 |
- return setupImageWithTag(c, "latest") |
|
| 33 |
+func setupImage(t *testing.T) (digest.Digest, error) {
|
|
| 34 |
+ return setupImageWithTag(t, "latest") |
|
| 35 | 35 |
} |
| 36 | 36 |
|
| 37 |
-func setupImageWithTag(c *testing.T, tag string) (digest.Digest, error) {
|
|
| 37 |
+func setupImageWithTag(t *testing.T, tag string) (digest.Digest, error) {
|
|
| 38 | 38 |
const containerName = "busyboxbydigest" |
| 39 | 39 |
|
| 40 | 40 |
// new file is committed because this layer is used for detecting malicious |
| 41 | 41 |
// changes. if this was committed as empty layer it would be skipped on pull |
| 42 | 42 |
// and malicious changes would never be detected. |
| 43 |
- cli.DockerCmd(c, "run", "-e", "digest=1", "--name", containerName, "busybox", "touch", "anewfile") |
|
| 43 |
+ cli.DockerCmd(t, "run", "-e", "digest=1", "--name", containerName, "busybox", "touch", "anewfile") |
|
| 44 | 44 |
|
| 45 | 45 |
// tag the image to upload it to the private registry |
| 46 | 46 |
repoAndTag := repoName + ":" + tag |
| 47 |
- cli.DockerCmd(c, "commit", containerName, repoAndTag) |
|
| 47 |
+ cli.DockerCmd(t, "commit", containerName, repoAndTag) |
|
| 48 | 48 |
|
| 49 | 49 |
// delete the container as we don't need it any more |
| 50 |
- cli.DockerCmd(c, "rm", "-fv", containerName) |
|
| 50 |
+ cli.DockerCmd(t, "rm", "-fv", containerName) |
|
| 51 | 51 |
|
| 52 | 52 |
// push the image |
| 53 |
- out := cli.DockerCmd(c, "push", repoAndTag).Combined() |
|
| 53 |
+ out := cli.DockerCmd(t, "push", repoAndTag).Combined() |
|
| 54 | 54 |
|
| 55 | 55 |
// delete our local repo that we previously tagged |
| 56 |
- cli.DockerCmd(c, "rmi", repoAndTag) |
|
| 56 |
+ cli.DockerCmd(t, "rmi", repoAndTag) |
|
| 57 | 57 |
|
| 58 | 58 |
matches := pushDigestRegex.FindStringSubmatch(out) |
| 59 |
- assert.Equal(c, len(matches), 2, "unable to parse digest from push output: %s", out) |
|
| 59 |
+ assert.Equal(t, len(matches), 2, "unable to parse digest from push output: %s", out) |
|
| 60 | 60 |
pushDigest := matches[1] |
| 61 | 61 |
|
| 62 | 62 |
return digest.Digest(pushDigest), nil |
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
-func (s *DockerRegistrySuite) TestPullByTagDisplaysDigest(c *testing.T) {
|
|
| 66 |
- testRequires(c, DaemonIsLinux) |
|
| 67 |
- pushDigest, err := setupImage(c) |
|
| 68 |
- assert.NilError(c, err, "error setting up image") |
|
| 65 |
+func (s *DockerRegistrySuite) TestPullByTagDisplaysDigest(t *testing.T) {
|
|
| 66 |
+ testRequires(t, DaemonIsLinux) |
|
| 67 |
+ pushDigest, err := setupImage(t) |
|
| 68 |
+ assert.NilError(t, err, "error setting up image") |
|
| 69 | 69 |
|
| 70 | 70 |
// pull from the registry using the tag |
| 71 |
- out := cli.DockerCmd(c, "pull", repoName).Combined() |
|
| 71 |
+ out := cli.DockerCmd(t, "pull", repoName).Combined() |
|
| 72 | 72 |
|
| 73 | 73 |
// the pull output includes "Digest: <digest>", so find that |
| 74 | 74 |
matches := digestRegex.FindStringSubmatch(out) |
| 75 |
- assert.Equal(c, len(matches), 2, "unable to parse digest from push output: %s", out) |
|
| 75 |
+ assert.Equal(t, len(matches), 2, "unable to parse digest from push output: %s", out) |
|
| 76 | 76 |
pullDigest := matches[1] |
| 77 | 77 |
|
| 78 | 78 |
// make sure the pushed and pull digests match |
| 79 |
- assert.Equal(c, pushDigest.String(), pullDigest) |
|
| 79 |
+ assert.Equal(t, pushDigest.String(), pullDigest) |
|
| 80 | 80 |
} |
| 81 | 81 |
|
| 82 |
-func (s *DockerRegistrySuite) TestPullByDigest(c *testing.T) {
|
|
| 83 |
- testRequires(c, DaemonIsLinux) |
|
| 84 |
- pushDigest, err := setupImage(c) |
|
| 85 |
- assert.NilError(c, err, "error setting up image") |
|
| 82 |
+func (s *DockerRegistrySuite) TestPullByDigest(t *testing.T) {
|
|
| 83 |
+ testRequires(t, DaemonIsLinux) |
|
| 84 |
+ pushDigest, err := setupImage(t) |
|
| 85 |
+ assert.NilError(t, err, "error setting up image") |
|
| 86 | 86 |
|
| 87 | 87 |
// pull from the registry using the <name>@<digest> reference |
| 88 | 88 |
imageReference := fmt.Sprintf("%s@%s", repoName, pushDigest)
|
| 89 |
- out := cli.DockerCmd(c, "pull", imageReference).Combined() |
|
| 89 |
+ out := cli.DockerCmd(t, "pull", imageReference).Combined() |
|
| 90 | 90 |
|
| 91 | 91 |
// the pull output includes "Digest: <digest>", so find that |
| 92 | 92 |
matches := digestRegex.FindStringSubmatch(out) |
| 93 |
- assert.Equal(c, len(matches), 2, "unable to parse digest from push output: %s", out) |
|
| 93 |
+ assert.Equal(t, len(matches), 2, "unable to parse digest from push output: %s", out) |
|
| 94 | 94 |
pullDigest := matches[1] |
| 95 | 95 |
|
| 96 | 96 |
// make sure the pushed and pull digests match |
| 97 |
- assert.Equal(c, pushDigest.String(), pullDigest) |
|
| 97 |
+ assert.Equal(t, pushDigest.String(), pullDigest) |
|
| 98 | 98 |
} |
| 99 | 99 |
|
| 100 |
-func (s *DockerRegistrySuite) TestPullByDigestNoFallback(c *testing.T) {
|
|
| 101 |
- testRequires(c, DaemonIsLinux) |
|
| 100 |
+func (s *DockerRegistrySuite) TestPullByDigestNoFallback(t *testing.T) {
|
|
| 101 |
+ testRequires(t, DaemonIsLinux) |
|
| 102 | 102 |
// pull from the registry using the <name>@<digest> reference |
| 103 | 103 |
imageReference := fmt.Sprintf("%s@sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", repoName)
|
| 104 | 104 |
out, _, err := dockerCmdWithError("pull", imageReference)
|
| 105 |
- assert.Assert(c, err != nil, "expected non-zero exit status and correct error message when pulling non-existing image") |
|
| 105 |
+ assert.Assert(t, err != nil, "expected non-zero exit status and correct error message when pulling non-existing image") |
|
| 106 | 106 |
|
| 107 | 107 |
expectedMsg := fmt.Sprintf("manifest for %s not found", imageReference)
|
| 108 | 108 |
if testEnv.UsingSnapshotter() {
|
| 109 | 109 |
expectedMsg = fmt.Sprintf("%s: not found", imageReference)
|
| 110 | 110 |
} |
| 111 | 111 |
|
| 112 |
- assert.Check(c, is.Contains(out, expectedMsg), "expected non-zero exit status and correct error message when pulling non-existing image") |
|
| 112 |
+ assert.Check(t, is.Contains(out, expectedMsg), "expected non-zero exit status and correct error message when pulling non-existing image") |
|
| 113 | 113 |
} |
| 114 | 114 |
|
| 115 |
-func (s *DockerRegistrySuite) TestCreateByDigest(c *testing.T) {
|
|
| 116 |
- pushDigest, err := setupImage(c) |
|
| 117 |
- assert.NilError(c, err, "error setting up image") |
|
| 115 |
+func (s *DockerRegistrySuite) TestCreateByDigest(t *testing.T) {
|
|
| 116 |
+ pushDigest, err := setupImage(t) |
|
| 117 |
+ assert.NilError(t, err, "error setting up image") |
|
| 118 | 118 |
|
| 119 | 119 |
imageReference := fmt.Sprintf("%s@%s", repoName, pushDigest)
|
| 120 | 120 |
|
| 121 | 121 |
const containerName = "createByDigest" |
| 122 |
- cli.DockerCmd(c, "create", "--name", containerName, imageReference) |
|
| 122 |
+ cli.DockerCmd(t, "create", "--name", containerName, imageReference) |
|
| 123 | 123 |
|
| 124 |
- res := inspectField(c, containerName, "Config.Image") |
|
| 125 |
- assert.Equal(c, res, imageReference) |
|
| 124 |
+ res := inspectField(t, containerName, "Config.Image") |
|
| 125 |
+ assert.Equal(t, res, imageReference) |
|
| 126 | 126 |
} |
| 127 | 127 |
|
| 128 |
-func (s *DockerRegistrySuite) TestRunByDigest(c *testing.T) {
|
|
| 129 |
- pushDigest, err := setupImage(c) |
|
| 130 |
- assert.NilError(c, err) |
|
| 128 |
+func (s *DockerRegistrySuite) TestRunByDigest(t *testing.T) {
|
|
| 129 |
+ pushDigest, err := setupImage(t) |
|
| 130 |
+ assert.NilError(t, err) |
|
| 131 | 131 |
|
| 132 | 132 |
imageReference := fmt.Sprintf("%s@%s", repoName, pushDigest)
|
| 133 | 133 |
|
| 134 | 134 |
const containerName = "runByDigest" |
| 135 |
- out := cli.DockerCmd(c, "run", "--name", containerName, imageReference, "sh", "-c", "echo found=$digest").Combined() |
|
| 135 |
+ out := cli.DockerCmd(t, "run", "--name", containerName, imageReference, "sh", "-c", "echo found=$digest").Combined() |
|
| 136 | 136 |
|
| 137 | 137 |
foundRegex := regexp.MustCompile("found=([^\n]+)")
|
| 138 | 138 |
matches := foundRegex.FindStringSubmatch(out) |
| 139 |
- assert.Equal(c, len(matches), 2, fmt.Sprintf("unable to parse digest from pull output: %s", out))
|
|
| 140 |
- assert.Equal(c, matches[1], "1", fmt.Sprintf("Expected %q, got %q", "1", matches[1]))
|
|
| 139 |
+ assert.Equal(t, len(matches), 2, fmt.Sprintf("unable to parse digest from pull output: %s", out))
|
|
| 140 |
+ assert.Equal(t, matches[1], "1", fmt.Sprintf("Expected %q, got %q", "1", matches[1]))
|
|
| 141 | 141 |
|
| 142 |
- res := inspectField(c, containerName, "Config.Image") |
|
| 143 |
- assert.Equal(c, res, imageReference) |
|
| 142 |
+ res := inspectField(t, containerName, "Config.Image") |
|
| 143 |
+ assert.Equal(t, res, imageReference) |
|
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 |
-func (s *DockerRegistrySuite) TestRemoveImageByDigest(c *testing.T) {
|
|
| 147 |
- imgDigest, err := setupImage(c) |
|
| 148 |
- assert.NilError(c, err, "error setting up image") |
|
| 146 |
+func (s *DockerRegistrySuite) TestRemoveImageByDigest(t *testing.T) {
|
|
| 147 |
+ imgDigest, err := setupImage(t) |
|
| 148 |
+ assert.NilError(t, err, "error setting up image") |
|
| 149 | 149 |
|
| 150 | 150 |
imageReference := fmt.Sprintf("%s@%s", repoName, imgDigest)
|
| 151 | 151 |
|
| 152 | 152 |
// pull from the registry using the <name>@<digest> reference |
| 153 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 153 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 154 | 154 |
|
| 155 | 155 |
// make sure inspect runs ok |
| 156 |
- inspectField(c, imageReference, "Id") |
|
| 156 |
+ inspectField(t, imageReference, "Id") |
|
| 157 | 157 |
|
| 158 | 158 |
// do the delete |
| 159 | 159 |
err = deleteImages(imageReference) |
| 160 |
- assert.NilError(c, err, "unexpected error deleting image") |
|
| 160 |
+ assert.NilError(t, err, "unexpected error deleting image") |
|
| 161 | 161 |
|
| 162 | 162 |
// try to inspect again - it should error this time |
| 163 | 163 |
_, err = inspectFieldWithError(imageReference, "Id") |
| 164 | 164 |
// unexpected nil err trying to inspect what should be a non-existent image |
| 165 |
- assert.ErrorContains(c, err, "No such object") |
|
| 165 |
+ assert.ErrorContains(t, err, "No such object") |
|
| 166 | 166 |
} |
| 167 | 167 |
|
| 168 |
-func (s *DockerRegistrySuite) TestBuildByDigest(c *testing.T) {
|
|
| 169 |
- imgDigest, err := setupImage(c) |
|
| 170 |
- assert.NilError(c, err, "error setting up image") |
|
| 168 |
+func (s *DockerRegistrySuite) TestBuildByDigest(t *testing.T) {
|
|
| 169 |
+ imgDigest, err := setupImage(t) |
|
| 170 |
+ assert.NilError(t, err, "error setting up image") |
|
| 171 | 171 |
|
| 172 | 172 |
imageReference := fmt.Sprintf("%s@%s", repoName, imgDigest)
|
| 173 | 173 |
|
| 174 | 174 |
// pull from the registry using the <name>@<digest> reference |
| 175 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 175 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 176 | 176 |
|
| 177 | 177 |
// do the build |
| 178 | 178 |
const name = "buildbydigest" |
| 179 |
- buildImageSuccessfully(c, name, build.WithDockerfile(fmt.Sprintf( |
|
| 179 |
+ buildImageSuccessfully(t, name, build.WithDockerfile(fmt.Sprintf( |
|
| 180 | 180 |
`FROM %s |
| 181 | 181 |
CMD ["/bin/echo", "Hello World"]`, imageReference))) |
| 182 |
- assert.NilError(c, err) |
|
| 182 |
+ assert.NilError(t, err) |
|
| 183 | 183 |
|
| 184 | 184 |
// verify the build was ok |
| 185 |
- res := inspectField(c, name, "Config.Cmd") |
|
| 186 |
- assert.Equal(c, res, `[/bin/echo Hello World]`) |
|
| 185 |
+ res := inspectField(t, name, "Config.Cmd") |
|
| 186 |
+ assert.Equal(t, res, `[/bin/echo Hello World]`) |
|
| 187 | 187 |
} |
| 188 | 188 |
|
| 189 |
-func (s *DockerRegistrySuite) TestTagByDigest(c *testing.T) {
|
|
| 190 |
- imgDigest, err := setupImage(c) |
|
| 191 |
- assert.NilError(c, err, "error setting up image") |
|
| 189 |
+func (s *DockerRegistrySuite) TestTagByDigest(t *testing.T) {
|
|
| 190 |
+ imgDigest, err := setupImage(t) |
|
| 191 |
+ assert.NilError(t, err, "error setting up image") |
|
| 192 | 192 |
|
| 193 | 193 |
imageReference := fmt.Sprintf("%s@%s", repoName, imgDigest)
|
| 194 | 194 |
|
| 195 | 195 |
// pull from the registry using the <name>@<digest> reference |
| 196 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 196 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 197 | 197 |
|
| 198 | 198 |
// tag it |
| 199 | 199 |
const tag = "tagbydigest" |
| 200 |
- cli.DockerCmd(c, "tag", imageReference, tag) |
|
| 200 |
+ cli.DockerCmd(t, "tag", imageReference, tag) |
|
| 201 | 201 |
|
| 202 |
- expectedID := inspectField(c, imageReference, "Id") |
|
| 202 |
+ expectedID := inspectField(t, imageReference, "Id") |
|
| 203 | 203 |
|
| 204 |
- tagID := inspectField(c, tag, "Id") |
|
| 205 |
- assert.Equal(c, tagID, expectedID) |
|
| 204 |
+ tagID := inspectField(t, tag, "Id") |
|
| 205 |
+ assert.Equal(t, tagID, expectedID) |
|
| 206 | 206 |
} |
| 207 | 207 |
|
| 208 |
-func (s *DockerRegistrySuite) TestListImagesWithoutDigests(c *testing.T) {
|
|
| 209 |
- imgDigest, err := setupImage(c) |
|
| 210 |
- assert.NilError(c, err, "error setting up image") |
|
| 208 |
+func (s *DockerRegistrySuite) TestListImagesWithoutDigests(t *testing.T) {
|
|
| 209 |
+ imgDigest, err := setupImage(t) |
|
| 210 |
+ assert.NilError(t, err, "error setting up image") |
|
| 211 | 211 |
|
| 212 | 212 |
imageReference := fmt.Sprintf("%s@%s", repoName, imgDigest)
|
| 213 | 213 |
|
| 214 | 214 |
// pull from the registry using the <name>@<digest> reference |
| 215 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 215 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 216 | 216 |
|
| 217 |
- out := cli.DockerCmd(c, "images").Stdout() |
|
| 218 |
- assert.Assert(c, !strings.Contains(out, "DIGEST"), "list output should not have contained DIGEST header") |
|
| 217 |
+ out := cli.DockerCmd(t, "images").Stdout() |
|
| 218 |
+ assert.Assert(t, !strings.Contains(out, "DIGEST"), "list output should not have contained DIGEST header") |
|
| 219 | 219 |
} |
| 220 | 220 |
|
| 221 |
-func (s *DockerRegistrySuite) TestListImagesWithDigests(c *testing.T) {
|
|
| 221 |
+func (s *DockerRegistrySuite) TestListImagesWithDigests(t *testing.T) {
|
|
| 222 | 222 |
// setup image1 |
| 223 |
- digest1, err := setupImageWithTag(c, "tag1") |
|
| 224 |
- assert.NilError(c, err, "error setting up image") |
|
| 223 |
+ digest1, err := setupImageWithTag(t, "tag1") |
|
| 224 |
+ assert.NilError(t, err, "error setting up image") |
|
| 225 | 225 |
imageReference1 := fmt.Sprintf("%s@%s", repoName, digest1)
|
| 226 |
- c.Logf("imageReference1 = %s", imageReference1)
|
|
| 226 |
+ t.Logf("imageReference1 = %s", imageReference1)
|
|
| 227 | 227 |
|
| 228 | 228 |
// pull image1 by digest |
| 229 |
- cli.DockerCmd(c, "pull", imageReference1) |
|
| 229 |
+ cli.DockerCmd(t, "pull", imageReference1) |
|
| 230 | 230 |
|
| 231 | 231 |
// list images |
| 232 |
- out := cli.DockerCmd(c, "images", "--digests").Combined() |
|
| 232 |
+ out := cli.DockerCmd(t, "images", "--digests").Combined() |
|
| 233 | 233 |
|
| 234 | 234 |
// make sure repo shown, tag=<none>, digest = $digest1 |
| 235 | 235 |
re1 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest1.String() + `\s`) |
| 236 |
- assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
| 236 |
+ assert.Assert(t, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
| 237 | 237 |
// setup image2 |
| 238 |
- digest2, err := setupImageWithTag(c, "tag2") |
|
| 239 |
- assert.NilError(c, err, "error setting up image") |
|
| 238 |
+ digest2, err := setupImageWithTag(t, "tag2") |
|
| 239 |
+ assert.NilError(t, err, "error setting up image") |
|
| 240 | 240 |
imageReference2 := fmt.Sprintf("%s@%s", repoName, digest2)
|
| 241 |
- c.Logf("imageReference2 = %s", imageReference2)
|
|
| 241 |
+ t.Logf("imageReference2 = %s", imageReference2)
|
|
| 242 | 242 |
|
| 243 | 243 |
// pull image1 by digest |
| 244 |
- cli.DockerCmd(c, "pull", imageReference1) |
|
| 244 |
+ cli.DockerCmd(t, "pull", imageReference1) |
|
| 245 | 245 |
|
| 246 | 246 |
// pull image2 by digest |
| 247 |
- cli.DockerCmd(c, "pull", imageReference2) |
|
| 247 |
+ cli.DockerCmd(t, "pull", imageReference2) |
|
| 248 | 248 |
|
| 249 | 249 |
// list images |
| 250 |
- out = cli.DockerCmd(c, "images", "--digests").Stdout() |
|
| 250 |
+ out = cli.DockerCmd(t, "images", "--digests").Stdout() |
|
| 251 | 251 |
|
| 252 | 252 |
// make sure repo shown, tag=<none>, digest = $digest1 |
| 253 |
- assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
| 253 |
+ assert.Assert(t, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
| 254 | 254 |
|
| 255 | 255 |
// make sure repo shown, tag=<none>, digest = $digest2 |
| 256 | 256 |
re2 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest2.String() + `\s`) |
| 257 |
- assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
| 257 |
+ assert.Assert(t, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
| 258 | 258 |
|
| 259 | 259 |
// pull tag1 |
| 260 |
- cli.DockerCmd(c, "pull", repoName+":tag1") |
|
| 260 |
+ cli.DockerCmd(t, "pull", repoName+":tag1") |
|
| 261 | 261 |
|
| 262 | 262 |
// list images |
| 263 |
- out = cli.DockerCmd(c, "images", "--digests").Stdout() |
|
| 263 |
+ out = cli.DockerCmd(t, "images", "--digests").Stdout() |
|
| 264 | 264 |
|
| 265 | 265 |
// make sure image 1 has repo, tag, <none> AND repo, <none>, digest |
| 266 | 266 |
reWithDigest1 := regexp.MustCompile(`\s*` + repoName + `\s*tag1\s*` + digest1.String() + `\s`) |
| 267 |
- assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
| 267 |
+ assert.Assert(t, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
| 268 | 268 |
// make sure image 2 has repo, <none>, digest |
| 269 |
- assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
| 269 |
+ assert.Assert(t, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
| 270 | 270 |
|
| 271 | 271 |
// pull tag 2 |
| 272 |
- cli.DockerCmd(c, "pull", repoName+":tag2") |
|
| 272 |
+ cli.DockerCmd(t, "pull", repoName+":tag2") |
|
| 273 | 273 |
|
| 274 | 274 |
// list images |
| 275 |
- out = cli.DockerCmd(c, "images", "--digests").Stdout() |
|
| 275 |
+ out = cli.DockerCmd(t, "images", "--digests").Stdout() |
|
| 276 | 276 |
|
| 277 | 277 |
// make sure image 1 has repo, tag, digest |
| 278 |
- assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
| 278 |
+ assert.Assert(t, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
| 279 | 279 |
|
| 280 | 280 |
// make sure image 2 has repo, tag, digest |
| 281 | 281 |
reWithDigest2 := regexp.MustCompile(`\s*` + repoName + `\s*tag2\s*` + digest2.String() + `\s`) |
| 282 |
- assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
| 282 |
+ assert.Assert(t, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
| 283 | 283 |
|
| 284 | 284 |
// list images |
| 285 |
- out = cli.DockerCmd(c, "images", "--digests").Stdout() |
|
| 285 |
+ out = cli.DockerCmd(t, "images", "--digests").Stdout() |
|
| 286 | 286 |
|
| 287 | 287 |
// make sure image 1 has repo, tag, digest |
| 288 |
- assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
| 288 |
+ assert.Assert(t, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
| 289 | 289 |
// make sure image 2 has repo, tag, digest |
| 290 |
- assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
| 290 |
+ assert.Assert(t, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
| 291 | 291 |
// We always have a digest when using containerd to store images |
| 292 | 292 |
if !testEnv.UsingSnapshotter() {
|
| 293 | 293 |
// make sure busybox has tag, but not digest |
| 294 | 294 |
busyboxRe := regexp.MustCompile(`\s*busybox\s*latest\s*<none>\s`) |
| 295 |
- assert.Assert(c, busyboxRe.MatchString(out), "expected %q: %s", busyboxRe.String(), out) |
|
| 295 |
+ assert.Assert(t, busyboxRe.MatchString(out), "expected %q: %s", busyboxRe.String(), out) |
|
| 296 | 296 |
} |
| 297 | 297 |
} |
| 298 | 298 |
|
| 299 |
-func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(c *testing.T) {
|
|
| 299 |
+func (s *DockerRegistrySuite) TestListDanglingImagesWithDigests(t *testing.T) {
|
|
| 300 | 300 |
// See https://github.com/moby/moby/pull/46856 |
| 301 |
- skip.If(c, testEnv.UsingSnapshotter(), "dangling=true filter behaves a bit differently with c8d") |
|
| 301 |
+ skip.If(t, testEnv.UsingSnapshotter(), "dangling=true filter behaves a bit differently with c8d") |
|
| 302 | 302 |
|
| 303 | 303 |
// setup image1 |
| 304 |
- digest1, err := setupImageWithTag(c, "dangle1") |
|
| 305 |
- assert.NilError(c, err, "error setting up image") |
|
| 304 |
+ digest1, err := setupImageWithTag(t, "dangle1") |
|
| 305 |
+ assert.NilError(t, err, "error setting up image") |
|
| 306 | 306 |
imageReference1 := fmt.Sprintf("%s@%s", repoName, digest1)
|
| 307 |
- c.Logf("imageReference1 = %s", imageReference1)
|
|
| 307 |
+ t.Logf("imageReference1 = %s", imageReference1)
|
|
| 308 | 308 |
|
| 309 | 309 |
// pull image1 by digest |
| 310 |
- cli.DockerCmd(c, "pull", imageReference1) |
|
| 310 |
+ cli.DockerCmd(t, "pull", imageReference1) |
|
| 311 | 311 |
|
| 312 | 312 |
// list images |
| 313 |
- out := cli.DockerCmd(c, "images", "--digests").Stdout() |
|
| 313 |
+ out := cli.DockerCmd(t, "images", "--digests").Stdout() |
|
| 314 | 314 |
|
| 315 | 315 |
// make sure repo shown, tag=<none>, digest = $digest1 |
| 316 | 316 |
re1 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest1.String() + `\s`) |
| 317 |
- assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
| 317 |
+ assert.Assert(t, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
| 318 | 318 |
// setup image2 |
| 319 |
- digest2, err := setupImageWithTag(c, "dangle2") |
|
| 319 |
+ digest2, err := setupImageWithTag(t, "dangle2") |
|
| 320 | 320 |
// error setting up image |
| 321 |
- assert.NilError(c, err) |
|
| 321 |
+ assert.NilError(t, err) |
|
| 322 | 322 |
imageReference2 := fmt.Sprintf("%s@%s", repoName, digest2)
|
| 323 |
- c.Logf("imageReference2 = %s", imageReference2)
|
|
| 323 |
+ t.Logf("imageReference2 = %s", imageReference2)
|
|
| 324 | 324 |
|
| 325 | 325 |
// pull image1 by digest |
| 326 |
- cli.DockerCmd(c, "pull", imageReference1) |
|
| 326 |
+ cli.DockerCmd(t, "pull", imageReference1) |
|
| 327 | 327 |
|
| 328 | 328 |
// pull image2 by digest |
| 329 |
- cli.DockerCmd(c, "pull", imageReference2) |
|
| 329 |
+ cli.DockerCmd(t, "pull", imageReference2) |
|
| 330 | 330 |
|
| 331 | 331 |
// list images |
| 332 |
- out = cli.DockerCmd(c, "images", "--digests", "--filter=dangling=true").Stdout() |
|
| 332 |
+ out = cli.DockerCmd(t, "images", "--digests", "--filter=dangling=true").Stdout() |
|
| 333 | 333 |
|
| 334 | 334 |
// make sure repo shown, tag=<none>, digest = $digest1 |
| 335 |
- assert.Assert(c, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
| 335 |
+ assert.Assert(t, re1.MatchString(out), "expected %q: %s", re1.String(), out) |
|
| 336 | 336 |
|
| 337 | 337 |
// make sure repo shown, tag=<none>, digest = $digest2 |
| 338 | 338 |
re2 := regexp.MustCompile(`\s*` + repoName + `\s*<none>\s*` + digest2.String() + `\s`) |
| 339 |
- assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
| 339 |
+ assert.Assert(t, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
| 340 | 340 |
|
| 341 | 341 |
// pull dangle1 tag |
| 342 |
- cli.DockerCmd(c, "pull", repoName+":dangle1") |
|
| 342 |
+ cli.DockerCmd(t, "pull", repoName+":dangle1") |
|
| 343 | 343 |
|
| 344 | 344 |
// list images |
| 345 |
- out = cli.DockerCmd(c, "images", "--digests", "--filter=dangling=true").Stdout() |
|
| 345 |
+ out = cli.DockerCmd(t, "images", "--digests", "--filter=dangling=true").Stdout() |
|
| 346 | 346 |
|
| 347 | 347 |
// make sure image 1 has repo, tag, <none> AND repo, <none>, digest |
| 348 | 348 |
reWithDigest1 := regexp.MustCompile(`\s*` + repoName + `\s*dangle1\s*` + digest1.String() + `\s`) |
| 349 |
- assert.Assert(c, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out) |
|
| 349 |
+ assert.Assert(t, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out) |
|
| 350 | 350 |
// make sure image 2 has repo, <none>, digest |
| 351 |
- assert.Assert(c, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
| 351 |
+ assert.Assert(t, re2.MatchString(out), "expected %q: %s", re2.String(), out) |
|
| 352 | 352 |
|
| 353 | 353 |
// pull dangle2 tag |
| 354 |
- cli.DockerCmd(c, "pull", repoName+":dangle2") |
|
| 354 |
+ cli.DockerCmd(t, "pull", repoName+":dangle2") |
|
| 355 | 355 |
|
| 356 | 356 |
// list images, show tagged images |
| 357 |
- out = cli.DockerCmd(c, "images", "--digests").Stdout() |
|
| 357 |
+ out = cli.DockerCmd(t, "images", "--digests").Stdout() |
|
| 358 | 358 |
|
| 359 | 359 |
// make sure image 1 has repo, tag, digest |
| 360 |
- assert.Assert(c, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
| 360 |
+ assert.Assert(t, reWithDigest1.MatchString(out), "expected %q: %s", reWithDigest1.String(), out) |
|
| 361 | 361 |
|
| 362 | 362 |
// make sure image 2 has repo, tag, digest |
| 363 | 363 |
reWithDigest2 := regexp.MustCompile(`\s*` + repoName + `\s*dangle2\s*` + digest2.String() + `\s`) |
| 364 |
- assert.Assert(c, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
| 364 |
+ assert.Assert(t, reWithDigest2.MatchString(out), "expected %q: %s", reWithDigest2.String(), out) |
|
| 365 | 365 |
|
| 366 | 366 |
// list images, no longer dangling, should not match |
| 367 |
- out = cli.DockerCmd(c, "images", "--digests", "--filter=dangling=true").Stdout() |
|
| 367 |
+ out = cli.DockerCmd(t, "images", "--digests", "--filter=dangling=true").Stdout() |
|
| 368 | 368 |
|
| 369 | 369 |
// make sure image 1 has repo, tag, digest |
| 370 |
- assert.Assert(c, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out) |
|
| 370 |
+ assert.Assert(t, !reWithDigest1.MatchString(out), "unexpected %q: %s", reWithDigest1.String(), out) |
|
| 371 | 371 |
// make sure image 2 has repo, tag, digest |
| 372 |
- assert.Assert(c, !reWithDigest2.MatchString(out), "unexpected %q: %s", reWithDigest2.String(), out) |
|
| 372 |
+ assert.Assert(t, !reWithDigest2.MatchString(out), "unexpected %q: %s", reWithDigest2.String(), out) |
|
| 373 | 373 |
} |
| 374 | 374 |
|
| 375 |
-func (s *DockerRegistrySuite) TestInspectImageWithDigests(c *testing.T) {
|
|
| 376 |
- imgDigest, err := setupImage(c) |
|
| 377 |
- assert.Assert(c, err == nil, "error setting up image") |
|
| 375 |
+func (s *DockerRegistrySuite) TestInspectImageWithDigests(t *testing.T) {
|
|
| 376 |
+ imgDigest, err := setupImage(t) |
|
| 377 |
+ assert.Assert(t, err == nil, "error setting up image") |
|
| 378 | 378 |
|
| 379 | 379 |
imageReference := fmt.Sprintf("%s@%s", repoName, imgDigest)
|
| 380 | 380 |
|
| 381 | 381 |
// pull from the registry using the <name>@<digest> reference |
| 382 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 382 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 383 | 383 |
|
| 384 |
- out := cli.DockerCmd(c, "inspect", imageReference).Stdout() |
|
| 384 |
+ out := cli.DockerCmd(t, "inspect", imageReference).Stdout() |
|
| 385 | 385 |
|
| 386 | 386 |
var imageJSON []image.InspectResponse |
| 387 | 387 |
err = json.Unmarshal([]byte(out), &imageJSON) |
| 388 |
- assert.NilError(c, err) |
|
| 389 |
- assert.Equal(c, len(imageJSON), 1) |
|
| 390 |
- assert.Equal(c, len(imageJSON[0].RepoDigests), 1) |
|
| 391 |
- assert.Check(c, is.Contains(imageJSON[0].RepoDigests, imageReference)) |
|
| 388 |
+ assert.NilError(t, err) |
|
| 389 |
+ assert.Equal(t, len(imageJSON), 1) |
|
| 390 |
+ assert.Equal(t, len(imageJSON[0].RepoDigests), 1) |
|
| 391 |
+ assert.Check(t, is.Contains(imageJSON[0].RepoDigests, imageReference)) |
|
| 392 | 392 |
} |
| 393 | 393 |
|
| 394 |
-func (s *DockerRegistrySuite) TestPsListContainersFilterAncestorImageByDigest(c *testing.T) {
|
|
| 395 |
- existingContainers := ExistingContainerIDs(c) |
|
| 394 |
+func (s *DockerRegistrySuite) TestPsListContainersFilterAncestorImageByDigest(t *testing.T) {
|
|
| 395 |
+ existingContainers := ExistingContainerIDs(t) |
|
| 396 | 396 |
|
| 397 |
- imgDigest, err := setupImage(c) |
|
| 398 |
- assert.NilError(c, err, "error setting up image") |
|
| 397 |
+ imgDigest, err := setupImage(t) |
|
| 398 |
+ assert.NilError(t, err, "error setting up image") |
|
| 399 | 399 |
|
| 400 | 400 |
imageReference := fmt.Sprintf("%s@%s", repoName, imgDigest)
|
| 401 | 401 |
|
| 402 | 402 |
// pull from the registry using the <name>@<digest> reference |
| 403 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 403 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 404 | 404 |
|
| 405 | 405 |
// build an image from it |
| 406 | 406 |
const imageName1 = "images_ps_filter_test" |
| 407 |
- buildImageSuccessfully(c, imageName1, build.WithDockerfile(fmt.Sprintf( |
|
| 407 |
+ buildImageSuccessfully(t, imageName1, build.WithDockerfile(fmt.Sprintf( |
|
| 408 | 408 |
`FROM %s |
| 409 | 409 |
LABEL match me 1`, imageReference))) |
| 410 | 410 |
|
| 411 | 411 |
// run a container based on that |
| 412 |
- cli.DockerCmd(c, "run", "--name=test1", imageReference, "echo", "hello") |
|
| 413 |
- expectedID := getIDByName(c, "test1") |
|
| 412 |
+ cli.DockerCmd(t, "run", "--name=test1", imageReference, "echo", "hello") |
|
| 413 |
+ expectedID := getIDByName(t, "test1") |
|
| 414 | 414 |
|
| 415 | 415 |
// run a container based on the a descendant of that too |
| 416 |
- cli.DockerCmd(c, "run", "--name=test2", imageName1, "echo", "hello") |
|
| 417 |
- expectedID1 := getIDByName(c, "test2") |
|
| 416 |
+ cli.DockerCmd(t, "run", "--name=test2", imageName1, "echo", "hello") |
|
| 417 |
+ expectedID1 := getIDByName(t, "test2") |
|
| 418 | 418 |
|
| 419 | 419 |
expectedIDs := []string{expectedID, expectedID1}
|
| 420 | 420 |
|
| 421 | 421 |
// Invalid imageReference |
| 422 |
- out := cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc", fmt.Sprintf("--filter=ancestor=busybox@%s", imgDigest)).Stdout()
|
|
| 423 |
- assert.Equal(c, strings.TrimSpace(out), "", "Filter container for ancestor filter should be empty") |
|
| 422 |
+ out := cli.DockerCmd(t, "ps", "-a", "-q", "--no-trunc", fmt.Sprintf("--filter=ancestor=busybox@%s", imgDigest)).Stdout()
|
|
| 423 |
+ assert.Equal(t, strings.TrimSpace(out), "", "Filter container for ancestor filter should be empty") |
|
| 424 | 424 |
|
| 425 | 425 |
// Valid imageReference |
| 426 |
- out = cli.DockerCmd(c, "ps", "-a", "-q", "--no-trunc", "--filter=ancestor="+imageReference).Stdout() |
|
| 427 |
- checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), imageReference, expectedIDs) |
|
| 426 |
+ out = cli.DockerCmd(t, "ps", "-a", "-q", "--no-trunc", "--filter=ancestor="+imageReference).Stdout() |
|
| 427 |
+ checkPsAncestorFilterOutput(t, RemoveOutputForExistingElements(out, existingContainers), imageReference, expectedIDs) |
|
| 428 | 428 |
} |
| 429 | 429 |
|
| 430 |
-func (s *DockerRegistrySuite) TestDeleteImageByIDOnlyPulledByDigest(c *testing.T) {
|
|
| 431 |
- pushDigest, err := setupImage(c) |
|
| 432 |
- assert.NilError(c, err, "error setting up image") |
|
| 430 |
+func (s *DockerRegistrySuite) TestDeleteImageByIDOnlyPulledByDigest(t *testing.T) {
|
|
| 431 |
+ pushDigest, err := setupImage(t) |
|
| 432 |
+ assert.NilError(t, err, "error setting up image") |
|
| 433 | 433 |
|
| 434 | 434 |
// pull from the registry using the <name>@<digest> reference |
| 435 | 435 |
imageReference := fmt.Sprintf("%s@%s", repoName, pushDigest)
|
| 436 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 436 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 437 | 437 |
// just in case... |
| 438 | 438 |
|
| 439 |
- cli.DockerCmd(c, "tag", imageReference, repoName+":sometag") |
|
| 439 |
+ cli.DockerCmd(t, "tag", imageReference, repoName+":sometag") |
|
| 440 | 440 |
|
| 441 |
- imageID := inspectField(c, imageReference, "Id") |
|
| 441 |
+ imageID := inspectField(t, imageReference, "Id") |
|
| 442 | 442 |
|
| 443 |
- cli.DockerCmd(c, "rmi", imageID) |
|
| 443 |
+ cli.DockerCmd(t, "rmi", imageID) |
|
| 444 | 444 |
|
| 445 | 445 |
_, err = inspectFieldWithError(imageID, "Id") |
| 446 |
- assert.ErrorContains(c, err, "", "image should have been deleted") |
|
| 446 |
+ assert.ErrorContains(t, err, "", "image should have been deleted") |
|
| 447 | 447 |
} |
| 448 | 448 |
|
| 449 |
-func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndTag(c *testing.T) {
|
|
| 450 |
- pushDigest, err := setupImage(c) |
|
| 451 |
- assert.NilError(c, err, "error setting up image") |
|
| 449 |
+func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndTag(t *testing.T) {
|
|
| 450 |
+ pushDigest, err := setupImage(t) |
|
| 451 |
+ assert.NilError(t, err, "error setting up image") |
|
| 452 | 452 |
|
| 453 | 453 |
// pull from the registry using the <name>@<digest> reference |
| 454 | 454 |
imageReference := fmt.Sprintf("%s@%s", repoName, pushDigest)
|
| 455 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 455 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 456 | 456 |
|
| 457 |
- imageID := inspectField(c, imageReference, "Id") |
|
| 457 |
+ imageID := inspectField(t, imageReference, "Id") |
|
| 458 | 458 |
|
| 459 | 459 |
const repoTag = repoName + ":sometag" |
| 460 | 460 |
const repoTag2 = repoName + ":othertag" |
| 461 |
- cli.DockerCmd(c, "tag", imageReference, repoTag) |
|
| 462 |
- cli.DockerCmd(c, "tag", imageReference, repoTag2) |
|
| 461 |
+ cli.DockerCmd(t, "tag", imageReference, repoTag) |
|
| 462 |
+ cli.DockerCmd(t, "tag", imageReference, repoTag2) |
|
| 463 | 463 |
|
| 464 |
- cli.DockerCmd(c, "rmi", repoTag2) |
|
| 464 |
+ cli.DockerCmd(t, "rmi", repoTag2) |
|
| 465 | 465 |
|
| 466 | 466 |
// rmi should have deleted only repoTag2, because there's another tag |
| 467 |
- inspectField(c, repoTag, "Id") |
|
| 467 |
+ inspectField(t, repoTag, "Id") |
|
| 468 | 468 |
|
| 469 |
- cli.DockerCmd(c, "rmi", repoTag) |
|
| 469 |
+ cli.DockerCmd(t, "rmi", repoTag) |
|
| 470 | 470 |
|
| 471 | 471 |
// rmi should have deleted the tag, the digest reference, and the image itself |
| 472 | 472 |
_, err = inspectFieldWithError(imageID, "Id") |
| 473 |
- assert.ErrorContains(c, err, "", "image should have been deleted") |
|
| 473 |
+ assert.ErrorContains(t, err, "", "image should have been deleted") |
|
| 474 | 474 |
} |
| 475 | 475 |
|
| 476 |
-func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndMultiRepoTag(c *testing.T) {
|
|
| 477 |
- pushDigest, err := setupImage(c) |
|
| 478 |
- assert.NilError(c, err, "error setting up image") |
|
| 476 |
+func (s *DockerRegistrySuite) TestDeleteImageWithDigestAndMultiRepoTag(t *testing.T) {
|
|
| 477 |
+ pushDigest, err := setupImage(t) |
|
| 478 |
+ assert.NilError(t, err, "error setting up image") |
|
| 479 | 479 |
|
| 480 | 480 |
repo2 := fmt.Sprintf("%s/%s", repoName, "repo2")
|
| 481 | 481 |
|
| 482 | 482 |
// pull from the registry using the <name>@<digest> reference |
| 483 | 483 |
imageReference := fmt.Sprintf("%s@%s", repoName, pushDigest)
|
| 484 |
- cli.DockerCmd(c, "pull", imageReference) |
|
| 484 |
+ cli.DockerCmd(t, "pull", imageReference) |
|
| 485 | 485 |
|
| 486 |
- imageID := inspectField(c, imageReference, "Id") |
|
| 486 |
+ imageID := inspectField(t, imageReference, "Id") |
|
| 487 | 487 |
|
| 488 | 488 |
repoTag := repoName + ":sometag" |
| 489 | 489 |
repoTag2 := repo2 + ":othertag" |
| 490 |
- cli.DockerCmd(c, "tag", imageReference, repoTag) |
|
| 491 |
- cli.DockerCmd(c, "tag", imageReference, repoTag2) |
|
| 490 |
+ cli.DockerCmd(t, "tag", imageReference, repoTag) |
|
| 491 |
+ cli.DockerCmd(t, "tag", imageReference, repoTag2) |
|
| 492 | 492 |
|
| 493 |
- cli.DockerCmd(c, "rmi", repoTag) |
|
| 493 |
+ cli.DockerCmd(t, "rmi", repoTag) |
|
| 494 | 494 |
|
| 495 | 495 |
// rmi should have deleted repoTag and image reference, but left repoTag2 |
| 496 |
- inspectField(c, repoTag2, "Id") |
|
| 496 |
+ inspectField(t, repoTag2, "Id") |
|
| 497 | 497 |
_, err = inspectFieldWithError(imageReference, "Id") |
| 498 |
- assert.ErrorContains(c, err, "", "image digest reference should have been removed") |
|
| 498 |
+ assert.ErrorContains(t, err, "", "image digest reference should have been removed") |
|
| 499 | 499 |
|
| 500 | 500 |
_, err = inspectFieldWithError(repoTag, "Id") |
| 501 |
- assert.ErrorContains(c, err, "", "image tag reference should have been removed") |
|
| 501 |
+ assert.ErrorContains(t, err, "", "image tag reference should have been removed") |
|
| 502 | 502 |
|
| 503 |
- cli.DockerCmd(c, "rmi", repoTag2) |
|
| 503 |
+ cli.DockerCmd(t, "rmi", repoTag2) |
|
| 504 | 504 |
|
| 505 | 505 |
// rmi should have deleted the tag, the digest reference, and the image itself |
| 506 | 506 |
_, err = inspectFieldWithError(imageID, "Id") |
| 507 |
- assert.ErrorContains(c, err, "", "image should have been deleted") |
|
| 507 |
+ assert.ErrorContains(t, err, "", "image should have been deleted") |
|
| 508 | 508 |
} |
| 509 | 509 |
|
| 510 | 510 |
// TestPullFailsWithAlteredManifest tests that a `docker pull` fails when |
| 511 | 511 |
// we have modified a manifest blob and its digest cannot be verified. |
| 512 | 512 |
// This is the schema2 version of the test. |
| 513 |
-func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(c *testing.T) {
|
|
| 514 |
- testRequires(c, DaemonIsLinux) |
|
| 515 |
- manifestDigest, err := setupImage(c) |
|
| 516 |
- assert.NilError(c, err, "error setting up image") |
|
| 513 |
+func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(t *testing.T) {
|
|
| 514 |
+ testRequires(t, DaemonIsLinux) |
|
| 515 |
+ manifestDigest, err := setupImage(t) |
|
| 516 |
+ assert.NilError(t, err, "error setting up image") |
|
| 517 | 517 |
|
| 518 | 518 |
// Load the target manifest blob. |
| 519 |
- manifestBlob := s.reg.ReadBlobContents(c, manifestDigest) |
|
| 519 |
+ manifestBlob := s.reg.ReadBlobContents(t, manifestDigest) |
|
| 520 | 520 |
|
| 521 | 521 |
var imgManifest schema2.Manifest |
| 522 | 522 |
err = json.Unmarshal(manifestBlob, &imgManifest) |
| 523 |
- assert.NilError(c, err, "unable to decode image manifest from blob") |
|
| 523 |
+ assert.NilError(t, err, "unable to decode image manifest from blob") |
|
| 524 | 524 |
|
| 525 | 525 |
// Change a layer in the manifest. |
| 526 | 526 |
imgManifest.Layers[0].Digest = digest.Digest("sha256:0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")
|
| 527 | 527 |
|
| 528 | 528 |
// Move the existing data file aside, so that we can replace it with a |
| 529 | 529 |
// malicious blob of data. NOTE: we defer the returned undo func. |
| 530 |
- undo := s.reg.TempMoveBlobData(c, manifestDigest) |
|
| 530 |
+ undo := s.reg.TempMoveBlobData(t, manifestDigest) |
|
| 531 | 531 |
defer undo() |
| 532 | 532 |
|
| 533 | 533 |
alteredManifestBlob, err := json.MarshalIndent(imgManifest, "", " ") |
| 534 |
- assert.NilError(c, err, "unable to encode altered image manifest to JSON") |
|
| 534 |
+ assert.NilError(t, err, "unable to encode altered image manifest to JSON") |
|
| 535 | 535 |
|
| 536 |
- s.reg.WriteBlobContents(c, manifestDigest, alteredManifestBlob) |
|
| 536 |
+ s.reg.WriteBlobContents(t, manifestDigest, alteredManifestBlob) |
|
| 537 | 537 |
|
| 538 | 538 |
// Now try pulling that image by digest. We should get an error about |
| 539 | 539 |
// digest verification for the manifest digest. |
| ... | ... |
@@ -541,57 +541,57 @@ func (s *DockerRegistrySuite) TestPullFailsWithAlteredManifest(c *testing.T) {
|
| 541 | 541 |
// Pull from the registry using the <name>@<digest> reference. |
| 542 | 542 |
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
|
| 543 | 543 |
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
|
| 544 |
- assert.Assert(c, exitStatus != 0) |
|
| 544 |
+ assert.Assert(t, exitStatus != 0) |
|
| 545 | 545 |
|
| 546 | 546 |
if testEnv.UsingSnapshotter() {
|
| 547 |
- assert.Assert(c, is.Contains(out, "unexpected commit digest")) |
|
| 548 |
- assert.Assert(c, is.Contains(out, "expected "+manifestDigest)) |
|
| 547 |
+ assert.Assert(t, is.Contains(out, "unexpected commit digest")) |
|
| 548 |
+ assert.Assert(t, is.Contains(out, "expected "+manifestDigest)) |
|
| 549 | 549 |
} else {
|
| 550 |
- assert.Assert(c, is.Contains(out, fmt.Sprintf("manifest verification failed for digest %s", manifestDigest)))
|
|
| 550 |
+ assert.Assert(t, is.Contains(out, fmt.Sprintf("manifest verification failed for digest %s", manifestDigest)))
|
|
| 551 | 551 |
} |
| 552 | 552 |
} |
| 553 | 553 |
|
| 554 | 554 |
// TestPullFailsWithAlteredLayer tests that a `docker pull` fails when |
| 555 | 555 |
// we have modified a layer blob and its digest cannot be verified. |
| 556 | 556 |
// This is the schema2 version of the test. |
| 557 |
-func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(c *testing.T) {
|
|
| 558 |
- testRequires(c, DaemonIsLinux) |
|
| 559 |
- skip.If(c, testEnv.UsingSnapshotter(), "Faked layer is already in the content store, so it won't be fetched from the repository at all.") |
|
| 557 |
+func (s *DockerRegistrySuite) TestPullFailsWithAlteredLayer(t *testing.T) {
|
|
| 558 |
+ testRequires(t, DaemonIsLinux) |
|
| 559 |
+ skip.If(t, testEnv.UsingSnapshotter(), "Faked layer is already in the content store, so it won't be fetched from the repository at all.") |
|
| 560 | 560 |
|
| 561 |
- manifestDigest, err := setupImage(c) |
|
| 562 |
- assert.NilError(c, err) |
|
| 561 |
+ manifestDigest, err := setupImage(t) |
|
| 562 |
+ assert.NilError(t, err) |
|
| 563 | 563 |
|
| 564 | 564 |
// Load the target manifest blob. |
| 565 |
- manifestBlob := s.reg.ReadBlobContents(c, manifestDigest) |
|
| 565 |
+ manifestBlob := s.reg.ReadBlobContents(t, manifestDigest) |
|
| 566 | 566 |
|
| 567 | 567 |
var imgManifest schema2.Manifest |
| 568 | 568 |
err = json.Unmarshal(manifestBlob, &imgManifest) |
| 569 |
- assert.NilError(c, err) |
|
| 569 |
+ assert.NilError(t, err) |
|
| 570 | 570 |
|
| 571 | 571 |
// Next, get the digest of one of the layers from the manifest. |
| 572 | 572 |
targetLayerDigest := imgManifest.Layers[0].Digest |
| 573 | 573 |
|
| 574 | 574 |
// Move the existing data file aside, so that we can replace it with a |
| 575 | 575 |
// malicious blob of data. NOTE: we defer the returned undo func. |
| 576 |
- undo := s.reg.TempMoveBlobData(c, targetLayerDigest) |
|
| 576 |
+ undo := s.reg.TempMoveBlobData(t, targetLayerDigest) |
|
| 577 | 577 |
defer undo() |
| 578 | 578 |
|
| 579 | 579 |
// Now make a fake data blob in this directory. |
| 580 |
- s.reg.WriteBlobContents(c, targetLayerDigest, []byte("This is not the data you are looking for."))
|
|
| 580 |
+ s.reg.WriteBlobContents(t, targetLayerDigest, []byte("This is not the data you are looking for."))
|
|
| 581 | 581 |
|
| 582 | 582 |
// Now try pulling that image by digest. We should get an error about |
| 583 | 583 |
// digest verification for the target layer digest. |
| 584 | 584 |
|
| 585 | 585 |
// Remove distribution cache to force a re-pull of the blobs |
| 586 | 586 |
if err := os.RemoveAll(filepath.Join(testEnv.DaemonInfo.DockerRootDir, "image", s.d.StorageDriver(), "distribution")); err != nil {
|
| 587 |
- c.Fatalf("error clearing distribution cache: %v", err)
|
|
| 587 |
+ t.Fatalf("error clearing distribution cache: %v", err)
|
|
| 588 | 588 |
} |
| 589 | 589 |
|
| 590 | 590 |
// Pull from the registry using the <name>@<digest> reference. |
| 591 | 591 |
imageReference := fmt.Sprintf("%s@%s", repoName, manifestDigest)
|
| 592 | 592 |
out, exitStatus, _ := dockerCmdWithError("pull", imageReference)
|
| 593 |
- assert.Assert(c, exitStatus != 0, "expected a non-zero exit status") |
|
| 593 |
+ assert.Assert(t, exitStatus != 0, "expected a non-zero exit status") |
|
| 594 | 594 |
|
| 595 | 595 |
expectedErrorMsg := fmt.Sprintf("filesystem layer verification failed for digest %s", targetLayerDigest)
|
| 596 |
- assert.Assert(c, strings.Contains(out, expectedErrorMsg), "expected error message in output: %s", out) |
|
| 596 |
+ assert.Assert(t, strings.Contains(out, expectedErrorMsg), "expected error message in output: %s", out) |
|
| 597 | 597 |
} |
| ... | ... |
@@ -15,12 +15,12 @@ type DockerCLICommitSuite struct {
|
| 15 | 15 |
ds *DockerSuite |
| 16 | 16 |
} |
| 17 | 17 |
|
| 18 |
-func (s *DockerCLICommitSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 19 |
- s.ds.TearDownTest(ctx, c) |
|
| 18 |
+func (s *DockerCLICommitSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 19 |
+ s.ds.TearDownTest(ctx, t) |
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
-func (s *DockerCLICommitSuite) OnTimeout(c *testing.T) {
|
|
| 23 |
- s.ds.OnTimeout(c) |
|
| 22 |
+func (s *DockerCLICommitSuite) OnTimeout(t *testing.T) {
|
|
| 23 |
+ s.ds.OnTimeout(t) |
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
func (s *DockerCLICommitSuite) TestCommitAfterContainerIsDone(c *testing.T) {
|
| ... | ... |
@@ -32,12 +32,12 @@ type DockerCLICpSuite struct {
|
| 32 | 32 |
ds *DockerSuite |
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 |
-func (s *DockerCLICpSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 36 |
- s.ds.TearDownTest(ctx, c) |
|
| 35 |
+func (s *DockerCLICpSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 36 |
+ s.ds.TearDownTest(ctx, t) |
|
| 37 | 37 |
} |
| 38 | 38 |
|
| 39 |
-func (s *DockerCLICpSuite) OnTimeout(c *testing.T) {
|
|
| 40 |
- s.ds.OnTimeout(c) |
|
| 39 |
+func (s *DockerCLICpSuite) OnTimeout(t *testing.T) {
|
|
| 40 |
+ s.ds.OnTimeout(t) |
|
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 | 43 |
// Ensure that an all-local path case returns an error. |
| ... | ... |
@@ -94,21 +94,21 @@ func defaultMkContentCommand() string {
|
| 94 | 94 |
return mkFilesCommand(defaultFileData) |
| 95 | 95 |
} |
| 96 | 96 |
|
| 97 |
-func makeTestContentInDir(c *testing.T, dir string) {
|
|
| 98 |
- c.Helper() |
|
| 97 |
+func makeTestContentInDir(t *testing.T, dir string) {
|
|
| 98 |
+ t.Helper() |
|
| 99 | 99 |
for _, fd := range defaultFileData {
|
| 100 | 100 |
path := filepath.Join(dir, filepath.FromSlash(fd.path)) |
| 101 | 101 |
switch fd.filetype {
|
| 102 | 102 |
case ftRegular: |
| 103 |
- assert.NilError(c, os.WriteFile(path, []byte(fd.contents+"\n"), os.FileMode(fd.mode))) |
|
| 103 |
+ assert.NilError(t, os.WriteFile(path, []byte(fd.contents+"\n"), os.FileMode(fd.mode))) |
|
| 104 | 104 |
case ftDir: |
| 105 |
- assert.NilError(c, os.Mkdir(path, os.FileMode(fd.mode))) |
|
| 105 |
+ assert.NilError(t, os.Mkdir(path, os.FileMode(fd.mode))) |
|
| 106 | 106 |
case ftSymlink: |
| 107 |
- assert.NilError(c, os.Symlink(fd.contents, path)) |
|
| 107 |
+ assert.NilError(t, os.Symlink(fd.contents, path)) |
|
| 108 | 108 |
} |
| 109 | 109 |
|
| 110 | 110 |
if fd.filetype != ftSymlink && runtime.GOOS != "windows" {
|
| 111 |
- assert.NilError(c, os.Chown(path, fd.uid, fd.gid)) |
|
| 111 |
+ assert.NilError(t, os.Chown(path, fd.uid, fd.gid)) |
|
| 112 | 112 |
} |
| 113 | 113 |
} |
| 114 | 114 |
} |
| ... | ... |
@@ -121,8 +121,8 @@ type testContainerOptions struct {
|
| 121 | 121 |
command string |
| 122 | 122 |
} |
| 123 | 123 |
|
| 124 |
-func makeTestContainer(c *testing.T, options testContainerOptions) (containerID string) {
|
|
| 125 |
- c.Helper() |
|
| 124 |
+func makeTestContainer(t *testing.T, options testContainerOptions) (containerID string) {
|
|
| 125 |
+ t.Helper() |
|
| 126 | 126 |
if options.addContent {
|
| 127 | 127 |
mkContentCmd := defaultMkContentCommand() |
| 128 | 128 |
if options.command == "" {
|
| ... | ... |
@@ -152,17 +152,17 @@ func makeTestContainer(c *testing.T, options testContainerOptions) (containerID |
| 152 | 152 |
|
| 153 | 153 |
args = append(args, "busybox", "/bin/sh", "-c", options.command) |
| 154 | 154 |
|
| 155 |
- out := cli.DockerCmd(c, args...).Combined() |
|
| 155 |
+ out := cli.DockerCmd(t, args...).Combined() |
|
| 156 | 156 |
|
| 157 | 157 |
containerID = strings.TrimSpace(out) |
| 158 | 158 |
|
| 159 |
- out = cli.DockerCmd(c, "wait", containerID).Combined() |
|
| 159 |
+ out = cli.DockerCmd(t, "wait", containerID).Combined() |
|
| 160 | 160 |
|
| 161 | 161 |
exitCode := strings.TrimSpace(out) |
| 162 | 162 |
if exitCode != "0" {
|
| 163 |
- out = cli.DockerCmd(c, "logs", containerID).Combined() |
|
| 163 |
+ out = cli.DockerCmd(t, "logs", containerID).Combined() |
|
| 164 | 164 |
} |
| 165 |
- assert.Equal(c, exitCode, "0", "failed to make test container: %s", out) |
|
| 165 |
+ assert.Equal(t, exitCode, "0", "failed to make test container: %s", out) |
|
| 166 | 166 |
|
| 167 | 167 |
return containerID |
| 168 | 168 |
} |
| ... | ... |
@@ -192,8 +192,8 @@ func containerCpPathTrailingSep(containerID string, pathElements ...string) stri |
| 192 | 192 |
return fmt.Sprintf("%s/", containerCpPath(containerID, pathElements...))
|
| 193 | 193 |
} |
| 194 | 194 |
|
| 195 |
-func runDockerCp(c *testing.T, src, dst string) error {
|
|
| 196 |
- c.Helper() |
|
| 195 |
+func runDockerCp(t *testing.T, src, dst string) error {
|
|
| 196 |
+ t.Helper() |
|
| 197 | 197 |
|
| 198 | 198 |
args := []string{"cp", src, dst}
|
| 199 | 199 |
if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, args...)); err != nil {
|
| ... | ... |
@@ -202,8 +202,8 @@ func runDockerCp(c *testing.T, src, dst string) error {
|
| 202 | 202 |
return nil |
| 203 | 203 |
} |
| 204 | 204 |
|
| 205 |
-func startContainerGetOutput(c *testing.T, containerID string) (string, error) {
|
|
| 206 |
- c.Helper() |
|
| 205 |
+func startContainerGetOutput(t *testing.T, containerID string) (string, error) {
|
|
| 206 |
+ t.Helper() |
|
| 207 | 207 |
|
| 208 | 208 |
args := []string{"start", "-a", containerID}
|
| 209 | 209 |
|
| ... | ... |
@@ -215,13 +215,13 @@ func startContainerGetOutput(c *testing.T, containerID string) (string, error) {
|
| 215 | 215 |
return out, nil |
| 216 | 216 |
} |
| 217 | 217 |
|
| 218 |
-func getTestDir(c *testing.T, label string) (tmpDir string) {
|
|
| 219 |
- c.Helper() |
|
| 218 |
+func getTestDir(t *testing.T, label string) (tmpDir string) {
|
|
| 219 |
+ t.Helper() |
|
| 220 | 220 |
var err error |
| 221 | 221 |
|
| 222 | 222 |
tmpDir, err = os.MkdirTemp("", label)
|
| 223 | 223 |
// unable to make temporary directory |
| 224 |
- assert.NilError(c, err) |
|
| 224 |
+ assert.NilError(t, err) |
|
| 225 | 225 |
|
| 226 | 226 |
return tmpDir |
| 227 | 227 |
} |
| ... | ... |
@@ -234,8 +234,8 @@ func isCpCannotCopyDir(err error) is.Comparison {
|
| 234 | 234 |
return is.ErrorContains(err, archive.ErrCannotCopyDir.Error()) |
| 235 | 235 |
} |
| 236 | 236 |
|
| 237 |
-func fileContentEquals(c *testing.T, filename, contents string) error {
|
|
| 238 |
- c.Helper() |
|
| 237 |
+func fileContentEquals(t *testing.T, filename, contents string) error {
|
|
| 238 |
+ t.Helper() |
|
| 239 | 239 |
|
| 240 | 240 |
fileBytes, err := os.ReadFile(filename) |
| 241 | 241 |
if err != nil {
|
| ... | ... |
@@ -254,8 +254,8 @@ func fileContentEquals(c *testing.T, filename, contents string) error {
|
| 254 | 254 |
return nil |
| 255 | 255 |
} |
| 256 | 256 |
|
| 257 |
-func symlinkTargetEquals(c *testing.T, symlink, expectedTarget string) error {
|
|
| 258 |
- c.Helper() |
|
| 257 |
+func symlinkTargetEquals(t *testing.T, symlink, expectedTarget string) error {
|
|
| 258 |
+ t.Helper() |
|
| 259 | 259 |
|
| 260 | 260 |
actualTarget, err := os.Readlink(symlink) |
| 261 | 261 |
if err != nil {
|
| ... | ... |
@@ -269,10 +269,10 @@ func symlinkTargetEquals(c *testing.T, symlink, expectedTarget string) error {
|
| 269 | 269 |
return nil |
| 270 | 270 |
} |
| 271 | 271 |
|
| 272 |
-func containerStartOutputEquals(c *testing.T, containerID, contents string) error {
|
|
| 273 |
- c.Helper() |
|
| 272 |
+func containerStartOutputEquals(t *testing.T, containerID, contents string) error {
|
|
| 273 |
+ t.Helper() |
|
| 274 | 274 |
|
| 275 |
- out, err := startContainerGetOutput(c, containerID) |
|
| 275 |
+ out, err := startContainerGetOutput(t, containerID) |
|
| 276 | 276 |
if err != nil {
|
| 277 | 277 |
return err |
| 278 | 278 |
} |
| ... | ... |
@@ -21,12 +21,12 @@ type DockerCLICreateSuite struct {
|
| 21 | 21 |
ds *DockerSuite |
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
-func (s *DockerCLICreateSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 25 |
- s.ds.TearDownTest(ctx, c) |
|
| 24 |
+func (s *DockerCLICreateSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 25 |
+ s.ds.TearDownTest(ctx, t) |
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 |
-func (s *DockerCLICreateSuite) OnTimeout(c *testing.T) {
|
|
| 29 |
- s.ds.OnTimeout(c) |
|
| 28 |
+func (s *DockerCLICreateSuite) OnTimeout(t *testing.T) {
|
|
| 29 |
+ s.ds.OnTimeout(t) |
|
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 | 32 |
// Make sure we can create a simple container with some args |
| ... | ... |
@@ -379,15 +379,15 @@ func (s *DockerDaemonSuite) TestDaemonBridgeNone(c *testing.T) {
|
| 379 | 379 |
assert.Assert(c, is.Contains(out, "No such network")) |
| 380 | 380 |
} |
| 381 | 381 |
|
| 382 |
-func createInterface(c *testing.T, ifType string, ifName string, ipNet string) {
|
|
| 383 |
- icmd.RunCommand("ip", "link", "add", "name", ifName, "type", ifType).Assert(c, icmd.Success)
|
|
| 384 |
- icmd.RunCommand("ifconfig", ifName, ipNet, "up").Assert(c, icmd.Success)
|
|
| 382 |
+func createInterface(t *testing.T, ifType string, ifName string, ipNet string) {
|
|
| 383 |
+ icmd.RunCommand("ip", "link", "add", "name", ifName, "type", ifType).Assert(t, icmd.Success)
|
|
| 384 |
+ icmd.RunCommand("ifconfig", ifName, ipNet, "up").Assert(t, icmd.Success)
|
|
| 385 | 385 |
} |
| 386 | 386 |
|
| 387 |
-func deleteInterface(c *testing.T, ifName string) {
|
|
| 388 |
- icmd.RunCommand("ip", "link", "delete", ifName).Assert(c, icmd.Success)
|
|
| 389 |
- icmd.RunCommand("iptables", "-t", "nat", "--flush").Assert(c, icmd.Success)
|
|
| 390 |
- icmd.RunCommand("iptables", "--flush").Assert(c, icmd.Success)
|
|
| 387 |
+func deleteInterface(t *testing.T, ifName string) {
|
|
| 388 |
+ icmd.RunCommand("ip", "link", "delete", ifName).Assert(t, icmd.Success)
|
|
| 389 |
+ icmd.RunCommand("iptables", "-t", "nat", "--flush").Assert(t, icmd.Success)
|
|
| 390 |
+ icmd.RunCommand("iptables", "--flush").Assert(t, icmd.Success)
|
|
| 391 | 391 |
} |
| 392 | 392 |
|
| 393 | 393 |
func (s *DockerDaemonSuite) TestDaemonUlimitDefaults(c *testing.T) {
|
| ... | ... |
@@ -2129,35 +2129,35 @@ func (s *DockerDaemonSuite) TestShmSizeReload(c *testing.T) {
|
| 2129 | 2129 |
assert.Equal(c, strings.TrimSpace(out), fmt.Sprintf("%v", size))
|
| 2130 | 2130 |
} |
| 2131 | 2131 |
|
| 2132 |
-func testDaemonStartIpcMode(c *testing.T, from, mode string, valid bool) {
|
|
| 2133 |
- d := daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 2134 |
- c.Logf("Checking IpcMode %s set from %s\n", mode, from)
|
|
| 2132 |
+func testDaemonStartIpcMode(t *testing.T, from, mode string, valid bool) {
|
|
| 2133 |
+ d := daemon.New(t, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 2134 |
+ t.Logf("Checking IpcMode %s set from %s\n", mode, from)
|
|
| 2135 | 2135 |
var serr error |
| 2136 | 2136 |
switch from {
|
| 2137 | 2137 |
case "config": |
| 2138 | 2138 |
f, err := os.CreateTemp("", "test-daemon-ipc-config")
|
| 2139 |
- assert.NilError(c, err) |
|
| 2139 |
+ assert.NilError(t, err) |
|
| 2140 | 2140 |
defer os.Remove(f.Name()) |
| 2141 | 2141 |
config := `{"default-ipc-mode": "` + mode + `"}`
|
| 2142 | 2142 |
_, err = f.WriteString(config) |
| 2143 |
- assert.NilError(c, f.Close()) |
|
| 2144 |
- assert.NilError(c, err) |
|
| 2143 |
+ assert.NilError(t, f.Close()) |
|
| 2144 |
+ assert.NilError(t, err) |
|
| 2145 | 2145 |
|
| 2146 | 2146 |
serr = d.StartWithError("--config-file", f.Name())
|
| 2147 | 2147 |
case "cli": |
| 2148 | 2148 |
serr = d.StartWithError("--default-ipc-mode", mode)
|
| 2149 | 2149 |
default: |
| 2150 |
- c.Fatalf("testDaemonStartIpcMode: invalid 'from' argument")
|
|
| 2150 |
+ t.Fatalf("testDaemonStartIpcMode: invalid 'from' argument")
|
|
| 2151 | 2151 |
} |
| 2152 | 2152 |
if serr == nil {
|
| 2153 |
- d.Stop(c) |
|
| 2153 |
+ d.Stop(t) |
|
| 2154 | 2154 |
} |
| 2155 | 2155 |
|
| 2156 | 2156 |
if valid {
|
| 2157 |
- assert.NilError(c, serr) |
|
| 2157 |
+ assert.NilError(t, serr) |
|
| 2158 | 2158 |
} else {
|
| 2159 |
- assert.ErrorContains(c, serr, "") |
|
| 2160 |
- icmd.RunCommand("grep", "-E", "IPC .* is (invalid|not supported)", d.LogFileName()).Assert(c, icmd.Success)
|
|
| 2159 |
+ assert.ErrorContains(t, serr, "") |
|
| 2160 |
+ icmd.RunCommand("grep", "-E", "IPC .* is (invalid|not supported)", d.LogFileName()).Assert(t, icmd.Success)
|
|
| 2161 | 2161 |
} |
| 2162 | 2162 |
} |
| 2163 | 2163 |
|
| ... | ... |
@@ -29,12 +29,12 @@ type DockerCLIEventSuite struct {
|
| 29 | 29 |
ds *DockerSuite |
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 |
-func (s *DockerCLIEventSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 33 |
- s.ds.TearDownTest(ctx, c) |
|
| 32 |
+func (s *DockerCLIEventSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 33 |
+ s.ds.TearDownTest(ctx, t) |
|
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 |
-func (s *DockerCLIEventSuite) OnTimeout(c *testing.T) {
|
|
| 37 |
- s.ds.OnTimeout(c) |
|
| 36 |
+func (s *DockerCLIEventSuite) OnTimeout(t *testing.T) {
|
|
| 37 |
+ s.ds.OnTimeout(t) |
|
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 | 40 |
func (s *DockerCLIEventSuite) TestEventsTimestampFormats(c *testing.T) {
|
| ... | ... |
@@ -27,12 +27,12 @@ type DockerCLIExecSuite struct {
|
| 27 | 27 |
ds *DockerSuite |
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-func (s *DockerCLIExecSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 31 |
- s.ds.TearDownTest(ctx, c) |
|
| 30 |
+func (s *DockerCLIExecSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 31 |
+ s.ds.TearDownTest(ctx, t) |
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 |
-func (s *DockerCLIExecSuite) OnTimeout(c *testing.T) {
|
|
| 35 |
- s.ds.OnTimeout(c) |
|
| 34 |
+func (s *DockerCLIExecSuite) OnTimeout(t *testing.T) {
|
|
| 35 |
+ s.ds.OnTimeout(t) |
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 | 38 |
func (s *DockerCLIExecSuite) TestExec(c *testing.T) {
|
| ... | ... |
@@ -47,21 +47,21 @@ type DockerExternalVolumeSuite struct {
|
| 47 | 47 |
*volumePlugin |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
-func (s *DockerExternalVolumeSuite) SetUpTest(ctx context.Context, c *testing.T) {
|
|
| 51 |
- testRequires(c, testEnv.IsLocalDaemon) |
|
| 52 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 50 |
+func (s *DockerExternalVolumeSuite) SetUpTest(ctx context.Context, t *testing.T) {
|
|
| 51 |
+ testRequires(t, testEnv.IsLocalDaemon) |
|
| 52 |
+ s.d = daemon.New(t, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 53 | 53 |
s.ec = &eventCounter{}
|
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 |
-func (s *DockerExternalVolumeSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 56 |
+func (s *DockerExternalVolumeSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 57 | 57 |
if s.d != nil {
|
| 58 |
- s.d.Stop(c) |
|
| 59 |
- s.ds.TearDownTest(ctx, c) |
|
| 58 |
+ s.d.Stop(t) |
|
| 59 |
+ s.ds.TearDownTest(ctx, t) |
|
| 60 | 60 |
} |
| 61 | 61 |
} |
| 62 | 62 |
|
| 63 |
-func (s *DockerExternalVolumeSuite) SetUpSuite(ctx context.Context, c *testing.T) {
|
|
| 64 |
- s.volumePlugin = newVolumePlugin(c, volumePluginName) |
|
| 63 |
+func (s *DockerExternalVolumeSuite) SetUpSuite(ctx context.Context, t *testing.T) {
|
|
| 64 |
+ s.volumePlugin = newVolumePlugin(t, volumePluginName) |
|
| 65 | 65 |
} |
| 66 | 66 |
|
| 67 | 67 |
type volumePlugin struct {
|
| ... | ... |
@@ -274,11 +274,11 @@ func newVolumePlugin(t *testing.T, name string) *volumePlugin {
|
| 274 | 274 |
return s |
| 275 | 275 |
} |
| 276 | 276 |
|
| 277 |
-func (s *DockerExternalVolumeSuite) TearDownSuite(ctx context.Context, c *testing.T) {
|
|
| 277 |
+func (s *DockerExternalVolumeSuite) TearDownSuite(ctx context.Context, t *testing.T) {
|
|
| 278 | 278 |
s.volumePlugin.Close() |
| 279 | 279 |
|
| 280 | 280 |
err := os.RemoveAll("/etc/docker/plugins")
|
| 281 |
- assert.NilError(c, err) |
|
| 281 |
+ assert.NilError(t, err) |
|
| 282 | 282 |
} |
| 283 | 283 |
|
| 284 | 284 |
func (s *DockerExternalVolumeSuite) TestVolumeCLICreateOptionConflict(c *testing.T) {
|
| ... | ... |
@@ -18,23 +18,23 @@ type DockerCLIHealthSuite struct {
|
| 18 | 18 |
ds *DockerSuite |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (s *DockerCLIHealthSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 22 |
- s.ds.TearDownTest(ctx, c) |
|
| 21 |
+func (s *DockerCLIHealthSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 22 |
+ s.ds.TearDownTest(ctx, t) |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
-func (s *DockerCLIHealthSuite) OnTimeout(c *testing.T) {
|
|
| 26 |
- s.ds.OnTimeout(c) |
|
| 25 |
+func (s *DockerCLIHealthSuite) OnTimeout(t *testing.T) {
|
|
| 26 |
+ s.ds.OnTimeout(t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
-func waitForHealthStatus(c *testing.T, name string, prev string, expected string) {
|
|
| 29 |
+func waitForHealthStatus(t *testing.T, name string, prev string, expected string) {
|
|
| 30 | 30 |
prev = prev + "\n" |
| 31 | 31 |
expected = expected + "\n" |
| 32 | 32 |
for {
|
| 33 |
- out := cli.DockerCmd(c, "inspect", "--format={{.State.Health.Status}}", name).Stdout()
|
|
| 33 |
+ out := cli.DockerCmd(t, "inspect", "--format={{.State.Health.Status}}", name).Stdout()
|
|
| 34 | 34 |
if out == expected {
|
| 35 | 35 |
return |
| 36 | 36 |
} |
| 37 |
- assert.Equal(c, out, prev) |
|
| 37 |
+ assert.Equal(t, out, prev) |
|
| 38 | 38 |
if out != prev {
|
| 39 | 39 |
return |
| 40 | 40 |
} |
| ... | ... |
@@ -42,11 +42,11 @@ func waitForHealthStatus(c *testing.T, name string, prev string, expected string |
| 42 | 42 |
} |
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 |
-func getHealth(c *testing.T, name string) *container.Health {
|
|
| 46 |
- out := cli.DockerCmd(c, "inspect", "--format={{json .State.Health}}", name).Stdout()
|
|
| 45 |
+func getHealth(t *testing.T, name string) *container.Health {
|
|
| 46 |
+ out := cli.DockerCmd(t, "inspect", "--format={{json .State.Health}}", name).Stdout()
|
|
| 47 | 47 |
var health container.Health |
| 48 | 48 |
err := json.Unmarshal([]byte(out), &health) |
| 49 |
- assert.Equal(c, err, nil) |
|
| 49 |
+ assert.Equal(t, err, nil) |
|
| 50 | 50 |
return &health |
| 51 | 51 |
} |
| 52 | 52 |
|
| ... | ... |
@@ -18,12 +18,12 @@ type DockerCLIHistorySuite struct {
|
| 18 | 18 |
ds *DockerSuite |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (s *DockerCLIHistorySuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 22 |
- s.ds.TearDownTest(ctx, c) |
|
| 21 |
+func (s *DockerCLIHistorySuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 22 |
+ s.ds.TearDownTest(ctx, t) |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
-func (s *DockerCLIHistorySuite) OnTimeout(c *testing.T) {
|
|
| 26 |
- s.ds.OnTimeout(c) |
|
| 25 |
+func (s *DockerCLIHistorySuite) OnTimeout(t *testing.T) {
|
|
| 26 |
+ s.ds.OnTimeout(t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
// This is a heisen-test. Because the created timestamp of images and the behavior of |
| ... | ... |
@@ -23,12 +23,12 @@ type DockerCLIImagesSuite struct {
|
| 23 | 23 |
ds *DockerSuite |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-func (s *DockerCLIImagesSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 27 |
- s.ds.TearDownTest(ctx, c) |
|
| 26 |
+func (s *DockerCLIImagesSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 27 |
+ s.ds.TearDownTest(ctx, t) |
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-func (s *DockerCLIImagesSuite) OnTimeout(c *testing.T) {
|
|
| 31 |
- s.ds.OnTimeout(c) |
|
| 30 |
+func (s *DockerCLIImagesSuite) OnTimeout(t *testing.T) {
|
|
| 31 |
+ s.ds.OnTimeout(t) |
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 | 34 |
func (s *DockerCLIImagesSuite) TestImagesEnsureImageIsListed(c *testing.T) {
|
| ... | ... |
@@ -18,12 +18,12 @@ type DockerCLIImportSuite struct {
|
| 18 | 18 |
ds *DockerSuite |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (s *DockerCLIImportSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 22 |
- s.ds.TearDownTest(ctx, c) |
|
| 21 |
+func (s *DockerCLIImportSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 22 |
+ s.ds.TearDownTest(ctx, t) |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
-func (s *DockerCLIImportSuite) OnTimeout(c *testing.T) {
|
|
| 26 |
- s.ds.OnTimeout(c) |
|
| 25 |
+func (s *DockerCLIImportSuite) OnTimeout(t *testing.T) {
|
|
| 26 |
+ s.ds.OnTimeout(t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
func (s *DockerCLIImportSuite) TestImportDisplay(c *testing.T) {
|
| ... | ... |
@@ -16,12 +16,12 @@ type DockerCLIInfoSuite struct {
|
| 16 | 16 |
ds *DockerSuite |
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 |
-func (s *DockerCLIInfoSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 20 |
- s.ds.TearDownTest(ctx, c) |
|
| 19 |
+func (s *DockerCLIInfoSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 20 |
+ s.ds.TearDownTest(ctx, t) |
|
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
-func (s *DockerCLIInfoSuite) OnTimeout(c *testing.T) {
|
|
| 24 |
- s.ds.OnTimeout(c) |
|
| 23 |
+func (s *DockerCLIInfoSuite) OnTimeout(t *testing.T) {
|
|
| 24 |
+ s.ds.OnTimeout(t) |
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 | 27 |
// ensure docker info succeeds |
| ... | ... |
@@ -114,11 +114,11 @@ func (s *DockerCLIInfoSuite) TestInfoDisplaysStoppedContainers(c *testing.T) {
|
| 114 | 114 |
assert.Assert(c, is.Contains(out, fmt.Sprintf(" Stopped: %d\n", existing["ContainersStopped"]+1)))
|
| 115 | 115 |
} |
| 116 | 116 |
|
| 117 |
-func existingContainerStates(c *testing.T) map[string]int {
|
|
| 118 |
- out := cli.DockerCmd(c, "info", "--format", "{{json .}}").Stdout()
|
|
| 117 |
+func existingContainerStates(t *testing.T) map[string]int {
|
|
| 118 |
+ out := cli.DockerCmd(t, "info", "--format", "{{json .}}").Stdout()
|
|
| 119 | 119 |
var m map[string]interface{}
|
| 120 | 120 |
err := json.Unmarshal([]byte(out), &m) |
| 121 |
- assert.NilError(c, err) |
|
| 121 |
+ assert.NilError(t, err) |
|
| 122 | 122 |
res := map[string]int{}
|
| 123 | 123 |
res["Containers"] = int(m["Containers"].(float64)) |
| 124 | 124 |
res["ContainersRunning"] = int(m["ContainersRunning"].(float64)) |
| ... | ... |
@@ -23,12 +23,12 @@ type DockerCLIInspectSuite struct {
|
| 23 | 23 |
ds *DockerSuite |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-func (s *DockerCLIInspectSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 27 |
- s.ds.TearDownTest(ctx, c) |
|
| 26 |
+func (s *DockerCLIInspectSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 27 |
+ s.ds.TearDownTest(ctx, t) |
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
-func (s *DockerCLIInspectSuite) OnTimeout(c *testing.T) {
|
|
| 31 |
- s.ds.OnTimeout(c) |
|
| 30 |
+func (s *DockerCLIInspectSuite) OnTimeout(t *testing.T) {
|
|
| 31 |
+ s.ds.OnTimeout(t) |
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 | 34 |
func (s *DockerCLIInspectSuite) TestInspectImage(c *testing.T) {
|
| ... | ... |
@@ -19,12 +19,12 @@ type DockerCLILinksSuite struct {
|
| 19 | 19 |
ds *DockerSuite |
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
-func (s *DockerCLILinksSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 23 |
- s.ds.TearDownTest(ctx, c) |
|
| 22 |
+func (s *DockerCLILinksSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 23 |
+ s.ds.TearDownTest(ctx, t) |
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-func (s *DockerCLILinksSuite) OnTimeout(c *testing.T) {
|
|
| 27 |
- s.ds.OnTimeout(c) |
|
| 26 |
+func (s *DockerCLILinksSuite) OnTimeout(t *testing.T) {
|
|
| 27 |
+ s.ds.OnTimeout(t) |
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 | 30 |
func (s *DockerCLILinksSuite) TestLinksPingUnlinkedContainers(c *testing.T) {
|
| ... | ... |
@@ -53,7 +53,7 @@ func (s *DockerCLILinksSuite) TestLinksPingLinkedContainers(c *testing.T) {
|
| 53 | 53 |
testLinkPingOnNetwork(c, "bridge") |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 |
-func testLinkPingOnNetwork(c *testing.T, network string) {
|
|
| 56 |
+func testLinkPingOnNetwork(t *testing.T, network string) {
|
|
| 57 | 57 |
var postArgs []string |
| 58 | 58 |
if network != "" {
|
| 59 | 59 |
postArgs = append(postArgs, []string{"--net", network}...)
|
| ... | ... |
@@ -63,8 +63,8 @@ func testLinkPingOnNetwork(c *testing.T, network string) {
|
| 63 | 63 |
runArgs2 := append([]string{"run", "-d", "--name", "container2", "--hostname", "wilma"}, postArgs...)
|
| 64 | 64 |
|
| 65 | 65 |
// Run the two named containers |
| 66 |
- cli.DockerCmd(c, runArgs1...) |
|
| 67 |
- cli.DockerCmd(c, runArgs2...) |
|
| 66 |
+ cli.DockerCmd(t, runArgs1...) |
|
| 67 |
+ cli.DockerCmd(t, runArgs2...) |
|
| 68 | 68 |
|
| 69 | 69 |
postArgs = []string{}
|
| 70 | 70 |
if network != "" {
|
| ... | ... |
@@ -78,15 +78,15 @@ func testLinkPingOnNetwork(c *testing.T, network string) {
|
| 78 | 78 |
|
| 79 | 79 |
// test ping by alias, ping by name, and ping by hostname |
| 80 | 80 |
// 1. Ping by alias |
| 81 |
- cli.DockerCmd(c, append(runArgs, fmt.Sprintf(pingCmd, "alias1", "alias2"))...) |
|
| 81 |
+ cli.DockerCmd(t, append(runArgs, fmt.Sprintf(pingCmd, "alias1", "alias2"))...) |
|
| 82 | 82 |
// 2. Ping by container name |
| 83 |
- cli.DockerCmd(c, append(runArgs, fmt.Sprintf(pingCmd, "container1", "container2"))...) |
|
| 83 |
+ cli.DockerCmd(t, append(runArgs, fmt.Sprintf(pingCmd, "container1", "container2"))...) |
|
| 84 | 84 |
// 3. Ping by hostname |
| 85 |
- cli.DockerCmd(c, append(runArgs, fmt.Sprintf(pingCmd, "fred", "wilma"))...) |
|
| 85 |
+ cli.DockerCmd(t, append(runArgs, fmt.Sprintf(pingCmd, "fred", "wilma"))...) |
|
| 86 | 86 |
|
| 87 | 87 |
// Clean for next round |
| 88 |
- cli.DockerCmd(c, "rm", "-f", "container1") |
|
| 89 |
- cli.DockerCmd(c, "rm", "-f", "container2") |
|
| 88 |
+ cli.DockerCmd(t, "rm", "-f", "container1") |
|
| 89 |
+ cli.DockerCmd(t, "rm", "-f", "container2") |
|
| 90 | 90 |
} |
| 91 | 91 |
|
| 92 | 92 |
func (s *DockerCLILinksSuite) TestLinksPingLinkedContainersAfterRename(c *testing.T) {
|
| ... | ... |
@@ -15,12 +15,12 @@ type DockerCLILoginSuite struct {
|
| 15 | 15 |
ds *DockerSuite |
| 16 | 16 |
} |
| 17 | 17 |
|
| 18 |
-func (s *DockerCLILoginSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 19 |
- s.ds.TearDownTest(ctx, c) |
|
| 18 |
+func (s *DockerCLILoginSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 19 |
+ s.ds.TearDownTest(ctx, t) |
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
-func (s *DockerCLILoginSuite) OnTimeout(c *testing.T) {
|
|
| 23 |
- s.ds.OnTimeout(c) |
|
| 22 |
+func (s *DockerCLILoginSuite) OnTimeout(t *testing.T) {
|
|
| 23 |
+ s.ds.OnTimeout(t) |
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
func (s *DockerCLILoginSuite) TestLoginWithoutTTY(c *testing.T) {
|
| ... | ... |
@@ -24,12 +24,12 @@ type DockerCLILogsSuite struct {
|
| 24 | 24 |
ds *DockerSuite |
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
-func (s *DockerCLILogsSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 28 |
- s.ds.TearDownTest(ctx, c) |
|
| 27 |
+func (s *DockerCLILogsSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 28 |
+ s.ds.TearDownTest(ctx, t) |
|
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
-func (s *DockerCLILogsSuite) OnTimeout(c *testing.T) {
|
|
| 32 |
- s.ds.OnTimeout(c) |
|
| 31 |
+func (s *DockerCLILogsSuite) OnTimeout(t *testing.T) {
|
|
| 32 |
+ s.ds.OnTimeout(t) |
|
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 | 35 |
// This used to work, it test a log of PageSize-1 (gh#4851) |
| ... | ... |
@@ -47,12 +47,12 @@ func (s *DockerCLILogsSuite) TestLogsContainerMuchBiggerThanPage(c *testing.T) {
|
| 47 | 47 |
testLogsContainerPagination(c, 33000) |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
-func testLogsContainerPagination(c *testing.T, testLen int) {
|
|
| 51 |
- id := cli.DockerCmd(c, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n = >> a.a; done; echo >> a.a; cat a.a", testLen)).Stdout()
|
|
| 50 |
+func testLogsContainerPagination(t *testing.T, testLen int) {
|
|
| 51 |
+ id := cli.DockerCmd(t, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n = >> a.a; done; echo >> a.a; cat a.a", testLen)).Stdout()
|
|
| 52 | 52 |
id = strings.TrimSpace(id) |
| 53 |
- cli.DockerCmd(c, "wait", id) |
|
| 54 |
- out := cli.DockerCmd(c, "logs", id).Combined() |
|
| 55 |
- assert.Equal(c, len(out), testLen+1) |
|
| 53 |
+ cli.DockerCmd(t, "wait", id) |
|
| 54 |
+ out := cli.DockerCmd(t, "logs", id).Combined() |
|
| 55 |
+ assert.Equal(t, len(out), testLen+1) |
|
| 56 | 56 |
} |
| 57 | 57 |
|
| 58 | 58 |
func (s *DockerCLILogsSuite) TestLogsTimestamps(c *testing.T) {
|
| ... | ... |
@@ -21,20 +21,20 @@ type DockerCLINetmodeSuite struct {
|
| 21 | 21 |
ds *DockerSuite |
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
-func (s *DockerCLINetmodeSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 25 |
- s.ds.TearDownTest(ctx, c) |
|
| 24 |
+func (s *DockerCLINetmodeSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 25 |
+ s.ds.TearDownTest(ctx, t) |
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 |
-func (s *DockerCLINetmodeSuite) OnTimeout(c *testing.T) {
|
|
| 29 |
- s.ds.OnTimeout(c) |
|
| 28 |
+func (s *DockerCLINetmodeSuite) OnTimeout(t *testing.T) {
|
|
| 29 |
+ s.ds.OnTimeout(t) |
|
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 | 32 |
// DockerCmdWithFail executes a docker command that is supposed to fail and returns |
| 33 | 33 |
// the output. If the command returns a Nil error, it will fail and stop the tests. |
| 34 |
-func dockerCmdWithFail(c *testing.T, args ...string) string {
|
|
| 35 |
- c.Helper() |
|
| 34 |
+func dockerCmdWithFail(t *testing.T, args ...string) string {
|
|
| 35 |
+ t.Helper() |
|
| 36 | 36 |
out, _, err := dockerCmdWithError(args...) |
| 37 |
- assert.Assert(c, err != nil, "%v", out) |
|
| 37 |
+ assert.Assert(t, err != nil, "%v", out) |
|
| 38 | 38 |
return out |
| 39 | 39 |
} |
| 40 | 40 |
|
| ... | ... |
@@ -12,12 +12,12 @@ type DockerCLINetworkSuite struct {
|
| 12 | 12 |
ds *DockerSuite |
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 |
-func (s *DockerCLINetworkSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 16 |
- s.ds.TearDownTest(ctx, c) |
|
| 15 |
+func (s *DockerCLINetworkSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 16 |
+ s.ds.TearDownTest(ctx, t) |
|
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 |
-func (s *DockerCLINetworkSuite) OnTimeout(c *testing.T) {
|
|
| 20 |
- s.ds.OnTimeout(c) |
|
| 19 |
+func (s *DockerCLINetworkSuite) OnTimeout(t *testing.T) {
|
|
| 20 |
+ s.ds.OnTimeout(t) |
|
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 | 23 |
type DockerNetworkSuite struct {
|
| ... | ... |
@@ -43,22 +43,22 @@ const ( |
| 43 | 43 |
|
| 44 | 44 |
var remoteDriverNetworkRequest remoteapi.CreateNetworkRequest |
| 45 | 45 |
|
| 46 |
-func (s *DockerNetworkSuite) SetUpTest(ctx context.Context, c *testing.T) {
|
|
| 47 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 46 |
+func (s *DockerNetworkSuite) SetUpTest(ctx context.Context, t *testing.T) {
|
|
| 47 |
+ s.d = daemon.New(t, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
-func (s *DockerNetworkSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 50 |
+func (s *DockerNetworkSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 51 | 51 |
if s.d != nil {
|
| 52 |
- s.d.Stop(c) |
|
| 53 |
- s.ds.TearDownTest(ctx, c) |
|
| 52 |
+ s.d.Stop(t) |
|
| 53 |
+ s.ds.TearDownTest(ctx, t) |
|
| 54 | 54 |
} |
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 |
-func (s *DockerNetworkSuite) SetUpSuite(ctx context.Context, c *testing.T) {
|
|
| 57 |
+func (s *DockerNetworkSuite) SetUpSuite(ctx context.Context, t *testing.T) {
|
|
| 58 | 58 |
mux := http.NewServeMux() |
| 59 | 59 |
s.server = httptest.NewServer(mux) |
| 60 |
- assert.Assert(c, s.server != nil, "Failed to start an HTTP Server") |
|
| 61 |
- setupRemoteNetworkDrivers(c, mux, s.server.URL, dummyNetworkDriver, dummyIPAMDriver) |
|
| 60 |
+ assert.Assert(t, s.server != nil, "Failed to start an HTTP Server") |
|
| 61 |
+ setupRemoteNetworkDrivers(t, mux, s.server.URL, dummyNetworkDriver, dummyIPAMDriver) |
|
| 62 | 62 |
} |
| 63 | 63 |
|
| 64 | 64 |
func setupRemoteNetworkDrivers(t *testing.T, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
| ... | ... |
@@ -238,7 +238,7 @@ func setupRemoteNetworkDrivers(t *testing.T, mux *http.ServeMux, url, netDrv, ip |
| 238 | 238 |
assert.NilError(t, err) |
| 239 | 239 |
} |
| 240 | 240 |
|
| 241 |
-func (s *DockerNetworkSuite) TearDownSuite(ctx context.Context, c *testing.T) {
|
|
| 241 |
+func (s *DockerNetworkSuite) TearDownSuite(ctx context.Context, t *testing.T) {
|
|
| 242 | 242 |
if s.server == nil {
|
| 243 | 243 |
return |
| 244 | 244 |
} |
| ... | ... |
@@ -246,23 +246,23 @@ func (s *DockerNetworkSuite) TearDownSuite(ctx context.Context, c *testing.T) {
|
| 246 | 246 |
s.server.Close() |
| 247 | 247 |
|
| 248 | 248 |
err := os.RemoveAll("/etc/docker/plugins")
|
| 249 |
- assert.NilError(c, err) |
|
| 249 |
+ assert.NilError(t, err) |
|
| 250 | 250 |
} |
| 251 | 251 |
|
| 252 |
-func assertNwIsAvailable(c *testing.T, name string) {
|
|
| 253 |
- if !isNwPresent(c, name) {
|
|
| 254 |
- c.Fatalf("Network %s not found in network ls o/p", name)
|
|
| 252 |
+func assertNwIsAvailable(t *testing.T, name string) {
|
|
| 253 |
+ if !isNwPresent(t, name) {
|
|
| 254 |
+ t.Fatalf("Network %s not found in network ls o/p", name)
|
|
| 255 | 255 |
} |
| 256 | 256 |
} |
| 257 | 257 |
|
| 258 |
-func assertNwNotAvailable(c *testing.T, name string) {
|
|
| 259 |
- if isNwPresent(c, name) {
|
|
| 260 |
- c.Fatalf("Found network %s in network ls o/p", name)
|
|
| 258 |
+func assertNwNotAvailable(t *testing.T, name string) {
|
|
| 259 |
+ if isNwPresent(t, name) {
|
|
| 260 |
+ t.Fatalf("Found network %s in network ls o/p", name)
|
|
| 261 | 261 |
} |
| 262 | 262 |
} |
| 263 | 263 |
|
| 264 |
-func isNwPresent(c *testing.T, name string) bool {
|
|
| 265 |
- out := cli.DockerCmd(c, "network", "ls").Stdout() |
|
| 264 |
+func isNwPresent(t *testing.T, name string) bool {
|
|
| 265 |
+ out := cli.DockerCmd(t, "network", "ls").Stdout() |
|
| 266 | 266 |
lines := strings.Split(out, "\n") |
| 267 | 267 |
for i := 1; i < len(lines)-1; i++ {
|
| 268 | 268 |
netFields := strings.Fields(lines[i]) |
| ... | ... |
@@ -276,7 +276,7 @@ func isNwPresent(c *testing.T, name string) bool {
|
| 276 | 276 |
// assertNwList checks network list retrieved with ls command |
| 277 | 277 |
// equals to expected network list |
| 278 | 278 |
// note: out should be `network ls [option]` result |
| 279 |
-func assertNwList(c *testing.T, out string, expectNws []string) {
|
|
| 279 |
+func assertNwList(t *testing.T, out string, expectNws []string) {
|
|
| 280 | 280 |
lines := strings.Split(out, "\n") |
| 281 | 281 |
var nwList []string |
| 282 | 282 |
for _, line := range lines[1 : len(lines)-1] {
|
| ... | ... |
@@ -286,14 +286,14 @@ func assertNwList(c *testing.T, out string, expectNws []string) {
|
| 286 | 286 |
} |
| 287 | 287 |
|
| 288 | 288 |
// network ls should contains all expected networks |
| 289 |
- assert.DeepEqual(c, nwList, expectNws) |
|
| 289 |
+ assert.DeepEqual(t, nwList, expectNws) |
|
| 290 | 290 |
} |
| 291 | 291 |
|
| 292 |
-func getNwResource(c *testing.T, name string) *network.Inspect {
|
|
| 293 |
- out := cli.DockerCmd(c, "network", "inspect", name).Stdout() |
|
| 292 |
+func getNwResource(t *testing.T, name string) *network.Inspect {
|
|
| 293 |
+ out := cli.DockerCmd(t, "network", "inspect", name).Stdout() |
|
| 294 | 294 |
var nr []network.Inspect |
| 295 | 295 |
err := json.Unmarshal([]byte(out), &nr) |
| 296 |
- assert.NilError(c, err) |
|
| 296 |
+ assert.NilError(t, err) |
|
| 297 | 297 |
return &nr[0] |
| 298 | 298 |
} |
| 299 | 299 |
|
| ... | ... |
@@ -1051,26 +1051,26 @@ func (s *DockerCLINetworkSuite) TestInspectAPIMultipleNetworks(c *testing.T) {
|
| 1051 | 1051 |
assert.Equal(c, bridge.IPAddress, inspectCurrent.NetworkSettings.IPAddress) |
| 1052 | 1052 |
} |
| 1053 | 1053 |
|
| 1054 |
-func connectContainerToNetworks(c *testing.T, d *daemon.Daemon, cName string, nws []string) {
|
|
| 1054 |
+func connectContainerToNetworks(t *testing.T, d *daemon.Daemon, cName string, nws []string) {
|
|
| 1055 | 1055 |
// Run a container on the default network |
| 1056 | 1056 |
out, err := d.Cmd("run", "-d", "--name", cName, "busybox", "top")
|
| 1057 |
- assert.NilError(c, err, out) |
|
| 1057 |
+ assert.NilError(t, err, out) |
|
| 1058 | 1058 |
|
| 1059 | 1059 |
// Attach the container to other networks |
| 1060 | 1060 |
for _, nw := range nws {
|
| 1061 | 1061 |
out, err = d.Cmd("network", "create", nw)
|
| 1062 |
- assert.NilError(c, err, out) |
|
| 1062 |
+ assert.NilError(t, err, out) |
|
| 1063 | 1063 |
out, err = d.Cmd("network", "connect", nw, cName)
|
| 1064 |
- assert.NilError(c, err, out) |
|
| 1064 |
+ assert.NilError(t, err, out) |
|
| 1065 | 1065 |
} |
| 1066 | 1066 |
} |
| 1067 | 1067 |
|
| 1068 |
-func verifyContainerIsConnectedToNetworks(c *testing.T, d *daemon.Daemon, cName string, nws []string) {
|
|
| 1068 |
+func verifyContainerIsConnectedToNetworks(t *testing.T, d *daemon.Daemon, cName string, nws []string) {
|
|
| 1069 | 1069 |
// Verify container is connected to all the networks |
| 1070 | 1070 |
for _, nw := range nws {
|
| 1071 | 1071 |
out, err := d.Cmd("inspect", "-f", fmt.Sprintf("{{.NetworkSettings.Networks.%s}}", nw), cName)
|
| 1072 |
- assert.NilError(c, err, out) |
|
| 1073 |
- assert.Assert(c, out != "<no value>\n") |
|
| 1072 |
+ assert.NilError(t, err, out) |
|
| 1073 |
+ assert.Assert(t, out != "<no value>\n") |
|
| 1074 | 1074 |
} |
| 1075 | 1075 |
} |
| 1076 | 1076 |
|
| ... | ... |
@@ -1173,12 +1173,12 @@ func (s *DockerNetworkSuite) TestDockerNetworkConnectWithPortMapping(c *testing. |
| 1173 | 1173 |
cli.DockerCmd(c, "network", "connect", "test1", "c1") |
| 1174 | 1174 |
} |
| 1175 | 1175 |
|
| 1176 |
-func verifyPortMap(c *testing.T, container, port, originalMapping string, mustBeEqual bool) {
|
|
| 1177 |
- currentMapping := cli.DockerCmd(c, "port", container, port).Stdout() |
|
| 1176 |
+func verifyPortMap(t *testing.T, container, port, originalMapping string, mustBeEqual bool) {
|
|
| 1177 |
+ currentMapping := cli.DockerCmd(t, "port", container, port).Stdout() |
|
| 1178 | 1178 |
if mustBeEqual {
|
| 1179 |
- assert.Equal(c, currentMapping, originalMapping) |
|
| 1179 |
+ assert.Equal(t, currentMapping, originalMapping) |
|
| 1180 | 1180 |
} else {
|
| 1181 |
- assert.Assert(c, currentMapping != originalMapping) |
|
| 1181 |
+ assert.Assert(t, currentMapping != originalMapping) |
|
| 1182 | 1182 |
} |
| 1183 | 1183 |
} |
| 1184 | 1184 |
|
| ... | ... |
@@ -1370,30 +1370,30 @@ func (s *DockerNetworkSuite) TestDockerNetworkUnsupportedRequiredIP(c *testing.T |
| 1370 | 1370 |
assertNwNotAvailable(c, "n0") |
| 1371 | 1371 |
} |
| 1372 | 1372 |
|
| 1373 |
-func checkUnsupportedNetworkAndIP(c *testing.T, nwMode string) {
|
|
| 1373 |
+func checkUnsupportedNetworkAndIP(t *testing.T, nwMode string) {
|
|
| 1374 | 1374 |
out, _, err := dockerCmdWithError("run", "-d", "--net", nwMode, "--ip", "172.28.99.88", "--ip6", "2001:db8:1234::9988", "busybox", "top")
|
| 1375 |
- assert.Assert(c, err != nil, "out: %s", out) |
|
| 1376 |
- assert.Assert(c, is.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error())) |
|
| 1375 |
+ assert.Assert(t, err != nil, "out: %s", out) |
|
| 1376 |
+ assert.Assert(t, is.Contains(out, runconfig.ErrUnsupportedNetworkAndIP.Error())) |
|
| 1377 | 1377 |
} |
| 1378 | 1378 |
|
| 1379 |
-func verifyIPAddressConfig(c *testing.T, cName, nwname, ipv4, ipv6 string) {
|
|
| 1379 |
+func verifyIPAddressConfig(t *testing.T, cName, nwname, ipv4, ipv6 string) {
|
|
| 1380 | 1380 |
if ipv4 != "" {
|
| 1381 |
- out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv4Address", nwname))
|
|
| 1382 |
- assert.Equal(c, strings.TrimSpace(out), ipv4) |
|
| 1381 |
+ out := inspectField(t, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv4Address", nwname))
|
|
| 1382 |
+ assert.Equal(t, strings.TrimSpace(out), ipv4) |
|
| 1383 | 1383 |
} |
| 1384 | 1384 |
|
| 1385 | 1385 |
if ipv6 != "" {
|
| 1386 |
- out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv6Address", nwname))
|
|
| 1387 |
- assert.Equal(c, strings.TrimSpace(out), ipv6) |
|
| 1386 |
+ out := inspectField(t, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAMConfig.IPv6Address", nwname))
|
|
| 1387 |
+ assert.Equal(t, strings.TrimSpace(out), ipv6) |
|
| 1388 | 1388 |
} |
| 1389 | 1389 |
} |
| 1390 | 1390 |
|
| 1391 |
-func verifyIPAddresses(c *testing.T, cName, nwname, ipv4, ipv6 string) {
|
|
| 1392 |
- out := inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAddress", nwname))
|
|
| 1393 |
- assert.Equal(c, strings.TrimSpace(out), ipv4) |
|
| 1391 |
+func verifyIPAddresses(t *testing.T, cName, nwname, ipv4, ipv6 string) {
|
|
| 1392 |
+ out := inspectField(t, cName, fmt.Sprintf("NetworkSettings.Networks.%s.IPAddress", nwname))
|
|
| 1393 |
+ assert.Equal(t, strings.TrimSpace(out), ipv4) |
|
| 1394 | 1394 |
|
| 1395 |
- out = inspectField(c, cName, fmt.Sprintf("NetworkSettings.Networks.%s.GlobalIPv6Address", nwname))
|
|
| 1396 |
- assert.Equal(c, strings.TrimSpace(out), ipv6) |
|
| 1395 |
+ out = inspectField(t, cName, fmt.Sprintf("NetworkSettings.Networks.%s.GlobalIPv6Address", nwname))
|
|
| 1396 |
+ assert.Equal(t, strings.TrimSpace(out), ipv6) |
|
| 1397 | 1397 |
} |
| 1398 | 1398 |
|
| 1399 | 1399 |
func (s *DockerNetworkSuite) TestDockerNetworkConnectLinkLocalIP(c *testing.T) {
|
| ... | ... |
@@ -16,12 +16,12 @@ type DockerCLIPluginLogDriverSuite struct {
|
| 16 | 16 |
ds *DockerSuite |
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 |
-func (s *DockerCLIPluginLogDriverSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 20 |
- s.ds.TearDownTest(ctx, c) |
|
| 19 |
+func (s *DockerCLIPluginLogDriverSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 20 |
+ s.ds.TearDownTest(ctx, t) |
|
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
-func (s *DockerCLIPluginLogDriverSuite) OnTimeout(c *testing.T) {
|
|
| 24 |
- s.ds.OnTimeout(c) |
|
| 23 |
+func (s *DockerCLIPluginLogDriverSuite) OnTimeout(t *testing.T) {
|
|
| 24 |
+ s.ds.OnTimeout(t) |
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 | 27 |
func (s *DockerCLIPluginLogDriverSuite) TestPluginLogDriver(c *testing.T) {
|
| ... | ... |
@@ -35,12 +35,12 @@ type DockerCLIPluginsSuite struct {
|
| 35 | 35 |
ds *DockerSuite |
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 |
-func (s *DockerCLIPluginsSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 39 |
- s.ds.TearDownTest(ctx, c) |
|
| 38 |
+func (s *DockerCLIPluginsSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 39 |
+ s.ds.TearDownTest(ctx, t) |
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 |
-func (s *DockerCLIPluginsSuite) OnTimeout(c *testing.T) {
|
|
| 43 |
- s.ds.OnTimeout(c) |
|
| 42 |
+func (s *DockerCLIPluginsSuite) OnTimeout(t *testing.T) {
|
|
| 43 |
+ s.ds.OnTimeout(t) |
|
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 | 46 |
func (ps *DockerPluginSuite) TestPluginBasicOps(c *testing.T) {
|
| ... | ... |
@@ -19,12 +19,12 @@ type DockerCLIPortSuite struct {
|
| 19 | 19 |
ds *DockerSuite |
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
-func (s *DockerCLIPortSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 23 |
- s.ds.TearDownTest(ctx, c) |
|
| 22 |
+func (s *DockerCLIPortSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 23 |
+ s.ds.TearDownTest(ctx, t) |
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-func (s *DockerCLIPortSuite) OnTimeout(c *testing.T) {
|
|
| 27 |
- s.ds.OnTimeout(c) |
|
| 26 |
+func (s *DockerCLIPortSuite) OnTimeout(t *testing.T) {
|
|
| 27 |
+ s.ds.OnTimeout(t) |
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 | 30 |
func (s *DockerCLIPortSuite) TestPortList(c *testing.T) {
|
| ... | ... |
@@ -163,10 +163,10 @@ func (s *DockerCLIPortSuite) TestPortList(c *testing.T) {
|
| 163 | 163 |
cli.DockerCmd(c, "rm", "-f", id) |
| 164 | 164 |
} |
| 165 | 165 |
|
| 166 |
-func assertPortList(c *testing.T, out string, expected []string) {
|
|
| 167 |
- c.Helper() |
|
| 166 |
+func assertPortList(t *testing.T, out string, expected []string) {
|
|
| 167 |
+ t.Helper() |
|
| 168 | 168 |
lines := strings.Split(strings.Trim(out, "\n "), "\n") |
| 169 |
- assert.Assert(c, is.Len(lines, len(expected)), "expected: %s", strings.Join(expected, ", ")) |
|
| 169 |
+ assert.Assert(t, is.Len(lines, len(expected)), "expected: %s", strings.Join(expected, ", ")) |
|
| 170 | 170 |
|
| 171 | 171 |
sort.Strings(lines) |
| 172 | 172 |
sort.Strings(expected) |
| ... | ... |
@@ -184,7 +184,7 @@ func assertPortList(c *testing.T, out string, expected []string) {
|
| 184 | 184 |
if lines[i] == expected[i] {
|
| 185 | 185 |
continue |
| 186 | 186 |
} |
| 187 |
- assert.Equal(c, lines[i], oldFormat(expected[i])) |
|
| 187 |
+ assert.Equal(t, lines[i], oldFormat(expected[i])) |
|
| 188 | 188 |
} |
| 189 | 189 |
} |
| 190 | 190 |
|
| ... | ... |
@@ -233,8 +233,8 @@ func assertPortRange(ctx context.Context, id string, expectedTCP, expectedUDP [] |
| 233 | 233 |
return nil |
| 234 | 234 |
} |
| 235 | 235 |
|
| 236 |
-func stopRemoveContainer(id string, c *testing.T) {
|
|
| 237 |
- cli.DockerCmd(c, "rm", "-f", id) |
|
| 236 |
+func stopRemoveContainer(id string, t *testing.T) {
|
|
| 237 |
+ cli.DockerCmd(t, "rm", "-f", id) |
|
| 238 | 238 |
} |
| 239 | 239 |
|
| 240 | 240 |
func (s *DockerCLIPortSuite) TestUnpublishedPortsInPsOutput(c *testing.T) {
|
| ... | ... |
@@ -14,12 +14,12 @@ type DockerCLIProxySuite struct {
|
| 14 | 14 |
ds *DockerSuite |
| 15 | 15 |
} |
| 16 | 16 |
|
| 17 |
-func (s *DockerCLIProxySuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 18 |
- s.ds.TearDownTest(ctx, c) |
|
| 17 |
+func (s *DockerCLIProxySuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 18 |
+ s.ds.TearDownTest(ctx, t) |
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (s *DockerCLIProxySuite) OnTimeout(c *testing.T) {
|
|
| 22 |
- s.ds.OnTimeout(c) |
|
| 21 |
+func (s *DockerCLIProxySuite) OnTimeout(t *testing.T) {
|
|
| 22 |
+ s.ds.OnTimeout(t) |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
func (s *DockerCLIProxySuite) TestCLIProxyDisableProxyUnixSock(c *testing.T) {
|
| ... | ... |
@@ -22,30 +22,30 @@ import ( |
| 22 | 22 |
"gotest.tools/v3/poll" |
| 23 | 23 |
) |
| 24 | 24 |
|
| 25 |
-func (s *DockerCLIPruneSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 26 |
- s.ds.TearDownTest(ctx, c) |
|
| 25 |
+func (s *DockerCLIPruneSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 26 |
+ s.ds.TearDownTest(ctx, t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
-func (s *DockerCLIPruneSuite) OnTimeout(c *testing.T) {
|
|
| 30 |
- s.ds.OnTimeout(c) |
|
| 29 |
+func (s *DockerCLIPruneSuite) OnTimeout(t *testing.T) {
|
|
| 30 |
+ s.ds.OnTimeout(t) |
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 |
-func pruneNetworkAndVerify(c *testing.T, d *daemon.Daemon, kept, pruned []string) {
|
|
| 33 |
+func pruneNetworkAndVerify(t *testing.T, d *daemon.Daemon, kept, pruned []string) {
|
|
| 34 | 34 |
_, err := d.Cmd("network", "prune", "--force")
|
| 35 |
- assert.NilError(c, err) |
|
| 35 |
+ assert.NilError(t, err) |
|
| 36 | 36 |
|
| 37 | 37 |
for _, s := range kept {
|
| 38 |
- poll.WaitOn(c, pollCheck(c, func(*testing.T) (interface{}, string) {
|
|
| 38 |
+ poll.WaitOn(t, pollCheck(t, func(*testing.T) (interface{}, string) {
|
|
| 39 | 39 |
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
|
| 40 |
- assert.NilError(c, err) |
|
| 40 |
+ assert.NilError(t, err) |
|
| 41 | 41 |
return out, "" |
| 42 | 42 |
}, checker.Contains(s)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 | 45 |
for _, s := range pruned {
|
| 46 |
- poll.WaitOn(c, pollCheck(c, func(*testing.T) (interface{}, string) {
|
|
| 46 |
+ poll.WaitOn(t, pollCheck(t, func(*testing.T) (interface{}, string) {
|
|
| 47 | 47 |
out, err := d.Cmd("network", "ls", "--format", "{{.Name}}")
|
| 48 |
- assert.NilError(c, err) |
|
| 48 |
+ assert.NilError(t, err) |
|
| 49 | 49 |
return out, "" |
| 50 | 50 |
}, checker.Not(checker.Contains(s))), poll.WithTimeout(defaultReconciliationTimeout)) |
| 51 | 51 |
} |
| ... | ... |
@@ -22,12 +22,12 @@ type DockerCLIPsSuite struct {
|
| 22 | 22 |
ds *DockerSuite |
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
-func (s *DockerCLIPsSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 26 |
- s.ds.TearDownTest(ctx, c) |
|
| 25 |
+func (s *DockerCLIPsSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 26 |
+ s.ds.TearDownTest(ctx, t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
-func (s *DockerCLIPsSuite) OnTimeout(c *testing.T) {
|
|
| 30 |
- s.ds.OnTimeout(c) |
|
| 29 |
+func (s *DockerCLIPsSuite) OnTimeout(t *testing.T) {
|
|
| 30 |
+ s.ds.OnTimeout(t) |
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
func (s *DockerCLIPsSuite) TestPsListContainersBase(c *testing.T) {
|
| ... | ... |
@@ -391,7 +391,7 @@ func (s *DockerCLIPsSuite) TestPsListContainersFilterAncestorImage(c *testing.T) |
| 391 | 391 |
checkPsAncestorFilterOutput(c, RemoveOutputForExistingElements(out, existingContainers), imageName2+","+imageName1Tagged, []string{fourthID, fifthID})
|
| 392 | 392 |
} |
| 393 | 393 |
|
| 394 |
-func checkPsAncestorFilterOutput(c *testing.T, out string, filterName string, expectedIDs []string) {
|
|
| 394 |
+func checkPsAncestorFilterOutput(t *testing.T, out string, filterName string, expectedIDs []string) {
|
|
| 395 | 395 |
var actualIDs []string |
| 396 | 396 |
if out != "" {
|
| 397 | 397 |
actualIDs = strings.Split(out[:len(out)-1], "\n") |
| ... | ... |
@@ -399,17 +399,17 @@ func checkPsAncestorFilterOutput(c *testing.T, out string, filterName string, ex |
| 399 | 399 |
sort.Strings(actualIDs) |
| 400 | 400 |
sort.Strings(expectedIDs) |
| 401 | 401 |
|
| 402 |
- assert.Equal(c, len(actualIDs), len(expectedIDs), fmt.Sprintf("Expected filtered container(s) for %s ancestor filter to be %v:%v, got %v:%v", filterName, len(expectedIDs), expectedIDs, len(actualIDs), actualIDs))
|
|
| 402 |
+ assert.Equal(t, len(actualIDs), len(expectedIDs), fmt.Sprintf("Expected filtered container(s) for %s ancestor filter to be %v:%v, got %v:%v", filterName, len(expectedIDs), expectedIDs, len(actualIDs), actualIDs))
|
|
| 403 | 403 |
if len(expectedIDs) > 0 {
|
| 404 | 404 |
same := true |
| 405 | 405 |
for i := range expectedIDs {
|
| 406 | 406 |
if actualIDs[i] != expectedIDs[i] {
|
| 407 |
- c.Logf("%s, %s", actualIDs[i], expectedIDs[i])
|
|
| 407 |
+ t.Logf("%s, %s", actualIDs[i], expectedIDs[i])
|
|
| 408 | 408 |
same = false |
| 409 | 409 |
break |
| 410 | 410 |
} |
| 411 | 411 |
} |
| 412 |
- assert.Equal(c, same, true, fmt.Sprintf("Expected filtered container(s) for %s ancestor filter to be %v, got %v", filterName, expectedIDs, actualIDs))
|
|
| 412 |
+ assert.Equal(t, same, true, fmt.Sprintf("Expected filtered container(s) for %s ancestor filter to be %v, got %v", filterName, expectedIDs, actualIDs))
|
|
| 413 | 413 |
} |
| 414 | 414 |
} |
| 415 | 415 |
|
| ... | ... |
@@ -26,7 +26,7 @@ import ( |
| 26 | 26 |
// tags for the same image) are not also pulled down. |
| 27 | 27 |
// |
| 28 | 28 |
// Ref: docker/docker#8141 |
| 29 |
-func (s *DockerRegistrySuite) TestPullImageWithAliases(c *testing.T) {
|
|
| 29 |
+func (s *DockerRegistrySuite) TestPullImageWithAliases(t *testing.T) {
|
|
| 30 | 30 |
const imgRepo = privateRegistryURL + "/dockercli/busybox" |
| 31 | 31 |
|
| 32 | 32 |
var repos []string |
| ... | ... |
@@ -36,44 +36,44 @@ func (s *DockerRegistrySuite) TestPullImageWithAliases(c *testing.T) {
|
| 36 | 36 |
|
| 37 | 37 |
// Tag and push the same image multiple times. |
| 38 | 38 |
for _, repo := range repos {
|
| 39 |
- cli.DockerCmd(c, "tag", "busybox", repo) |
|
| 40 |
- cli.DockerCmd(c, "push", repo) |
|
| 39 |
+ cli.DockerCmd(t, "tag", "busybox", repo) |
|
| 40 |
+ cli.DockerCmd(t, "push", repo) |
|
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 | 43 |
// Clear local images store. |
| 44 | 44 |
args := append([]string{"rmi"}, repos...)
|
| 45 |
- cli.DockerCmd(c, args...) |
|
| 45 |
+ cli.DockerCmd(t, args...) |
|
| 46 | 46 |
|
| 47 | 47 |
// Pull a single tag and verify it doesn't bring down all aliases. |
| 48 |
- cli.DockerCmd(c, "pull", repos[0]) |
|
| 49 |
- cli.DockerCmd(c, "inspect", repos[0]) |
|
| 48 |
+ cli.DockerCmd(t, "pull", repos[0]) |
|
| 49 |
+ cli.DockerCmd(t, "inspect", repos[0]) |
|
| 50 | 50 |
for _, repo := range repos[1:] {
|
| 51 | 51 |
_, _, err := dockerCmdWithError("inspect", repo)
|
| 52 |
- assert.ErrorContains(c, err, "", "Image %v shouldn't have been pulled down", repo) |
|
| 52 |
+ assert.ErrorContains(t, err, "", "Image %v shouldn't have been pulled down", repo) |
|
| 53 | 53 |
} |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 | 56 |
// TestConcurrentPullWholeRepo pulls the same repo concurrently. |
| 57 |
-func (s *DockerRegistrySuite) TestConcurrentPullWholeRepo(c *testing.T) {
|
|
| 57 |
+func (s *DockerRegistrySuite) TestConcurrentPullWholeRepo(t *testing.T) {
|
|
| 58 | 58 |
const imgRepo = privateRegistryURL + "/dockercli/busybox" |
| 59 | 59 |
|
| 60 | 60 |
var repos []string |
| 61 | 61 |
for _, tag := range []string{"recent", "fresh", "todays"} {
|
| 62 | 62 |
repo := fmt.Sprintf("%v:%v", imgRepo, tag)
|
| 63 |
- buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(` |
|
| 63 |
+ buildImageSuccessfully(t, repo, build.WithDockerfile(fmt.Sprintf(` |
|
| 64 | 64 |
FROM busybox |
| 65 | 65 |
ENTRYPOINT ["/bin/echo"] |
| 66 | 66 |
ENV FOO foo |
| 67 | 67 |
ENV BAR bar |
| 68 | 68 |
CMD echo %s |
| 69 | 69 |
`, repo))) |
| 70 |
- cli.DockerCmd(c, "push", repo) |
|
| 70 |
+ cli.DockerCmd(t, "push", repo) |
|
| 71 | 71 |
repos = append(repos, repo) |
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 | 74 |
// Clear local images store. |
| 75 | 75 |
args := append([]string{"rmi"}, repos...)
|
| 76 |
- cli.DockerCmd(c, args...) |
|
| 76 |
+ cli.DockerCmd(t, args...) |
|
| 77 | 77 |
|
| 78 | 78 |
// Run multiple re-pulls concurrently |
| 79 | 79 |
numPulls := 3 |
| ... | ... |
@@ -90,19 +90,19 @@ func (s *DockerRegistrySuite) TestConcurrentPullWholeRepo(c *testing.T) {
|
| 90 | 90 |
// package is not goroutine-safe. |
| 91 | 91 |
for i := 0; i != numPulls; i++ {
|
| 92 | 92 |
err := <-results |
| 93 |
- assert.NilError(c, err, "concurrent pull failed with error: %v", err) |
|
| 93 |
+ assert.NilError(t, err, "concurrent pull failed with error: %v", err) |
|
| 94 | 94 |
} |
| 95 | 95 |
|
| 96 | 96 |
// Ensure all tags were pulled successfully |
| 97 | 97 |
for _, repo := range repos {
|
| 98 |
- cli.DockerCmd(c, "inspect", repo) |
|
| 99 |
- out := cli.DockerCmd(c, "run", "--rm", repo).Combined() |
|
| 100 |
- assert.Equal(c, strings.TrimSpace(out), "/bin/sh -c echo "+repo) |
|
| 98 |
+ cli.DockerCmd(t, "inspect", repo) |
|
| 99 |
+ out := cli.DockerCmd(t, "run", "--rm", repo).Combined() |
|
| 100 |
+ assert.Equal(t, strings.TrimSpace(out), "/bin/sh -c echo "+repo) |
|
| 101 | 101 |
} |
| 102 | 102 |
} |
| 103 | 103 |
|
| 104 | 104 |
// TestConcurrentFailingPull tries a concurrent pull that doesn't succeed. |
| 105 |
-func (s *DockerRegistrySuite) TestConcurrentFailingPull(c *testing.T) {
|
|
| 105 |
+func (s *DockerRegistrySuite) TestConcurrentFailingPull(t *testing.T) {
|
|
| 106 | 106 |
const imgRepo = privateRegistryURL + "/dockercli/busybox" |
| 107 | 107 |
|
| 108 | 108 |
// Run multiple pulls concurrently |
| ... | ... |
@@ -120,32 +120,32 @@ func (s *DockerRegistrySuite) TestConcurrentFailingPull(c *testing.T) {
|
| 120 | 120 |
// package is not goroutine-safe. |
| 121 | 121 |
for i := 0; i != numPulls; i++ {
|
| 122 | 122 |
err := <-results |
| 123 |
- assert.ErrorContains(c, err, "", "expected pull to fail") |
|
| 123 |
+ assert.ErrorContains(t, err, "", "expected pull to fail") |
|
| 124 | 124 |
} |
| 125 | 125 |
} |
| 126 | 126 |
|
| 127 | 127 |
// TestConcurrentPullMultipleTags pulls multiple tags from the same repo |
| 128 | 128 |
// concurrently. |
| 129 |
-func (s *DockerRegistrySuite) TestConcurrentPullMultipleTags(c *testing.T) {
|
|
| 129 |
+func (s *DockerRegistrySuite) TestConcurrentPullMultipleTags(t *testing.T) {
|
|
| 130 | 130 |
const imgRepo = privateRegistryURL + "/dockercli/busybox" |
| 131 | 131 |
|
| 132 | 132 |
var repos []string |
| 133 | 133 |
for _, tag := range []string{"recent", "fresh", "todays"} {
|
| 134 | 134 |
repo := fmt.Sprintf("%v:%v", imgRepo, tag)
|
| 135 |
- buildImageSuccessfully(c, repo, build.WithDockerfile(fmt.Sprintf(` |
|
| 135 |
+ buildImageSuccessfully(t, repo, build.WithDockerfile(fmt.Sprintf(` |
|
| 136 | 136 |
FROM busybox |
| 137 | 137 |
ENTRYPOINT ["/bin/echo"] |
| 138 | 138 |
ENV FOO foo |
| 139 | 139 |
ENV BAR bar |
| 140 | 140 |
CMD echo %s |
| 141 | 141 |
`, repo))) |
| 142 |
- cli.DockerCmd(c, "push", repo) |
|
| 142 |
+ cli.DockerCmd(t, "push", repo) |
|
| 143 | 143 |
repos = append(repos, repo) |
| 144 | 144 |
} |
| 145 | 145 |
|
| 146 | 146 |
// Clear local images store. |
| 147 | 147 |
args := append([]string{"rmi"}, repos...)
|
| 148 |
- cli.DockerCmd(c, args...) |
|
| 148 |
+ cli.DockerCmd(t, args...) |
|
| 149 | 149 |
|
| 150 | 150 |
// Re-pull individual tags, in parallel |
| 151 | 151 |
results := make(chan error, len(repos)) |
| ... | ... |
@@ -161,24 +161,24 @@ func (s *DockerRegistrySuite) TestConcurrentPullMultipleTags(c *testing.T) {
|
| 161 | 161 |
// package is not goroutine-safe. |
| 162 | 162 |
for range repos {
|
| 163 | 163 |
err := <-results |
| 164 |
- assert.NilError(c, err, "concurrent pull failed with error: %v", err) |
|
| 164 |
+ assert.NilError(t, err, "concurrent pull failed with error: %v", err) |
|
| 165 | 165 |
} |
| 166 | 166 |
|
| 167 | 167 |
// Ensure all tags were pulled successfully |
| 168 | 168 |
for _, repo := range repos {
|
| 169 |
- cli.DockerCmd(c, "inspect", repo) |
|
| 170 |
- out := cli.DockerCmd(c, "run", "--rm", repo).Combined() |
|
| 171 |
- assert.Equal(c, strings.TrimSpace(out), "/bin/sh -c echo "+repo) |
|
| 169 |
+ cli.DockerCmd(t, "inspect", repo) |
|
| 170 |
+ out := cli.DockerCmd(t, "run", "--rm", repo).Combined() |
|
| 171 |
+ assert.Equal(t, strings.TrimSpace(out), "/bin/sh -c echo "+repo) |
|
| 172 | 172 |
} |
| 173 | 173 |
} |
| 174 | 174 |
|
| 175 | 175 |
// TestPullIDStability verifies that pushing an image and pulling it back |
| 176 | 176 |
// preserves the image ID. |
| 177 |
-func (s *DockerRegistrySuite) TestPullIDStability(c *testing.T) {
|
|
| 177 |
+func (s *DockerRegistrySuite) TestPullIDStability(t *testing.T) {
|
|
| 178 | 178 |
const derivedImage = privateRegistryURL + "/dockercli/id-stability" |
| 179 | 179 |
const baseImage = "busybox" |
| 180 | 180 |
|
| 181 |
- buildImageSuccessfully(c, derivedImage, build.WithDockerfile(fmt.Sprintf(` |
|
| 181 |
+ buildImageSuccessfully(t, derivedImage, build.WithDockerfile(fmt.Sprintf(` |
|
| 182 | 182 |
FROM %s |
| 183 | 183 |
ENV derived true |
| 184 | 184 |
ENV asdf true |
| ... | ... |
@@ -186,54 +186,54 @@ func (s *DockerRegistrySuite) TestPullIDStability(c *testing.T) {
|
| 186 | 186 |
CMD echo %s |
| 187 | 187 |
`, baseImage, derivedImage))) |
| 188 | 188 |
|
| 189 |
- originalID := getIDByName(c, derivedImage) |
|
| 190 |
- cli.DockerCmd(c, "push", derivedImage) |
|
| 189 |
+ originalID := getIDByName(t, derivedImage) |
|
| 190 |
+ cli.DockerCmd(t, "push", derivedImage) |
|
| 191 | 191 |
|
| 192 | 192 |
// Pull |
| 193 |
- out := cli.DockerCmd(c, "pull", derivedImage).Combined() |
|
| 193 |
+ out := cli.DockerCmd(t, "pull", derivedImage).Combined() |
|
| 194 | 194 |
if strings.Contains(out, "Pull complete") {
|
| 195 |
- c.Fatalf("repull redownloaded a layer: %s", out)
|
|
| 195 |
+ t.Fatalf("repull redownloaded a layer: %s", out)
|
|
| 196 | 196 |
} |
| 197 | 197 |
|
| 198 |
- derivedIDAfterPull := getIDByName(c, derivedImage) |
|
| 198 |
+ derivedIDAfterPull := getIDByName(t, derivedImage) |
|
| 199 | 199 |
|
| 200 | 200 |
if derivedIDAfterPull != originalID {
|
| 201 |
- c.Fatal("image's ID unexpectedly changed after a repush/repull")
|
|
| 201 |
+ t.Fatal("image's ID unexpectedly changed after a repush/repull")
|
|
| 202 | 202 |
} |
| 203 | 203 |
|
| 204 | 204 |
// Make sure the image runs correctly |
| 205 |
- out = cli.DockerCmd(c, "run", "--rm", derivedImage).Combined() |
|
| 205 |
+ out = cli.DockerCmd(t, "run", "--rm", derivedImage).Combined() |
|
| 206 | 206 |
if strings.TrimSpace(out) != derivedImage {
|
| 207 |
- c.Fatalf("expected %s; got %s", derivedImage, out)
|
|
| 207 |
+ t.Fatalf("expected %s; got %s", derivedImage, out)
|
|
| 208 | 208 |
} |
| 209 | 209 |
|
| 210 | 210 |
// Confirm that repushing and repulling does not change the computed ID |
| 211 |
- cli.DockerCmd(c, "push", derivedImage) |
|
| 212 |
- cli.DockerCmd(c, "rmi", derivedImage) |
|
| 213 |
- cli.DockerCmd(c, "pull", derivedImage) |
|
| 211 |
+ cli.DockerCmd(t, "push", derivedImage) |
|
| 212 |
+ cli.DockerCmd(t, "rmi", derivedImage) |
|
| 213 |
+ cli.DockerCmd(t, "pull", derivedImage) |
|
| 214 | 214 |
|
| 215 |
- derivedIDAfterPull = getIDByName(c, derivedImage) |
|
| 215 |
+ derivedIDAfterPull = getIDByName(t, derivedImage) |
|
| 216 | 216 |
if derivedIDAfterPull != originalID {
|
| 217 |
- c.Fatal("image's ID unexpectedly changed after a repush/repull")
|
|
| 217 |
+ t.Fatal("image's ID unexpectedly changed after a repush/repull")
|
|
| 218 | 218 |
} |
| 219 | 219 |
|
| 220 | 220 |
// Make sure the image still runs |
| 221 |
- out = cli.DockerCmd(c, "run", "--rm", derivedImage).Combined() |
|
| 221 |
+ out = cli.DockerCmd(t, "run", "--rm", derivedImage).Combined() |
|
| 222 | 222 |
if strings.TrimSpace(out) != derivedImage {
|
| 223 |
- c.Fatalf("expected %s; got %s", derivedImage, out)
|
|
| 223 |
+ t.Fatalf("expected %s; got %s", derivedImage, out)
|
|
| 224 | 224 |
} |
| 225 | 225 |
} |
| 226 | 226 |
|
| 227 | 227 |
// #21213 |
| 228 |
-func (s *DockerRegistrySuite) TestPullNoLayers(c *testing.T) {
|
|
| 228 |
+func (s *DockerRegistrySuite) TestPullNoLayers(t *testing.T) {
|
|
| 229 | 229 |
const imgRepo = privateRegistryURL + "/dockercli/scratch" |
| 230 | 230 |
|
| 231 |
- buildImageSuccessfully(c, imgRepo, build.WithDockerfile(` |
|
| 231 |
+ buildImageSuccessfully(t, imgRepo, build.WithDockerfile(` |
|
| 232 | 232 |
FROM scratch |
| 233 | 233 |
ENV foo bar`)) |
| 234 |
- cli.DockerCmd(c, "push", imgRepo) |
|
| 235 |
- cli.DockerCmd(c, "rmi", imgRepo) |
|
| 236 |
- cli.DockerCmd(c, "pull", imgRepo) |
|
| 234 |
+ cli.DockerCmd(t, "push", imgRepo) |
|
| 235 |
+ cli.DockerCmd(t, "rmi", imgRepo) |
|
| 236 |
+ cli.DockerCmd(t, "pull", imgRepo) |
|
| 237 | 237 |
} |
| 238 | 238 |
|
| 239 | 239 |
func (s *DockerRegistrySuite) TestPullManifestList(c *testing.T) {
|
| ... | ... |
@@ -17,12 +17,12 @@ type DockerCLIPullSuite struct {
|
| 17 | 17 |
ds *DockerSuite |
| 18 | 18 |
} |
| 19 | 19 |
|
| 20 |
-func (s *DockerCLIPullSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 21 |
- s.ds.TearDownTest(ctx, c) |
|
| 20 |
+func (s *DockerCLIPullSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 21 |
+ s.ds.TearDownTest(ctx, t) |
|
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
-func (s *DockerCLIPullSuite) OnTimeout(c *testing.T) {
|
|
| 25 |
- s.ds.OnTimeout(c) |
|
| 24 |
+func (s *DockerCLIPullSuite) OnTimeout(t *testing.T) {
|
|
| 25 |
+ s.ds.OnTimeout(t) |
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
// TestPullFromCentralRegistry pulls an image from the central registry and verifies that the client |
| ... | ... |
@@ -24,12 +24,12 @@ type DockerCLIPushSuite struct {
|
| 24 | 24 |
ds *DockerSuite |
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
-func (s *DockerCLIPushSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 28 |
- s.ds.TearDownTest(ctx, c) |
|
| 27 |
+func (s *DockerCLIPushSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 28 |
+ s.ds.TearDownTest(ctx, t) |
|
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
-func (s *DockerCLIPushSuite) OnTimeout(c *testing.T) {
|
|
| 32 |
- s.ds.OnTimeout(c) |
|
| 31 |
+func (s *DockerCLIPushSuite) OnTimeout(t *testing.T) {
|
|
| 32 |
+ s.ds.OnTimeout(t) |
|
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 | 35 |
func (s *DockerRegistrySuite) TestPushBusyboxImage(c *testing.T) {
|
| ... | ... |
@@ -28,25 +28,25 @@ func unescapeBackslashSemicolonParens(s string) string {
|
| 28 | 28 |
return string(ret) |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
-func regexpCheckUA(c *testing.T, ua string) {
|
|
| 31 |
+func regexpCheckUA(t *testing.T, ua string) {
|
|
| 32 | 32 |
re := regexp.MustCompile("(?P<dockerUA>.+) UpstreamClient(?P<upstreamUA>.+)")
|
| 33 | 33 |
substrArr := re.FindStringSubmatch(ua) |
| 34 | 34 |
|
| 35 |
- assert.Equal(c, len(substrArr), 3, "Expected 'UpstreamClient()' with upstream client UA") |
|
| 35 |
+ assert.Equal(t, len(substrArr), 3, "Expected 'UpstreamClient()' with upstream client UA") |
|
| 36 | 36 |
dockerUA := substrArr[1] |
| 37 | 37 |
upstreamUAEscaped := substrArr[2] |
| 38 | 38 |
|
| 39 | 39 |
// check dockerUA looks correct |
| 40 | 40 |
reDockerUA := regexp.MustCompile("^docker/[0-9A-Za-z+]")
|
| 41 | 41 |
bMatchDockerUA := reDockerUA.MatchString(dockerUA) |
| 42 |
- assert.Assert(c, bMatchDockerUA, "Docker Engine User-Agent malformed") |
|
| 42 |
+ assert.Assert(t, bMatchDockerUA, "Docker Engine User-Agent malformed") |
|
| 43 | 43 |
|
| 44 | 44 |
// check upstreamUA looks correct |
| 45 | 45 |
// Expecting something like: Docker-Client/1.11.0-dev (linux) |
| 46 | 46 |
upstreamUA := unescapeBackslashSemicolonParens(upstreamUAEscaped) |
| 47 | 47 |
reUpstreamUA := regexp.MustCompile(`^\(Docker-Client/[0-9A-Za-z+]`) |
| 48 | 48 |
bMatchUpstreamUA := reUpstreamUA.MatchString(upstreamUA) |
| 49 |
- assert.Assert(c, bMatchUpstreamUA, "(Upstream) Docker Client User-Agent malformed") |
|
| 49 |
+ assert.Assert(t, bMatchUpstreamUA, "(Upstream) Docker Client User-Agent malformed") |
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
// registerUserAgentHandler registers a handler for the `/v2/*` endpoint. |
| ... | ... |
@@ -20,12 +20,12 @@ type DockerCLIRestartSuite struct {
|
| 20 | 20 |
ds *DockerSuite |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
-func (s *DockerCLIRestartSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 24 |
- s.ds.TearDownTest(ctx, c) |
|
| 23 |
+func (s *DockerCLIRestartSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 24 |
+ s.ds.TearDownTest(ctx, t) |
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
-func (s *DockerCLIRestartSuite) OnTimeout(c *testing.T) {
|
|
| 28 |
- s.ds.OnTimeout(c) |
|
| 27 |
+func (s *DockerCLIRestartSuite) OnTimeout(t *testing.T) {
|
|
| 28 |
+ s.ds.OnTimeout(t) |
|
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 | 31 |
func (s *DockerCLIRestartSuite) TestRestartStoppedContainer(c *testing.T) {
|
| ... | ... |
@@ -50,8 +50,8 @@ func (s *DockerCLIRestartSuite) TestRestartRunningContainer(c *testing.T) {
|
| 50 | 50 |
cID = strings.TrimSpace(cID) |
| 51 | 51 |
cli.WaitRun(c, cID) |
| 52 | 52 |
|
| 53 |
- getLogs := func(c *testing.T) (interface{}, string) {
|
|
| 54 |
- out := cli.DockerCmd(c, "logs", cID).Combined() |
|
| 53 |
+ getLogs := func(t *testing.T) (interface{}, string) {
|
|
| 54 |
+ out := cli.DockerCmd(t, "logs", cID).Combined() |
|
| 55 | 55 |
return out, "" |
| 56 | 56 |
} |
| 57 | 57 |
|
| ... | ... |
@@ -20,12 +20,12 @@ type DockerCLIRmiSuite struct {
|
| 20 | 20 |
ds *DockerSuite |
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 |
-func (s *DockerCLIRmiSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 24 |
- s.ds.TearDownTest(ctx, c) |
|
| 23 |
+func (s *DockerCLIRmiSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 24 |
+ s.ds.TearDownTest(ctx, t) |
|
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
-func (s *DockerCLIRmiSuite) OnTimeout(c *testing.T) {
|
|
| 28 |
- s.ds.OnTimeout(c) |
|
| 27 |
+func (s *DockerCLIRmiSuite) OnTimeout(t *testing.T) {
|
|
| 28 |
+ s.ds.OnTimeout(t) |
|
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 | 31 |
func (s *DockerCLIRmiSuite) TestRmiWithContainerFails(c *testing.T) {
|
| ... | ... |
@@ -46,12 +46,12 @@ type DockerCLIRunSuite struct {
|
| 46 | 46 |
ds *DockerSuite |
| 47 | 47 |
} |
| 48 | 48 |
|
| 49 |
-func (s *DockerCLIRunSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 50 |
- s.ds.TearDownTest(ctx, c) |
|
| 49 |
+func (s *DockerCLIRunSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 50 |
+ s.ds.TearDownTest(ctx, t) |
|
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 |
-func (s *DockerCLIRunSuite) OnTimeout(c *testing.T) {
|
|
| 54 |
- s.ds.OnTimeout(c) |
|
| 53 |
+func (s *DockerCLIRunSuite) OnTimeout(t *testing.T) {
|
|
| 54 |
+ s.ds.OnTimeout(t) |
|
| 55 | 55 |
} |
| 56 | 56 |
|
| 57 | 57 |
// "test123" should be printed by docker run |
| ... | ... |
@@ -1812,24 +1812,24 @@ func (s *DockerCLIRunSuite) TestRunWriteSpecialFilesAndNotCommit(c *testing.T) {
|
| 1812 | 1812 |
testRunWriteSpecialFilesAndNotCommit(c, "writeresolv", "/etc/resolv.conf") |
| 1813 | 1813 |
} |
| 1814 | 1814 |
|
| 1815 |
-func testRunWriteSpecialFilesAndNotCommit(c *testing.T, name, path string) {
|
|
| 1815 |
+func testRunWriteSpecialFilesAndNotCommit(t *testing.T, name, path string) {
|
|
| 1816 | 1816 |
command := fmt.Sprintf("echo test2267 >> %s && cat %s", path, path)
|
| 1817 |
- out := cli.DockerCmd(c, "run", "--name", name, "busybox", "sh", "-c", command).Combined() |
|
| 1817 |
+ out := cli.DockerCmd(t, "run", "--name", name, "busybox", "sh", "-c", command).Combined() |
|
| 1818 | 1818 |
if !strings.Contains(out, "test2267") {
|
| 1819 |
- c.Fatalf("%s should contain 'test2267'", path)
|
|
| 1819 |
+ t.Fatalf("%s should contain 'test2267'", path)
|
|
| 1820 | 1820 |
} |
| 1821 | 1821 |
|
| 1822 |
- out = cli.DockerCmd(c, "diff", name).Combined() |
|
| 1823 |
- if len(strings.Trim(out, "\r\n")) != 0 && !eqToBaseDiff(out, c) {
|
|
| 1824 |
- c.Fatal("diff should be empty")
|
|
| 1822 |
+ out = cli.DockerCmd(t, "diff", name).Combined() |
|
| 1823 |
+ if len(strings.Trim(out, "\r\n")) != 0 && !eqToBaseDiff(out, t) {
|
|
| 1824 |
+ t.Fatal("diff should be empty")
|
|
| 1825 | 1825 |
} |
| 1826 | 1826 |
} |
| 1827 | 1827 |
|
| 1828 |
-func eqToBaseDiff(out string, c *testing.T) bool {
|
|
| 1828 |
+func eqToBaseDiff(out string, t *testing.T) bool {
|
|
| 1829 | 1829 |
name := "eqToBaseDiff" + testutil.GenerateRandomAlphaOnlyString(32) |
| 1830 |
- cli.DockerCmd(c, "run", "--name", name, "busybox", "echo", "hello") |
|
| 1831 |
- cID := getIDByName(c, name) |
|
| 1832 |
- baseDiff := cli.DockerCmd(c, "diff", cID).Combined() |
|
| 1830 |
+ cli.DockerCmd(t, "run", "--name", name, "busybox", "echo", "hello") |
|
| 1831 |
+ cID := getIDByName(t, name) |
|
| 1832 |
+ baseDiff := cli.DockerCmd(t, "diff", cID).Combined() |
|
| 1833 | 1833 |
baseArr := strings.Split(baseDiff, "\n") |
| 1834 | 1834 |
sort.Strings(baseArr) |
| 1835 | 1835 |
outArr := strings.Split(out, "\n") |
| ... | ... |
@@ -2661,14 +2661,14 @@ func (s *DockerCLIRunSuite) TestPermissionsPtsReadonlyRootfs(c *testing.T) {
|
| 2661 | 2661 |
} |
| 2662 | 2662 |
} |
| 2663 | 2663 |
|
| 2664 |
-func testReadOnlyFile(c *testing.T, testPriv bool, filenames ...string) {
|
|
| 2664 |
+func testReadOnlyFile(t *testing.T, testPriv bool, filenames ...string) {
|
|
| 2665 | 2665 |
touch := "touch " + strings.Join(filenames, " ") |
| 2666 | 2666 |
out, _, err := dockerCmdWithError("run", "--read-only", "--rm", "busybox", "sh", "-c", touch)
|
| 2667 |
- assert.ErrorContains(c, err, "") |
|
| 2667 |
+ assert.ErrorContains(t, err, "") |
|
| 2668 | 2668 |
|
| 2669 | 2669 |
for _, f := range filenames {
|
| 2670 | 2670 |
expected := "touch: " + f + ": Read-only file system" |
| 2671 |
- assert.Assert(c, is.Contains(out, expected)) |
|
| 2671 |
+ assert.Assert(t, is.Contains(out, expected)) |
|
| 2672 | 2672 |
} |
| 2673 | 2673 |
|
| 2674 | 2674 |
if !testPriv {
|
| ... | ... |
@@ -2676,11 +2676,11 @@ func testReadOnlyFile(c *testing.T, testPriv bool, filenames ...string) {
|
| 2676 | 2676 |
} |
| 2677 | 2677 |
|
| 2678 | 2678 |
out, _, err = dockerCmdWithError("run", "--read-only", "--privileged", "--rm", "busybox", "sh", "-c", touch)
|
| 2679 |
- assert.ErrorContains(c, err, "") |
|
| 2679 |
+ assert.ErrorContains(t, err, "") |
|
| 2680 | 2680 |
|
| 2681 | 2681 |
for _, f := range filenames {
|
| 2682 | 2682 |
expected := "touch: " + f + ": Read-only file system" |
| 2683 |
- assert.Assert(c, is.Contains(out, expected)) |
|
| 2683 |
+ assert.Assert(t, is.Contains(out, expected)) |
|
| 2684 | 2684 |
} |
| 2685 | 2685 |
} |
| 2686 | 2686 |
|
| ... | ... |
@@ -3197,16 +3197,16 @@ func (s *DockerCLIRunSuite) TestRunContainerWithCgroupParent(c *testing.T) {
|
| 3197 | 3197 |
testRunContainerWithCgroupParent(c, "/cgroup-parent/test", "cgroup-test-absolute") |
| 3198 | 3198 |
} |
| 3199 | 3199 |
|
| 3200 |
-func testRunContainerWithCgroupParent(c *testing.T, cgroupParent, name string) {
|
|
| 3200 |
+func testRunContainerWithCgroupParent(t *testing.T, cgroupParent, name string) {
|
|
| 3201 | 3201 |
out, _, err := dockerCmdWithError("run", "--cgroup-parent", cgroupParent, "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
| 3202 | 3202 |
if err != nil {
|
| 3203 |
- c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", out, err)
|
|
| 3203 |
+ t.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", out, err)
|
|
| 3204 | 3204 |
} |
| 3205 | 3205 |
cgroupPaths := ParseCgroupPaths(out) |
| 3206 | 3206 |
if len(cgroupPaths) == 0 {
|
| 3207 |
- c.Fatalf("unexpected output - %q", out)
|
|
| 3207 |
+ t.Fatalf("unexpected output - %q", out)
|
|
| 3208 | 3208 |
} |
| 3209 |
- id := getIDByName(c, name) |
|
| 3209 |
+ id := getIDByName(t, name) |
|
| 3210 | 3210 |
expectedCgroup := path.Join(cgroupParent, id) |
| 3211 | 3211 |
found := false |
| 3212 | 3212 |
for _, p := range cgroupPaths {
|
| ... | ... |
@@ -3216,7 +3216,7 @@ func testRunContainerWithCgroupParent(c *testing.T, cgroupParent, name string) {
|
| 3216 | 3216 |
} |
| 3217 | 3217 |
} |
| 3218 | 3218 |
if !found {
|
| 3219 |
- c.Fatalf("unexpected cgroup paths. Expected at least one cgroup path to have suffix %q. Cgroup Paths: %v", expectedCgroup, cgroupPaths)
|
|
| 3219 |
+ t.Fatalf("unexpected cgroup paths. Expected at least one cgroup path to have suffix %q. Cgroup Paths: %v", expectedCgroup, cgroupPaths)
|
|
| 3220 | 3220 |
} |
| 3221 | 3221 |
} |
| 3222 | 3222 |
|
| ... | ... |
@@ -3231,23 +3231,23 @@ func (s *DockerCLIRunSuite) TestRunInvalidCgroupParent(c *testing.T) {
|
| 3231 | 3231 |
testRunInvalidCgroupParent(c, "/../../../../../../../../SHOULD_NOT_EXIST", "/SHOULD_NOT_EXIST", "cgroup-absolute-invalid-test") |
| 3232 | 3232 |
} |
| 3233 | 3233 |
|
| 3234 |
-func testRunInvalidCgroupParent(c *testing.T, cgroupParent, cleanCgroupParent, name string) {
|
|
| 3234 |
+func testRunInvalidCgroupParent(t *testing.T, cgroupParent, cleanCgroupParent, name string) {
|
|
| 3235 | 3235 |
out, _, err := dockerCmdWithError("run", "--cgroup-parent", cgroupParent, "--name", name, "busybox", "cat", "/proc/self/cgroup")
|
| 3236 | 3236 |
if err != nil {
|
| 3237 | 3237 |
// XXX: This may include a daemon crash. |
| 3238 |
- c.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", out, err)
|
|
| 3238 |
+ t.Fatalf("unexpected failure when running container with --cgroup-parent option - %s\n%v", out, err)
|
|
| 3239 | 3239 |
} |
| 3240 | 3240 |
|
| 3241 | 3241 |
// We expect "/SHOULD_NOT_EXIST" to not exist. If not, we have a security issue. |
| 3242 | 3242 |
if _, err := os.Stat("/SHOULD_NOT_EXIST"); err == nil || !os.IsNotExist(err) {
|
| 3243 |
- c.Fatalf("SECURITY: --cgroup-parent with ../../ relative paths cause files to be created in the host (this is bad) !!")
|
|
| 3243 |
+ t.Fatalf("SECURITY: --cgroup-parent with ../../ relative paths cause files to be created in the host (this is bad) !!")
|
|
| 3244 | 3244 |
} |
| 3245 | 3245 |
|
| 3246 | 3246 |
cgroupPaths := ParseCgroupPaths(out) |
| 3247 | 3247 |
if len(cgroupPaths) == 0 {
|
| 3248 |
- c.Fatalf("unexpected output - %q", out)
|
|
| 3248 |
+ t.Fatalf("unexpected output - %q", out)
|
|
| 3249 | 3249 |
} |
| 3250 |
- id := getIDByName(c, name) |
|
| 3250 |
+ id := getIDByName(t, name) |
|
| 3251 | 3251 |
expectedCgroup := path.Join(cleanCgroupParent, id) |
| 3252 | 3252 |
found := false |
| 3253 | 3253 |
for _, p := range cgroupPaths {
|
| ... | ... |
@@ -3257,7 +3257,7 @@ func testRunInvalidCgroupParent(c *testing.T, cgroupParent, cleanCgroupParent, n |
| 3257 | 3257 |
} |
| 3258 | 3258 |
} |
| 3259 | 3259 |
if !found {
|
| 3260 |
- c.Fatalf("unexpected cgroup paths. Expected at least one cgroup path to have suffix %q. Cgroup Paths: %v", expectedCgroup, cgroupPaths)
|
|
| 3260 |
+ t.Fatalf("unexpected cgroup paths. Expected at least one cgroup path to have suffix %q. Cgroup Paths: %v", expectedCgroup, cgroupPaths)
|
|
| 3261 | 3261 |
} |
| 3262 | 3262 |
} |
| 3263 | 3263 |
|
| ... | ... |
@@ -24,12 +24,12 @@ type DockerCLISaveLoadSuite struct {
|
| 24 | 24 |
ds *DockerSuite |
| 25 | 25 |
} |
| 26 | 26 |
|
| 27 |
-func (s *DockerCLISaveLoadSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 28 |
- s.ds.TearDownTest(ctx, c) |
|
| 27 |
+func (s *DockerCLISaveLoadSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 28 |
+ s.ds.TearDownTest(ctx, t) |
|
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
-func (s *DockerCLISaveLoadSuite) OnTimeout(c *testing.T) {
|
|
| 32 |
- s.ds.OnTimeout(c) |
|
| 31 |
+func (s *DockerCLISaveLoadSuite) OnTimeout(t *testing.T) {
|
|
| 32 |
+ s.ds.OnTimeout(t) |
|
| 33 | 33 |
} |
| 34 | 34 |
|
| 35 | 35 |
// save a repo using gz compression and try to load it using stdout |
| ... | ... |
@@ -15,12 +15,12 @@ type DockerCLISearchSuite struct {
|
| 15 | 15 |
ds *DockerSuite |
| 16 | 16 |
} |
| 17 | 17 |
|
| 18 |
-func (s *DockerCLISearchSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 19 |
- s.ds.TearDownTest(ctx, c) |
|
| 18 |
+func (s *DockerCLISearchSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 19 |
+ s.ds.TearDownTest(ctx, t) |
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
-func (s *DockerCLISearchSuite) OnTimeout(c *testing.T) {
|
|
| 23 |
- s.ds.OnTimeout(c) |
|
| 22 |
+func (s *DockerCLISearchSuite) OnTimeout(t *testing.T) {
|
|
| 23 |
+ s.ds.OnTimeout(t) |
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
// search for repos named "registry" on the central registry |
| ... | ... |
@@ -27,15 +27,15 @@ func (s *DockerSwarmSuite) TestServiceCreateMountVolume(c *testing.T) {
|
| 27 | 27 |
id := strings.TrimSpace(out) |
| 28 | 28 |
|
| 29 | 29 |
var tasks []swarm.Task |
| 30 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 31 |
- tasks = d.GetServiceTasks(ctx, c, id) |
|
| 30 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 31 |
+ tasks = d.GetServiceTasks(ctx, t, id) |
|
| 32 | 32 |
return len(tasks) > 0, "" |
| 33 | 33 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 34 | 34 |
|
| 35 | 35 |
task := tasks[0] |
| 36 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 36 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 37 | 37 |
if task.NodeID == "" || task.Status.ContainerStatus == nil {
|
| 38 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 38 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 39 | 39 |
} |
| 40 | 40 |
return task.NodeID != "" && task.Status.ContainerStatus != nil, "" |
| 41 | 41 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| ... | ... |
@@ -143,15 +143,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretSourceTargetPaths(c *testi |
| 143 | 143 |
assert.Equal(c, len(refs), len(testPaths)) |
| 144 | 144 |
|
| 145 | 145 |
var tasks []swarm.Task |
| 146 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 147 |
- tasks = d.GetServiceTasks(ctx, c, serviceName) |
|
| 146 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 147 |
+ tasks = d.GetServiceTasks(ctx, t, serviceName) |
|
| 148 | 148 |
return len(tasks) > 0, "" |
| 149 | 149 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 150 | 150 |
|
| 151 | 151 |
task := tasks[0] |
| 152 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 152 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 153 | 153 |
if task.NodeID == "" || task.Status.ContainerStatus == nil {
|
| 154 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 154 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 155 | 155 |
} |
| 156 | 156 |
return task.NodeID != "" && task.Status.ContainerStatus != nil, "" |
| 157 | 157 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| ... | ... |
@@ -194,15 +194,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithSecretReferencedTwice(c *testing |
| 194 | 194 |
assert.Equal(c, len(refs), 2) |
| 195 | 195 |
|
| 196 | 196 |
var tasks []swarm.Task |
| 197 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 198 |
- tasks = d.GetServiceTasks(ctx, c, serviceName) |
|
| 197 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 198 |
+ tasks = d.GetServiceTasks(ctx, t, serviceName) |
|
| 199 | 199 |
return len(tasks) > 0, "" |
| 200 | 200 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 201 | 201 |
|
| 202 | 202 |
task := tasks[0] |
| 203 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 203 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 204 | 204 |
if task.NodeID == "" || task.Status.ContainerStatus == nil {
|
| 205 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 205 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 206 | 206 |
} |
| 207 | 207 |
return task.NodeID != "" && task.Status.ContainerStatus != nil, "" |
| 208 | 208 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| ... | ... |
@@ -293,15 +293,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigSourceTargetPaths(c *testi |
| 293 | 293 |
assert.Equal(c, len(refs), len(testPaths)) |
| 294 | 294 |
|
| 295 | 295 |
var tasks []swarm.Task |
| 296 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 297 |
- tasks = d.GetServiceTasks(ctx, c, serviceName) |
|
| 296 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 297 |
+ tasks = d.GetServiceTasks(ctx, t, serviceName) |
|
| 298 | 298 |
return len(tasks) > 0, "" |
| 299 | 299 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 300 | 300 |
|
| 301 | 301 |
task := tasks[0] |
| 302 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 302 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 303 | 303 |
if task.NodeID == "" || task.Status.ContainerStatus == nil {
|
| 304 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 304 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 305 | 305 |
} |
| 306 | 306 |
return task.NodeID != "" && task.Status.ContainerStatus != nil, "" |
| 307 | 307 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| ... | ... |
@@ -344,15 +344,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithConfigReferencedTwice(c *testing |
| 344 | 344 |
assert.Equal(c, len(refs), 2) |
| 345 | 345 |
|
| 346 | 346 |
var tasks []swarm.Task |
| 347 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 348 |
- tasks = d.GetServiceTasks(ctx, c, serviceName) |
|
| 347 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 348 |
+ tasks = d.GetServiceTasks(ctx, t, serviceName) |
|
| 349 | 349 |
return len(tasks) > 0, "" |
| 350 | 350 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 351 | 351 |
|
| 352 | 352 |
task := tasks[0] |
| 353 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 353 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 354 | 354 |
if task.NodeID == "" || task.Status.ContainerStatus == nil {
|
| 355 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 355 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 356 | 356 |
} |
| 357 | 357 |
return task.NodeID != "" && task.Status.ContainerStatus != nil, "" |
| 358 | 358 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| ... | ... |
@@ -377,15 +377,15 @@ func (s *DockerSwarmSuite) TestServiceCreateMountTmpfs(c *testing.T) {
|
| 377 | 377 |
id := strings.TrimSpace(out) |
| 378 | 378 |
|
| 379 | 379 |
var tasks []swarm.Task |
| 380 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 381 |
- tasks = d.GetServiceTasks(ctx, c, id) |
|
| 380 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 381 |
+ tasks = d.GetServiceTasks(ctx, t, id) |
|
| 382 | 382 |
return len(tasks) > 0, "" |
| 383 | 383 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 384 | 384 |
|
| 385 | 385 |
task := tasks[0] |
| 386 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 386 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 387 | 387 |
if task.NodeID == "" || task.Status.ContainerStatus == nil {
|
| 388 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 388 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 389 | 389 |
} |
| 390 | 390 |
return task.NodeID != "" && task.Status.ContainerStatus != nil, "" |
| 391 | 391 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| ... | ... |
@@ -434,15 +434,15 @@ func (s *DockerSwarmSuite) TestServiceCreateWithNetworkAlias(c *testing.T) {
|
| 434 | 434 |
id := strings.TrimSpace(out) |
| 435 | 435 |
|
| 436 | 436 |
var tasks []swarm.Task |
| 437 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 438 |
- tasks = d.GetServiceTasks(ctx, c, id) |
|
| 437 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 438 |
+ tasks = d.GetServiceTasks(ctx, t, id) |
|
| 439 | 439 |
return len(tasks) > 0, "" |
| 440 | 440 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 441 | 441 |
|
| 442 | 442 |
task := tasks[0] |
| 443 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 443 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 444 | 444 |
if task.NodeID == "" || task.Status.ContainerStatus == nil {
|
| 445 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 445 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 446 | 446 |
} |
| 447 | 447 |
return task.NodeID != "" && task.Status.ContainerStatus != nil, "" |
| 448 | 448 |
}, checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
| ... | ... |
@@ -42,23 +42,23 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *testing.T) {
|
| 42 | 42 |
id := strings.TrimSpace(out) |
| 43 | 43 |
|
| 44 | 44 |
var tasks []swarm.Task |
| 45 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 46 |
- tasks = d.GetServiceTasks(ctx, c, id) |
|
| 45 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 46 |
+ tasks = d.GetServiceTasks(ctx, t, id) |
|
| 47 | 47 |
return tasks, "" |
| 48 | 48 |
}, checker.HasLen(1)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 49 | 49 |
|
| 50 | 50 |
task := tasks[0] |
| 51 | 51 |
|
| 52 | 52 |
// wait for task to start |
| 53 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 54 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 53 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 54 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 55 | 55 |
return task.Status.State, "" |
| 56 | 56 |
}, checker.Equals(swarm.TaskStateRunning)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 57 | 57 |
|
| 58 | 58 |
containerID := task.Status.ContainerStatus.ContainerID |
| 59 | 59 |
|
| 60 | 60 |
// wait for container to be healthy |
| 61 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 61 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 62 | 62 |
out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
|
| 63 | 63 |
return strings.TrimSpace(out), "" |
| 64 | 64 |
}, checker.Equals("healthy")), poll.WithTimeout(defaultReconciliationTimeout))
|
| ... | ... |
@@ -66,14 +66,14 @@ func (s *DockerSwarmSuite) TestServiceHealthRun(c *testing.T) {
|
| 66 | 66 |
// make it fail |
| 67 | 67 |
d.Cmd("exec", containerID, "rm", "/status")
|
| 68 | 68 |
// wait for container to be unhealthy |
| 69 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 69 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 70 | 70 |
out, _ := d.Cmd("inspect", "--format={{.State.Health.Status}}", containerID)
|
| 71 | 71 |
return strings.TrimSpace(out), "" |
| 72 | 72 |
}, checker.Equals("unhealthy")), poll.WithTimeout(defaultReconciliationTimeout))
|
| 73 | 73 |
|
| 74 | 74 |
// Task should be terminated |
| 75 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 76 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 75 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 76 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 77 | 77 |
return task.Status.State, "" |
| 78 | 78 |
}, checker.Equals(swarm.TaskStateFailed)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 79 | 79 |
|
| ... | ... |
@@ -105,23 +105,23 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
|
| 105 | 105 |
id := strings.TrimSpace(out) |
| 106 | 106 |
|
| 107 | 107 |
var tasks []swarm.Task |
| 108 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 109 |
- tasks = d.GetServiceTasks(ctx, c, id) |
|
| 108 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 109 |
+ tasks = d.GetServiceTasks(ctx, t, id) |
|
| 110 | 110 |
return tasks, "" |
| 111 | 111 |
}, checker.HasLen(1)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 112 | 112 |
|
| 113 | 113 |
task := tasks[0] |
| 114 | 114 |
|
| 115 | 115 |
// wait for task to start |
| 116 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 117 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 116 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 117 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 118 | 118 |
return task.Status.State, "" |
| 119 | 119 |
}, checker.Equals(swarm.TaskStateStarting)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 120 | 120 |
|
| 121 | 121 |
containerID := task.Status.ContainerStatus.ContainerID |
| 122 | 122 |
|
| 123 | 123 |
// wait for health check to work |
| 124 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 124 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 125 | 125 |
out, _ := d.Cmd("inspect", "--format={{.State.Health.FailingStreak}}", containerID)
|
| 126 | 126 |
failingStreak, _ := strconv.Atoi(strings.TrimSpace(out)) |
| 127 | 127 |
return failingStreak, "" |
| ... | ... |
@@ -135,8 +135,8 @@ func (s *DockerSwarmSuite) TestServiceHealthStart(c *testing.T) {
|
| 135 | 135 |
d.Cmd("exec", containerID, "touch", "/status")
|
| 136 | 136 |
|
| 137 | 137 |
// Task should be at running status |
| 138 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 139 |
- task = d.GetTask(ctx, c, task.ID) |
|
| 138 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 139 |
+ task = d.GetTask(ctx, t, task.ID) |
|
| 140 | 140 |
return task.Status.State, "" |
| 141 | 141 |
}, checker.Equals(swarm.TaskStateRunning)), poll.WithTimeout(defaultReconciliationTimeout)) |
| 142 | 142 |
} |
| ... | ... |
@@ -57,9 +57,9 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *testing.T) {
|
| 57 | 57 |
// verify that a minimum number of expected container log messages have been |
| 58 | 58 |
// output. |
| 59 | 59 |
func countLogLines(d *daemon.Daemon, name string) func(*testing.T) (interface{}, string) {
|
| 60 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 60 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 61 | 61 |
result := icmd.RunCmd(d.Command("service", "logs", "-t", "--raw", name))
|
| 62 |
- result.Assert(c, icmd.Expected{})
|
|
| 62 |
+ result.Assert(t, icmd.Expected{})
|
|
| 63 | 63 |
// if this returns an emptystring, trying to split it later will return |
| 64 | 64 |
// an array containing emptystring. a valid log line will NEVER be |
| 65 | 65 |
// emptystring because we ask for the timestamp. |
| ... | ... |
@@ -19,12 +19,12 @@ type DockerCLISNISuite struct {
|
| 19 | 19 |
ds *DockerSuite |
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 |
-func (s *DockerCLISNISuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 23 |
- s.ds.TearDownTest(ctx, c) |
|
| 22 |
+func (s *DockerCLISNISuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 23 |
+ s.ds.TearDownTest(ctx, t) |
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 |
-func (s *DockerCLISNISuite) OnTimeout(c *testing.T) {
|
|
| 27 |
- s.ds.OnTimeout(c) |
|
| 26 |
+func (s *DockerCLISNISuite) OnTimeout(t *testing.T) {
|
|
| 27 |
+ s.ds.OnTimeout(t) |
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 | 30 |
func (s *DockerCLISNISuite) TestClientSetsTLSServerName(c *testing.T) {
|
| ... | ... |
@@ -17,12 +17,12 @@ type DockerCLIStartSuite struct {
|
| 17 | 17 |
ds *DockerSuite |
| 18 | 18 |
} |
| 19 | 19 |
|
| 20 |
-func (s *DockerCLIStartSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 21 |
- s.ds.TearDownTest(ctx, c) |
|
| 20 |
+func (s *DockerCLIStartSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 21 |
+ s.ds.TearDownTest(ctx, t) |
|
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 |
-func (s *DockerCLIStartSuite) OnTimeout(c *testing.T) {
|
|
| 25 |
- s.ds.OnTimeout(c) |
|
| 24 |
+func (s *DockerCLIStartSuite) OnTimeout(t *testing.T) {
|
|
| 25 |
+ s.ds.OnTimeout(t) |
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
// Regression test for https://github.com/docker/docker/issues/7843 |
| ... | ... |
@@ -18,12 +18,12 @@ type DockerCLIStatsSuite struct {
|
| 18 | 18 |
ds *DockerSuite |
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (s *DockerCLIStatsSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 22 |
- s.ds.TearDownTest(ctx, c) |
|
| 21 |
+func (s *DockerCLIStatsSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 22 |
+ s.ds.TearDownTest(ctx, t) |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 |
-func (s *DockerCLIStatsSuite) OnTimeout(c *testing.T) {
|
|
| 26 |
- s.ds.OnTimeout(c) |
|
| 25 |
+func (s *DockerCLIStatsSuite) OnTimeout(t *testing.T) {
|
|
| 26 |
+ s.ds.OnTimeout(t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
func (s *DockerCLIStatsSuite) TestStatsNoStream(c *testing.T) {
|
| ... | ... |
@@ -1051,14 +1051,14 @@ func (s *DockerSwarmSuite) TestDNSConfigUpdate(c *testing.T) {
|
| 1051 | 1051 |
assert.Equal(c, strings.TrimSpace(out), "{[1.2.3.4] [example.com] [timeout:3]}")
|
| 1052 | 1052 |
} |
| 1053 | 1053 |
|
| 1054 |
-func getNodeStatus(c *testing.T, d *daemon.Daemon) swarm.LocalNodeState {
|
|
| 1055 |
- ctx := testutil.GetContext(c) |
|
| 1056 |
- info := d.SwarmInfo(ctx, c) |
|
| 1054 |
+func getNodeStatus(t *testing.T, d *daemon.Daemon) swarm.LocalNodeState {
|
|
| 1055 |
+ ctx := testutil.GetContext(t) |
|
| 1056 |
+ info := d.SwarmInfo(ctx, t) |
|
| 1057 | 1057 |
return info.LocalNodeState |
| 1058 | 1058 |
} |
| 1059 | 1059 |
|
| 1060 | 1060 |
func checkKeyIsEncrypted(d *daemon.Daemon) func(*testing.T) (interface{}, string) {
|
| 1061 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 1061 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 1062 | 1062 |
keyBytes, err := os.ReadFile(filepath.Join(d.Folder, "root", "swarm", "certificates", "swarm-node.key")) |
| 1063 | 1063 |
if err != nil {
|
| 1064 | 1064 |
return fmt.Errorf("error reading key: %v", err), ""
|
| ... | ... |
@@ -1073,20 +1073,20 @@ func checkKeyIsEncrypted(d *daemon.Daemon) func(*testing.T) (interface{}, string
|
| 1073 | 1073 |
} |
| 1074 | 1074 |
} |
| 1075 | 1075 |
|
| 1076 |
-func checkSwarmLockedToUnlocked(ctx context.Context, c *testing.T, d *daemon.Daemon) {
|
|
| 1076 |
+func checkSwarmLockedToUnlocked(ctx context.Context, t *testing.T, d *daemon.Daemon) {
|
|
| 1077 | 1077 |
// Wait for the PEM file to become unencrypted |
| 1078 |
- poll.WaitOn(c, pollCheck(c, checkKeyIsEncrypted(d), checker.Equals(false)), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 1078 |
+ poll.WaitOn(t, pollCheck(t, checkKeyIsEncrypted(d), checker.Equals(false)), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 1079 | 1079 |
|
| 1080 |
- d.RestartNode(c) |
|
| 1081 |
- poll.WaitOn(c, pollCheck(c, d.CheckLocalNodeState(ctx), checker.Equals(swarm.LocalNodeStateActive)), poll.WithTimeout(time.Second)) |
|
| 1080 |
+ d.RestartNode(t) |
|
| 1081 |
+ poll.WaitOn(t, pollCheck(t, d.CheckLocalNodeState(ctx), checker.Equals(swarm.LocalNodeStateActive)), poll.WithTimeout(time.Second)) |
|
| 1082 | 1082 |
} |
| 1083 | 1083 |
|
| 1084 |
-func checkSwarmUnlockedToLocked(ctx context.Context, c *testing.T, d *daemon.Daemon) {
|
|
| 1084 |
+func checkSwarmUnlockedToLocked(ctx context.Context, t *testing.T, d *daemon.Daemon) {
|
|
| 1085 | 1085 |
// Wait for the PEM file to become encrypted |
| 1086 |
- poll.WaitOn(c, pollCheck(c, checkKeyIsEncrypted(d), checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 1086 |
+ poll.WaitOn(t, pollCheck(t, checkKeyIsEncrypted(d), checker.Equals(true)), poll.WithTimeout(defaultReconciliationTimeout)) |
|
| 1087 | 1087 |
|
| 1088 |
- d.RestartNode(c) |
|
| 1089 |
- poll.WaitOn(c, pollCheck(c, d.CheckLocalNodeState(ctx), checker.Equals(swarm.LocalNodeStateLocked)), poll.WithTimeout(time.Second)) |
|
| 1088 |
+ d.RestartNode(t) |
|
| 1089 |
+ poll.WaitOn(t, pollCheck(t, d.CheckLocalNodeState(ctx), checker.Equals(swarm.LocalNodeStateLocked)), poll.WithTimeout(time.Second)) |
|
| 1090 | 1090 |
} |
| 1091 | 1091 |
|
| 1092 | 1092 |
func (s *DockerSwarmSuite) TestUnlockEngineAndUnlockedSwarm(c *testing.T) {
|
| ... | ... |
@@ -1293,7 +1293,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *testing.T) {
|
| 1293 | 1293 |
// (because we never want a manager TLS key to be on disk unencrypted if the cluster |
| 1294 | 1294 |
// is set to autolock) |
| 1295 | 1295 |
poll.WaitOn(c, pollCheck(c, d3.CheckControlAvailable(ctx), checker.False()), poll.WithTimeout(defaultReconciliationTimeout)) |
| 1296 |
- poll.WaitOn(c, pollCheck(c, func(c *testing.T) (interface{}, string) {
|
|
| 1296 |
+ poll.WaitOn(c, pollCheck(c, func(t *testing.T) (interface{}, string) {
|
|
| 1297 | 1297 |
certBytes, err := os.ReadFile(filepath.Join(d3.Folder, "root", "swarm", "certificates", "swarm-node.crt")) |
| 1298 | 1298 |
if err != nil {
|
| 1299 | 1299 |
return "", fmt.Sprintf("error: %v", err)
|
| ... | ... |
@@ -1801,21 +1801,21 @@ func (s *DockerSwarmSuite) TestSwarmJoinLeave(c *testing.T) {
|
| 1801 | 1801 |
|
| 1802 | 1802 |
const defaultRetryCount = 10 |
| 1803 | 1803 |
|
| 1804 |
-func waitForEvent(c *testing.T, d *daemon.Daemon, since string, filter string, event string, retry int) string {
|
|
| 1804 |
+func waitForEvent(t *testing.T, d *daemon.Daemon, since string, filter string, event string, retry int) string {
|
|
| 1805 | 1805 |
if retry < 1 {
|
| 1806 |
- c.Fatalf("retry count %d is invalid. It should be no less than 1", retry)
|
|
| 1806 |
+ t.Fatalf("retry count %d is invalid. It should be no less than 1", retry)
|
|
| 1807 | 1807 |
return "" |
| 1808 | 1808 |
} |
| 1809 | 1809 |
var out string |
| 1810 | 1810 |
for i := 0; i < retry; i++ {
|
| 1811 |
- until := daemonUnixTime(c) |
|
| 1811 |
+ until := daemonUnixTime(t) |
|
| 1812 | 1812 |
var err error |
| 1813 | 1813 |
if len(filter) > 0 {
|
| 1814 | 1814 |
out, err = d.Cmd("events", "--since", since, "--until", until, filter)
|
| 1815 | 1815 |
} else {
|
| 1816 | 1816 |
out, err = d.Cmd("events", "--since", since, "--until", until)
|
| 1817 | 1817 |
} |
| 1818 |
- assert.NilError(c, err, out) |
|
| 1818 |
+ assert.NilError(t, err, out) |
|
| 1819 | 1819 |
if strings.Contains(out, event) {
|
| 1820 | 1820 |
return strings.TrimSpace(out) |
| 1821 | 1821 |
} |
| ... | ... |
@@ -1824,7 +1824,7 @@ func waitForEvent(c *testing.T, d *daemon.Daemon, since string, filter string, e |
| 1824 | 1824 |
time.Sleep(200 * time.Millisecond) |
| 1825 | 1825 |
} |
| 1826 | 1826 |
} |
| 1827 |
- c.Fatalf("docker events output '%s' doesn't contain event '%s'", out, event)
|
|
| 1827 |
+ t.Fatalf("docker events output '%s' doesn't contain event '%s'", out, event)
|
|
| 1828 | 1828 |
return "" |
| 1829 | 1829 |
} |
| 1830 | 1830 |
|
| ... | ... |
@@ -2023,14 +2023,14 @@ func (s *DockerSwarmSuite) TestSwarmClusterEventsConfig(c *testing.T) {
|
| 2023 | 2023 |
waitForEvent(c, d, t1, "-f type=config", "config remove "+id, defaultRetryCount) |
| 2024 | 2024 |
} |
| 2025 | 2025 |
|
| 2026 |
-func getUnlockKey(d *daemon.Daemon, c *testing.T, autolockOutput string) string {
|
|
| 2026 |
+func getUnlockKey(d *daemon.Daemon, t *testing.T, autolockOutput string) string {
|
|
| 2027 | 2027 |
unlockKey, err := d.Cmd("swarm", "unlock-key", "-q")
|
| 2028 |
- assert.Assert(c, err == nil, unlockKey) |
|
| 2028 |
+ assert.Assert(t, err == nil, unlockKey) |
|
| 2029 | 2029 |
unlockKey = strings.TrimSuffix(unlockKey, "\n") |
| 2030 | 2030 |
|
| 2031 | 2031 |
// Check that "docker swarm init --autolock" or "docker swarm update --autolock" |
| 2032 | 2032 |
// contains all the expected strings, including the unlock key |
| 2033 |
- assert.Assert(c, strings.Contains(autolockOutput, "docker swarm unlock"), autolockOutput) |
|
| 2034 |
- assert.Assert(c, strings.Contains(autolockOutput, unlockKey), autolockOutput) |
|
| 2033 |
+ assert.Assert(t, strings.Contains(autolockOutput, "docker swarm unlock"), autolockOutput) |
|
| 2034 |
+ assert.Assert(t, strings.Contains(autolockOutput, unlockKey), autolockOutput) |
|
| 2035 | 2035 |
return unlockKey |
| 2036 | 2036 |
} |
| ... | ... |
@@ -14,12 +14,12 @@ type DockerCLITopSuite struct {
|
| 14 | 14 |
ds *DockerSuite |
| 15 | 15 |
} |
| 16 | 16 |
|
| 17 |
-func (s *DockerCLITopSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 18 |
- s.ds.TearDownTest(ctx, c) |
|
| 17 |
+func (s *DockerCLITopSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 18 |
+ s.ds.TearDownTest(ctx, t) |
|
| 19 | 19 |
} |
| 20 | 20 |
|
| 21 |
-func (s *DockerCLITopSuite) OnTimeout(c *testing.T) {
|
|
| 22 |
- s.ds.OnTimeout(c) |
|
| 21 |
+func (s *DockerCLITopSuite) OnTimeout(t *testing.T) {
|
|
| 22 |
+ s.ds.OnTimeout(t) |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
func (s *DockerCLITopSuite) TestTopMultipleArgs(c *testing.T) {
|
| ... | ... |
@@ -22,12 +22,12 @@ import ( |
| 22 | 22 |
"gotest.tools/v3/skip" |
| 23 | 23 |
) |
| 24 | 24 |
|
| 25 |
-func (s *DockerCLIUpdateSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 26 |
- s.ds.TearDownTest(ctx, c) |
|
| 25 |
+func (s *DockerCLIUpdateSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 26 |
+ s.ds.TearDownTest(ctx, t) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
-func (s *DockerCLIUpdateSuite) OnTimeout(c *testing.T) {
|
|
| 30 |
- s.ds.OnTimeout(c) |
|
| 29 |
+func (s *DockerCLIUpdateSuite) OnTimeout(t *testing.T) {
|
|
| 30 |
+ s.ds.OnTimeout(t) |
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
func (s *DockerCLIUpdateSuite) TestUpdateRunningContainer(c *testing.T) {
|
| ... | ... |
@@ -95,13 +95,13 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *testing.T) {
|
| 95 | 95 |
} |
| 96 | 96 |
|
| 97 | 97 |
// findUser finds the uid or name of the user of the first process that runs in a container |
| 98 |
-func (s *DockerDaemonSuite) findUser(c *testing.T, container string) string {
|
|
| 98 |
+func (s *DockerDaemonSuite) findUser(t *testing.T, container string) string {
|
|
| 99 | 99 |
out, err := s.d.Cmd("top", container)
|
| 100 |
- assert.Assert(c, err == nil, "Output: %s", out) |
|
| 100 |
+ assert.Assert(t, err == nil, "Output: %s", out) |
|
| 101 | 101 |
rows := strings.Split(out, "\n") |
| 102 | 102 |
if len(rows) < 2 {
|
| 103 | 103 |
// No process rows founds |
| 104 |
- c.FailNow() |
|
| 104 |
+ t.FailNow() |
|
| 105 | 105 |
} |
| 106 | 106 |
return strings.Fields(rows[1])[0] |
| 107 | 107 |
} |
| ... | ... |
@@ -25,12 +25,12 @@ type DockerCLIVolumeSuite struct {
|
| 25 | 25 |
ds *DockerSuite |
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 |
-func (s *DockerCLIVolumeSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 29 |
- s.ds.TearDownTest(ctx, c) |
|
| 28 |
+func (s *DockerCLIVolumeSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 29 |
+ s.ds.TearDownTest(ctx, t) |
|
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 |
-func (s *DockerCLIVolumeSuite) OnTimeout(c *testing.T) {
|
|
| 33 |
- s.ds.OnTimeout(c) |
|
| 32 |
+func (s *DockerCLIVolumeSuite) OnTimeout(t *testing.T) {
|
|
| 33 |
+ s.ds.OnTimeout(t) |
|
| 34 | 34 |
} |
| 35 | 35 |
|
| 36 | 36 |
func (s *DockerCLIVolumeSuite) TestVolumeCLICreate(c *testing.T) {
|
| ... | ... |
@@ -119,7 +119,7 @@ func (s *DockerCLIVolumeSuite) TestVolumeLsFormatDefaultFormat(c *testing.T) {
|
| 119 | 119 |
assertVolumesInList(c, out, []string{"aaa default", "soo default", "test default"})
|
| 120 | 120 |
} |
| 121 | 121 |
|
| 122 |
-func assertVolumesInList(c *testing.T, out string, expected []string) {
|
|
| 122 |
+func assertVolumesInList(t *testing.T, out string, expected []string) {
|
|
| 123 | 123 |
lines := strings.Split(strings.TrimSpace(out), "\n") |
| 124 | 124 |
for _, expect := range expected {
|
| 125 | 125 |
found := false |
| ... | ... |
@@ -129,7 +129,7 @@ func assertVolumesInList(c *testing.T, out string, expected []string) {
|
| 129 | 129 |
break |
| 130 | 130 |
} |
| 131 | 131 |
} |
| 132 |
- assert.Assert(c, found, "Expected volume not found: %v, got: %v", expect, lines) |
|
| 132 |
+ assert.Assert(t, found, "Expected volume not found: %v, got: %v", expect, lines) |
|
| 133 | 133 |
} |
| 134 | 134 |
} |
| 135 | 135 |
|
| ... | ... |
@@ -31,38 +31,38 @@ func newDockerHubPullSuite() *DockerHubPullSuite {
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
// SetUpSuite starts the suite daemon. |
| 34 |
-func (s *DockerHubPullSuite) SetUpSuite(ctx context.Context, c *testing.T) {
|
|
| 35 |
- testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon) |
|
| 36 |
- s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 37 |
- s.d.Start(c) |
|
| 34 |
+func (s *DockerHubPullSuite) SetUpSuite(ctx context.Context, t *testing.T) {
|
|
| 35 |
+ testRequires(t, DaemonIsLinux, testEnv.IsLocalDaemon) |
|
| 36 |
+ s.d = daemon.New(t, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) |
|
| 37 |
+ s.d.Start(t) |
|
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 | 40 |
// TearDownSuite stops the suite daemon. |
| 41 |
-func (s *DockerHubPullSuite) TearDownSuite(ctx context.Context, c *testing.T) {
|
|
| 41 |
+func (s *DockerHubPullSuite) TearDownSuite(ctx context.Context, t *testing.T) {
|
|
| 42 | 42 |
if s.d != nil {
|
| 43 |
- s.d.Stop(c) |
|
| 43 |
+ s.d.Stop(t) |
|
| 44 | 44 |
} |
| 45 | 45 |
} |
| 46 | 46 |
|
| 47 | 47 |
// SetUpTest declares that all tests of this suite require network. |
| 48 |
-func (s *DockerHubPullSuite) SetUpTest(ctx context.Context, c *testing.T) {
|
|
| 49 |
- testRequires(c, Network) |
|
| 48 |
+func (s *DockerHubPullSuite) SetUpTest(ctx context.Context, t *testing.T) {
|
|
| 49 |
+ testRequires(t, Network) |
|
| 50 | 50 |
} |
| 51 | 51 |
|
| 52 | 52 |
// TearDownTest removes all images from the suite daemon. |
| 53 |
-func (s *DockerHubPullSuite) TearDownTest(ctx context.Context, c *testing.T) {
|
|
| 54 |
- out := s.Cmd(c, "images", "-aq") |
|
| 53 |
+func (s *DockerHubPullSuite) TearDownTest(ctx context.Context, t *testing.T) {
|
|
| 54 |
+ out := s.Cmd(t, "images", "-aq") |
|
| 55 | 55 |
images := strings.Split(out, "\n") |
| 56 | 56 |
images = append([]string{"rmi", "-f"}, images...)
|
| 57 | 57 |
s.d.Cmd(images...) |
| 58 |
- s.ds.TearDownTest(ctx, c) |
|
| 58 |
+ s.ds.TearDownTest(ctx, t) |
|
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 | 61 |
// Cmd executes a command against the suite daemon and returns the combined |
| 62 | 62 |
// output. The function fails the test when the command returns an error. |
| 63 |
-func (s *DockerHubPullSuite) Cmd(c *testing.T, name string, arg ...string) string {
|
|
| 63 |
+func (s *DockerHubPullSuite) Cmd(t *testing.T, name string, arg ...string) string {
|
|
| 64 | 64 |
out, err := s.CmdWithError(name, arg...) |
| 65 |
- assert.Assert(c, err == nil, "%q failed with errors: %s, %v", strings.Join(arg, " "), out, err) |
|
| 65 |
+ assert.Assert(t, err == nil, "%q failed with errors: %s, %v", strings.Join(arg, " "), out, err) |
|
| 66 | 66 |
return out |
| 67 | 67 |
} |
| 68 | 68 |
|
| ... | ... |
@@ -47,18 +47,18 @@ func dockerCmdWithResult(args ...string) *icmd.Result {
|
| 47 | 47 |
return cli.Docker(cli.Args(args...)) |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
-func findContainerIP(c *testing.T, id string, network string) string {
|
|
| 51 |
- c.Helper() |
|
| 52 |
- out := cli.DockerCmd(c, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id).Stdout()
|
|
| 50 |
+func findContainerIP(t *testing.T, id string, network string) string {
|
|
| 51 |
+ t.Helper() |
|
| 52 |
+ out := cli.DockerCmd(t, "inspect", fmt.Sprintf("--format='{{ .NetworkSettings.Networks.%s.IPAddress }}'", network), id).Stdout()
|
|
| 53 | 53 |
return strings.Trim(out, " \r\n'") |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 |
-func getContainerCount(c *testing.T) int {
|
|
| 57 |
- c.Helper() |
|
| 56 |
+func getContainerCount(t *testing.T) int {
|
|
| 57 |
+ t.Helper() |
|
| 58 | 58 |
const containers = "Containers:" |
| 59 | 59 |
|
| 60 | 60 |
result := icmd.RunCommand(dockerBinary, "info") |
| 61 |
- result.Assert(c, icmd.Success) |
|
| 61 |
+ result.Assert(t, icmd.Success) |
|
| 62 | 62 |
|
| 63 | 63 |
lines := strings.Split(result.Combined(), "\n") |
| 64 | 64 |
for _, line := range lines {
|
| ... | ... |
@@ -67,18 +67,18 @@ func getContainerCount(c *testing.T) int {
|
| 67 | 67 |
output = strings.TrimPrefix(output, containers) |
| 68 | 68 |
output = strings.Trim(output, " ") |
| 69 | 69 |
containerCount, err := strconv.Atoi(output) |
| 70 |
- assert.NilError(c, err) |
|
| 70 |
+ assert.NilError(t, err) |
|
| 71 | 71 |
return containerCount |
| 72 | 72 |
} |
| 73 | 73 |
} |
| 74 | 74 |
return 0 |
| 75 | 75 |
} |
| 76 | 76 |
|
| 77 |
-func inspectFieldAndUnmarshall(c *testing.T, name, field string, output interface{}) {
|
|
| 78 |
- c.Helper() |
|
| 79 |
- str := inspectFieldJSON(c, name, field) |
|
| 77 |
+func inspectFieldAndUnmarshall(t *testing.T, name, field string, output interface{}) {
|
|
| 78 |
+ t.Helper() |
|
| 79 |
+ str := inspectFieldJSON(t, name, field) |
|
| 80 | 80 |
err := json.Unmarshal([]byte(str), output) |
| 81 |
- assert.Assert(c, err == nil, "failed to unmarshal: %v", err) |
|
| 81 |
+ assert.Assert(t, err == nil, "failed to unmarshal: %v", err) |
|
| 82 | 82 |
} |
| 83 | 83 |
|
| 84 | 84 |
// Deprecated: use cli.Docker |
| ... | ... |
@@ -97,26 +97,26 @@ func inspectFieldWithError(name, field string) (string, error) {
|
| 97 | 97 |
} |
| 98 | 98 |
|
| 99 | 99 |
// Deprecated: use cli.Docker |
| 100 |
-func inspectField(c *testing.T, name, field string) string {
|
|
| 101 |
- c.Helper() |
|
| 100 |
+func inspectField(t *testing.T, name, field string) string {
|
|
| 101 |
+ t.Helper() |
|
| 102 | 102 |
out, err := inspectFilter(name, "."+field) |
| 103 |
- assert.NilError(c, err) |
|
| 103 |
+ assert.NilError(t, err) |
|
| 104 | 104 |
return out |
| 105 | 105 |
} |
| 106 | 106 |
|
| 107 | 107 |
// Deprecated: use cli.Docker |
| 108 |
-func inspectFieldJSON(c *testing.T, name, field string) string {
|
|
| 109 |
- c.Helper() |
|
| 108 |
+func inspectFieldJSON(t *testing.T, name, field string) string {
|
|
| 109 |
+ t.Helper() |
|
| 110 | 110 |
out, err := inspectFilter(name, "json ."+field) |
| 111 |
- assert.NilError(c, err) |
|
| 111 |
+ assert.NilError(t, err) |
|
| 112 | 112 |
return out |
| 113 | 113 |
} |
| 114 | 114 |
|
| 115 | 115 |
// Deprecated: use cli.Docker |
| 116 |
-func inspectFieldMap(c *testing.T, name, path, field string) string {
|
|
| 117 |
- c.Helper() |
|
| 116 |
+func inspectFieldMap(t *testing.T, name, path, field string) string {
|
|
| 117 |
+ t.Helper() |
|
| 118 | 118 |
out, err := inspectFilter(name, fmt.Sprintf("index .%s %q", path, field))
|
| 119 |
- assert.NilError(c, err) |
|
| 119 |
+ assert.NilError(t, err) |
|
| 120 | 120 |
return out |
| 121 | 121 |
} |
| 122 | 122 |
|
| ... | ... |
@@ -152,17 +152,17 @@ func inspectMountPoint(name, destination string) (container.MountPoint, error) {
|
| 152 | 152 |
return container.MountPoint{}, errMountNotFound
|
| 153 | 153 |
} |
| 154 | 154 |
|
| 155 |
-func getIDByName(c *testing.T, name string) string {
|
|
| 156 |
- c.Helper() |
|
| 155 |
+func getIDByName(t *testing.T, name string) string {
|
|
| 156 |
+ t.Helper() |
|
| 157 | 157 |
id, err := inspectFieldWithError(name, "Id") |
| 158 |
- assert.NilError(c, err) |
|
| 158 |
+ assert.NilError(t, err) |
|
| 159 | 159 |
return id |
| 160 | 160 |
} |
| 161 | 161 |
|
| 162 | 162 |
// Deprecated: use cli.Docker |
| 163 |
-func buildImageSuccessfully(c *testing.T, name string, cmdOperators ...cli.CmdOperator) {
|
|
| 164 |
- c.Helper() |
|
| 165 |
- buildImage(name, cmdOperators...).Assert(c, icmd.Success) |
|
| 163 |
+func buildImageSuccessfully(t *testing.T, name string, cmdOperators ...cli.CmdOperator) {
|
|
| 164 |
+ t.Helper() |
|
| 165 |
+ buildImage(name, cmdOperators...).Assert(t, icmd.Success) |
|
| 166 | 166 |
} |
| 167 | 167 |
|
| 168 | 168 |
// Deprecated: use cli.Docker |
| ... | ... |
@@ -174,24 +174,24 @@ func buildImage(name string, cmdOperators ...cli.CmdOperator) *icmd.Result {
|
| 174 | 174 |
// as well as any missing directories. |
| 175 | 175 |
// The file is truncated if it already exists. |
| 176 | 176 |
// Fail the test when error occurs. |
| 177 |
-func writeFile(dst, content string, c *testing.T) {
|
|
| 178 |
- c.Helper() |
|
| 177 |
+func writeFile(dst, content string, t *testing.T) {
|
|
| 178 |
+ t.Helper() |
|
| 179 | 179 |
// Create subdirectories if necessary |
| 180 |
- assert.NilError(c, os.MkdirAll(path.Dir(dst), 0o700)) |
|
| 180 |
+ assert.NilError(t, os.MkdirAll(path.Dir(dst), 0o700)) |
|
| 181 | 181 |
f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o600) |
| 182 |
- assert.NilError(c, err) |
|
| 182 |
+ assert.NilError(t, err) |
|
| 183 | 183 |
defer f.Close() |
| 184 | 184 |
// Write content (truncate if it exists) |
| 185 | 185 |
_, err = io.Copy(f, strings.NewReader(content)) |
| 186 |
- assert.NilError(c, err) |
|
| 186 |
+ assert.NilError(t, err) |
|
| 187 | 187 |
} |
| 188 | 188 |
|
| 189 | 189 |
// Return the contents of file at path `src`. |
| 190 | 190 |
// Fail the test when error occurs. |
| 191 |
-func readFile(src string, c *testing.T) (content string) {
|
|
| 192 |
- c.Helper() |
|
| 191 |
+func readFile(src string, t *testing.T) (content string) {
|
|
| 192 |
+ t.Helper() |
|
| 193 | 193 |
data, err := os.ReadFile(src) |
| 194 |
- assert.NilError(c, err) |
|
| 194 |
+ assert.NilError(t, err) |
|
| 195 | 195 |
|
| 196 | 196 |
return string(data) |
| 197 | 197 |
} |
| ... | ... |
@@ -201,56 +201,56 @@ func containerStorageFile(containerID, basename string) string {
|
| 201 | 201 |
} |
| 202 | 202 |
|
| 203 | 203 |
// docker commands that use this function must be run with the '-d' switch. |
| 204 |
-func runCommandAndReadContainerFile(c *testing.T, filename string, command string, args ...string) []byte {
|
|
| 205 |
- c.Helper() |
|
| 204 |
+func runCommandAndReadContainerFile(t *testing.T, filename string, command string, args ...string) []byte {
|
|
| 205 |
+ t.Helper() |
|
| 206 | 206 |
result := icmd.RunCommand(command, args...) |
| 207 |
- result.Assert(c, icmd.Success) |
|
| 207 |
+ result.Assert(t, icmd.Success) |
|
| 208 | 208 |
contID := strings.TrimSpace(result.Combined()) |
| 209 |
- cli.WaitRun(c, contID) |
|
| 210 |
- return readContainerFile(c, contID, filename) |
|
| 209 |
+ cli.WaitRun(t, contID) |
|
| 210 |
+ return readContainerFile(t, contID, filename) |
|
| 211 | 211 |
} |
| 212 | 212 |
|
| 213 |
-func readContainerFile(c *testing.T, containerID, filename string) []byte {
|
|
| 214 |
- c.Helper() |
|
| 213 |
+func readContainerFile(t *testing.T, containerID, filename string) []byte {
|
|
| 214 |
+ t.Helper() |
|
| 215 | 215 |
f, err := os.Open(containerStorageFile(containerID, filename)) |
| 216 |
- assert.NilError(c, err) |
|
| 216 |
+ assert.NilError(t, err) |
|
| 217 | 217 |
defer f.Close() |
| 218 | 218 |
|
| 219 | 219 |
content, err := io.ReadAll(f) |
| 220 |
- assert.NilError(c, err) |
|
| 220 |
+ assert.NilError(t, err) |
|
| 221 | 221 |
return content |
| 222 | 222 |
} |
| 223 | 223 |
|
| 224 |
-func readContainerFileWithExec(c *testing.T, containerID, filename string) []byte {
|
|
| 225 |
- c.Helper() |
|
| 224 |
+func readContainerFileWithExec(t *testing.T, containerID, filename string) []byte {
|
|
| 225 |
+ t.Helper() |
|
| 226 | 226 |
result := icmd.RunCommand(dockerBinary, "exec", containerID, "cat", filename) |
| 227 |
- result.Assert(c, icmd.Success) |
|
| 227 |
+ result.Assert(t, icmd.Success) |
|
| 228 | 228 |
return []byte(result.Combined()) |
| 229 | 229 |
} |
| 230 | 230 |
|
| 231 | 231 |
// daemonTime provides the current time on the daemon host |
| 232 |
-func daemonTime(c *testing.T) time.Time {
|
|
| 233 |
- c.Helper() |
|
| 232 |
+func daemonTime(t *testing.T) time.Time {
|
|
| 233 |
+ t.Helper() |
|
| 234 | 234 |
if testEnv.IsLocalDaemon() {
|
| 235 | 235 |
return time.Now() |
| 236 | 236 |
} |
| 237 | 237 |
apiClient, err := client.NewClientWithOpts(client.FromEnv) |
| 238 |
- assert.NilError(c, err) |
|
| 238 |
+ assert.NilError(t, err) |
|
| 239 | 239 |
defer apiClient.Close() |
| 240 | 240 |
|
| 241 |
- info, err := apiClient.Info(testutil.GetContext(c)) |
|
| 242 |
- assert.NilError(c, err) |
|
| 241 |
+ info, err := apiClient.Info(testutil.GetContext(t)) |
|
| 242 |
+ assert.NilError(t, err) |
|
| 243 | 243 |
|
| 244 | 244 |
dt, err := time.Parse(time.RFC3339Nano, info.SystemTime) |
| 245 |
- assert.Assert(c, err == nil, "invalid time format in GET /info response") |
|
| 245 |
+ assert.Assert(t, err == nil, "invalid time format in GET /info response") |
|
| 246 | 246 |
return dt |
| 247 | 247 |
} |
| 248 | 248 |
|
| 249 | 249 |
// daemonUnixTime returns the current time on the daemon host with nanoseconds precision. |
| 250 | 250 |
// It return the time formatted how the client sends timestamps to the server. |
| 251 |
-func daemonUnixTime(c *testing.T) string {
|
|
| 252 |
- c.Helper() |
|
| 253 |
- return parseEventTime(daemonTime(c)) |
|
| 251 |
+func daemonUnixTime(t *testing.T) string {
|
|
| 252 |
+ t.Helper() |
|
| 253 |
+ return parseEventTime(daemonTime(t)) |
|
| 254 | 254 |
} |
| 255 | 255 |
|
| 256 | 256 |
func parseEventTime(t time.Time) string {
|
| ... | ... |
@@ -284,15 +284,15 @@ func appendBaseEnv(isTLS bool, env ...string) []string {
|
| 284 | 284 |
return env |
| 285 | 285 |
} |
| 286 | 286 |
|
| 287 |
-func createTmpFile(c *testing.T, content string) string {
|
|
| 288 |
- c.Helper() |
|
| 287 |
+func createTmpFile(t *testing.T, content string) string {
|
|
| 288 |
+ t.Helper() |
|
| 289 | 289 |
f, err := os.CreateTemp("", "testfile")
|
| 290 |
- assert.NilError(c, err) |
|
| 290 |
+ assert.NilError(t, err) |
|
| 291 | 291 |
|
| 292 | 292 |
filename := f.Name() |
| 293 | 293 |
|
| 294 | 294 |
err = os.WriteFile(filename, []byte(content), 0o644) |
| 295 |
- assert.NilError(c, err) |
|
| 295 |
+ assert.NilError(t, err) |
|
| 296 | 296 |
|
| 297 | 297 |
return filename |
| 298 | 298 |
} |
| ... | ... |
@@ -305,32 +305,32 @@ func waitInspect(name, expr, expected string, timeout time.Duration) error {
|
| 305 | 305 |
return daemon.WaitInspectWithArgs(dockerBinary, name, expr, expected, timeout) |
| 306 | 306 |
} |
| 307 | 307 |
|
| 308 |
-func getInspectBody(c *testing.T, version, id string) []byte {
|
|
| 309 |
- c.Helper() |
|
| 308 |
+func getInspectBody(t *testing.T, version, id string) []byte {
|
|
| 309 |
+ t.Helper() |
|
| 310 | 310 |
apiClient, err := client.NewClientWithOpts(client.FromEnv, client.WithVersion(version)) |
| 311 |
- assert.NilError(c, err) |
|
| 311 |
+ assert.NilError(t, err) |
|
| 312 | 312 |
defer apiClient.Close() |
| 313 |
- _, body, err := apiClient.ContainerInspectWithRaw(testutil.GetContext(c), id, false) |
|
| 314 |
- assert.NilError(c, err) |
|
| 313 |
+ _, body, err := apiClient.ContainerInspectWithRaw(testutil.GetContext(t), id, false) |
|
| 314 |
+ assert.NilError(t, err) |
|
| 315 | 315 |
return body |
| 316 | 316 |
} |
| 317 | 317 |
|
| 318 | 318 |
// Run a long running idle task in a background container using the |
| 319 | 319 |
// system-specific default image and command. |
| 320 |
-func runSleepingContainer(c *testing.T, extraArgs ...string) string {
|
|
| 321 |
- c.Helper() |
|
| 322 |
- return runSleepingContainerInImage(c, "busybox", extraArgs...) |
|
| 320 |
+func runSleepingContainer(t *testing.T, extraArgs ...string) string {
|
|
| 321 |
+ t.Helper() |
|
| 322 |
+ return runSleepingContainerInImage(t, "busybox", extraArgs...) |
|
| 323 | 323 |
} |
| 324 | 324 |
|
| 325 | 325 |
// Run a long running idle task in a background container using the specified |
| 326 | 326 |
// image and the system-specific command. |
| 327 |
-func runSleepingContainerInImage(c *testing.T, image string, extraArgs ...string) string {
|
|
| 328 |
- c.Helper() |
|
| 327 |
+func runSleepingContainerInImage(t *testing.T, image string, extraArgs ...string) string {
|
|
| 328 |
+ t.Helper() |
|
| 329 | 329 |
args := []string{"run", "-d"}
|
| 330 | 330 |
args = append(args, extraArgs...) |
| 331 | 331 |
args = append(args, image) |
| 332 | 332 |
args = append(args, sleepCommandForDaemonPlatform()...) |
| 333 |
- return strings.TrimSpace(cli.DockerCmd(c, args...).Combined()) |
|
| 333 |
+ return strings.TrimSpace(cli.DockerCmd(t, args...).Combined()) |
|
| 334 | 334 |
} |
| 335 | 335 |
|
| 336 | 336 |
// minimalBaseImage returns the name of the minimal base image for the current |
| ... | ... |
@@ -405,10 +405,10 @@ func waitForGoroutines(ctx context.Context, t poll.TestingT, apiClient client.AP |
| 405 | 405 |
} |
| 406 | 406 |
|
| 407 | 407 |
// getErrorMessage returns the error message from an error API response |
| 408 |
-func getErrorMessage(c *testing.T, body []byte) string {
|
|
| 409 |
- c.Helper() |
|
| 408 |
+func getErrorMessage(t *testing.T, body []byte) string {
|
|
| 409 |
+ t.Helper() |
|
| 410 | 410 |
var resp types.ErrorResponse |
| 411 |
- assert.NilError(c, json.Unmarshal(body, &resp)) |
|
| 411 |
+ assert.NilError(t, json.Unmarshal(body, &resp)) |
|
| 412 | 412 |
return strings.TrimSpace(resp.Message) |
| 413 | 413 |
} |
| 414 | 414 |
|
| ... | ... |
@@ -439,12 +439,12 @@ func pollCheck(t *testing.T, f checkF, compare func(x interface{}) assert.BoolOr
|
| 439 | 439 |
} |
| 440 | 440 |
|
| 441 | 441 |
func reducedCheck(r reducer, funcs ...checkF) checkF {
|
| 442 |
- return func(c *testing.T) (interface{}, string) {
|
|
| 443 |
- c.Helper() |
|
| 442 |
+ return func(t *testing.T) (interface{}, string) {
|
|
| 443 |
+ t.Helper() |
|
| 444 | 444 |
var values []interface{}
|
| 445 | 445 |
var comments []string |
| 446 | 446 |
for _, f := range funcs {
|
| 447 |
- v, comment := f(c) |
|
| 447 |
+ v, comment := f(t) |
|
| 448 | 448 |
values = append(values, v) |
| 449 | 449 |
if len(comment) > 0 {
|
| 450 | 450 |
comments = append(comments, comment) |
| ... | ... |
@@ -462,31 +462,31 @@ func sumAsIntegers(vals ...interface{}) interface{} {
|
| 462 | 462 |
return s |
| 463 | 463 |
} |
| 464 | 464 |
|
| 465 |
-func loadSpecialImage(c *testing.T, imageFunc specialimage.SpecialImageFunc) string {
|
|
| 466 |
- tmpDir := c.TempDir() |
|
| 465 |
+func loadSpecialImage(t *testing.T, imageFunc specialimage.SpecialImageFunc) string {
|
|
| 466 |
+ tmpDir := t.TempDir() |
|
| 467 | 467 |
|
| 468 | 468 |
imgDir := filepath.Join(tmpDir, "image") |
| 469 |
- assert.NilError(c, os.Mkdir(imgDir, 0o755)) |
|
| 469 |
+ assert.NilError(t, os.Mkdir(imgDir, 0o755)) |
|
| 470 | 470 |
|
| 471 | 471 |
_, err := imageFunc(imgDir) |
| 472 |
- assert.NilError(c, err) |
|
| 472 |
+ assert.NilError(t, err) |
|
| 473 | 473 |
|
| 474 | 474 |
rc, err := archive.TarWithOptions(imgDir, &archive.TarOptions{})
|
| 475 |
- assert.NilError(c, err) |
|
| 475 |
+ assert.NilError(t, err) |
|
| 476 | 476 |
defer rc.Close() |
| 477 | 477 |
|
| 478 | 478 |
imgTar := filepath.Join(tmpDir, "image.tar") |
| 479 | 479 |
tarFile, err := os.OpenFile(imgTar, os.O_CREATE|os.O_WRONLY, 0o644) |
| 480 |
- assert.NilError(c, err) |
|
| 480 |
+ assert.NilError(t, err) |
|
| 481 | 481 |
|
| 482 | 482 |
defer tarFile.Close() |
| 483 | 483 |
|
| 484 | 484 |
_, err = io.Copy(tarFile, rc) |
| 485 |
- assert.NilError(c, err) |
|
| 485 |
+ assert.NilError(t, err) |
|
| 486 | 486 |
|
| 487 | 487 |
tarFile.Close() |
| 488 | 488 |
|
| 489 |
- out := cli.DockerCmd(c, "load", "-i", imgTar).Stdout() |
|
| 489 |
+ out := cli.DockerCmd(t, "load", "-i", imgTar).Stdout() |
|
| 490 | 490 |
|
| 491 | 491 |
for _, line := range strings.Split(out, "\n") {
|
| 492 | 492 |
line = strings.TrimSpace(line) |
| ... | ... |
@@ -499,6 +499,6 @@ func loadSpecialImage(c *testing.T, imageFunc specialimage.SpecialImageFunc) str |
| 499 | 499 |
} |
| 500 | 500 |
} |
| 501 | 501 |
|
| 502 |
- c.Fatalf("failed to extract image ref from %q", out)
|
|
| 502 |
+ t.Fatalf("failed to extract image ref from %q", out)
|
|
| 503 | 503 |
return "" |
| 504 | 504 |
} |
| ... | ... |
@@ -37,13 +37,13 @@ type eventObserver struct {
|
| 37 | 37 |
|
| 38 | 38 |
// newEventObserver creates the observer and initializes the command |
| 39 | 39 |
// without running it. Users must call `eventObserver.Start` to start the command. |
| 40 |
-func newEventObserver(c *testing.T, args ...string) (*eventObserver, error) {
|
|
| 41 |
- since := daemonTime(c).Unix() |
|
| 42 |
- return newEventObserverWithBacklog(c, since, args...) |
|
| 40 |
+func newEventObserver(t *testing.T, args ...string) (*eventObserver, error) {
|
|
| 41 |
+ since := daemonTime(t).Unix() |
|
| 42 |
+ return newEventObserverWithBacklog(t, since, args...) |
|
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 | 45 |
// newEventObserverWithBacklog creates a new observer changing the start time of the backlog to return. |
| 46 |
-func newEventObserverWithBacklog(c *testing.T, since int64, args ...string) (*eventObserver, error) {
|
|
| 46 |
+func newEventObserverWithBacklog(t *testing.T, since int64, args ...string) (*eventObserver, error) {
|
|
| 47 | 47 |
startTime := strconv.FormatInt(since, 10) |
| 48 | 48 |
cmdArgs := []string{"events", "--since", startTime}
|
| 49 | 49 |
if len(args) > 0 {
|
| ... | ... |
@@ -95,13 +95,13 @@ func (e *eventObserver) Match(match eventMatcher, process eventMatchProcessor) {
|
| 95 | 95 |
e.disconnectionError = err |
| 96 | 96 |
} |
| 97 | 97 |
|
| 98 |
-func (e *eventObserver) CheckEventError(c *testing.T, id, event string, match eventMatcher) {
|
|
| 98 |
+func (e *eventObserver) CheckEventError(t *testing.T, id, event string, match eventMatcher) {
|
|
| 99 | 99 |
var foundEvent bool |
| 100 | 100 |
scannerOut := e.buffer.String() |
| 101 | 101 |
|
| 102 | 102 |
if e.disconnectionError != nil {
|
| 103 |
- until := daemonUnixTime(c) |
|
| 104 |
- out := cli.DockerCmd(c, "events", "--since", e.startTime, "--until", until).Stdout() |
|
| 103 |
+ until := daemonUnixTime(t) |
|
| 104 |
+ out := cli.DockerCmd(t, "events", "--since", e.startTime, "--until", until).Stdout() |
|
| 105 | 105 |
events := strings.Split(strings.TrimSpace(out), "\n") |
| 106 | 106 |
for _, e := range events {
|
| 107 | 107 |
if _, ok := match(e); ok {
|
| ... | ... |
@@ -112,7 +112,7 @@ func (e *eventObserver) CheckEventError(c *testing.T, id, event string, match ev |
| 112 | 112 |
scannerOut = out |
| 113 | 113 |
} |
| 114 | 114 |
if !foundEvent {
|
| 115 |
- c.Fatalf("failed to observe event `%s` for %s. Disconnection error: %v\nout:\n%v", event, id, e.disconnectionError, scannerOut)
|
|
| 115 |
+ t.Fatalf("failed to observe event `%s` for %s. Disconnection error: %v\nout:\n%v", event, id, e.disconnectionError, scannerOut)
|
|
| 116 | 116 |
} |
| 117 | 117 |
} |
| 118 | 118 |
|
| ... | ... |
@@ -146,18 +146,18 @@ func processEventMatch(actions map[string]chan bool) eventMatchProcessor {
|
| 146 | 146 |
|
| 147 | 147 |
// parseEventAction parses an event text and returns the action. |
| 148 | 148 |
// It fails if the text is not in the event format. |
| 149 |
-func parseEventAction(c *testing.T, text string) string {
|
|
| 149 |
+func parseEventAction(t *testing.T, text string) string {
|
|
| 150 | 150 |
matches := eventstestutils.ScanMap(text) |
| 151 | 151 |
return matches["action"] |
| 152 | 152 |
} |
| 153 | 153 |
|
| 154 | 154 |
// eventActionsByIDAndType returns the actions for a given id and type. |
| 155 | 155 |
// It fails if the text is not in the event format. |
| 156 |
-func eventActionsByIDAndType(c *testing.T, events []string, id, eventType string) []string {
|
|
| 156 |
+func eventActionsByIDAndType(t *testing.T, events []string, id, eventType string) []string {
|
|
| 157 | 157 |
var filtered []string |
| 158 | 158 |
for _, event := range events {
|
| 159 | 159 |
matches := eventstestutils.ScanMap(event) |
| 160 |
- assert.Assert(c, matches != nil) |
|
| 160 |
+ assert.Assert(t, matches != nil) |
|
| 161 | 161 |
if matchIDAndEventType(matches, id, eventType) {
|
| 162 | 162 |
filtered = append(filtered, matches["action"]) |
| 163 | 163 |
} |
| ... | ... |
@@ -185,12 +185,12 @@ func matchEventID(matches map[string]string, id string) bool {
|
| 185 | 185 |
return matchID |
| 186 | 186 |
} |
| 187 | 187 |
|
| 188 |
-func parseEvents(c *testing.T, out, match string) {
|
|
| 188 |
+func parseEvents(t *testing.T, out, match string) {
|
|
| 189 | 189 |
events := strings.Split(strings.TrimSpace(out), "\n") |
| 190 | 190 |
for _, event := range events {
|
| 191 | 191 |
matches := eventstestutils.ScanMap(event) |
| 192 | 192 |
matched, err := regexp.MatchString(match, matches["action"]) |
| 193 |
- assert.NilError(c, err) |
|
| 194 |
- assert.Assert(c, matched, "Matcher: %s did not match %s", match, matches["action"]) |
|
| 193 |
+ assert.NilError(t, err) |
|
| 194 |
+ assert.Assert(t, matched, "Matcher: %s did not match %s", match, matches["action"]) |
|
| 195 | 195 |
} |
| 196 | 196 |
} |
| ... | ... |
@@ -15,37 +15,37 @@ import ( |
| 15 | 15 |
"gotest.tools/v3/assert" |
| 16 | 16 |
) |
| 17 | 17 |
|
| 18 |
-func ensureSyscallTest(ctx context.Context, c *testing.T) {
|
|
| 19 |
- defer testEnv.ProtectImage(c, "syscall-test:latest") |
|
| 18 |
+func ensureSyscallTest(ctx context.Context, t *testing.T) {
|
|
| 19 |
+ defer testEnv.ProtectImage(t, "syscall-test:latest") |
|
| 20 | 20 |
|
| 21 | 21 |
// If the image already exists, there's nothing left to do. |
| 22 |
- if testEnv.HasExistingImage(c, "syscall-test:latest") {
|
|
| 22 |
+ if testEnv.HasExistingImage(t, "syscall-test:latest") {
|
|
| 23 | 23 |
return |
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
// if no match, must build in docker, which is significantly slower |
| 27 | 27 |
// (slower mostly because of the vfs graphdriver) |
| 28 | 28 |
if testEnv.DaemonInfo.OSType != runtime.GOOS {
|
| 29 |
- ensureSyscallTestBuild(ctx, c) |
|
| 29 |
+ ensureSyscallTestBuild(ctx, t) |
|
| 30 | 30 |
return |
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
tmp, err := os.MkdirTemp("", "syscall-test-build")
|
| 34 |
- assert.NilError(c, err, "couldn't create temp dir") |
|
| 34 |
+ assert.NilError(t, err, "couldn't create temp dir") |
|
| 35 | 35 |
defer os.RemoveAll(tmp) |
| 36 | 36 |
|
| 37 | 37 |
gcc, err := exec.LookPath("gcc")
|
| 38 |
- assert.NilError(c, err, "could not find gcc") |
|
| 38 |
+ assert.NilError(t, err, "could not find gcc") |
|
| 39 | 39 |
|
| 40 | 40 |
tests := []string{"userns", "ns", "acct", "setuid", "setgid", "socket", "raw"}
|
| 41 | 41 |
for _, test := range tests {
|
| 42 | 42 |
out, err := exec.Command(gcc, "-g", "-Wall", "-static", fmt.Sprintf("../contrib/syscall-test/%s.c", test), "-o", fmt.Sprintf("%s/%s-test", tmp, test)).CombinedOutput()
|
| 43 |
- assert.NilError(c, err, string(out)) |
|
| 43 |
+ assert.NilError(t, err, string(out)) |
|
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 | 46 |
if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" {
|
| 47 | 47 |
out, err := exec.Command(gcc, "-s", "-m32", "-nostdlib", "-static", "../contrib/syscall-test/exit32.s", "-o", tmp+"/"+"exit32-test").CombinedOutput() |
| 48 |
- assert.NilError(c, err, string(out)) |
|
| 48 |
+ assert.NilError(t, err, string(out)) |
|
| 49 | 49 |
} |
| 50 | 50 |
|
| 51 | 51 |
dockerFile := filepath.Join(tmp, "Dockerfile") |
| ... | ... |
@@ -54,7 +54,7 @@ func ensureSyscallTest(ctx context.Context, c *testing.T) {
|
| 54 | 54 |
COPY . /usr/bin/ |
| 55 | 55 |
`) |
| 56 | 56 |
err = os.WriteFile(dockerFile, content, 0o600) |
| 57 |
- assert.NilError(c, err) |
|
| 57 |
+ assert.NilError(t, err) |
|
| 58 | 58 |
|
| 59 | 59 |
var buildArgs []string |
| 60 | 60 |
if arg := os.Getenv("DOCKER_BUILD_ARGS"); strings.TrimSpace(arg) != "" {
|
| ... | ... |
@@ -62,12 +62,12 @@ func ensureSyscallTest(ctx context.Context, c *testing.T) {
|
| 62 | 62 |
} |
| 63 | 63 |
buildArgs = append(buildArgs, []string{"-q", "-t", "syscall-test", tmp}...)
|
| 64 | 64 |
buildArgs = append([]string{"build"}, buildArgs...)
|
| 65 |
- cli.DockerCmd(c, buildArgs...) |
|
| 65 |
+ cli.DockerCmd(t, buildArgs...) |
|
| 66 | 66 |
} |
| 67 | 67 |
|
| 68 |
-func ensureSyscallTestBuild(ctx context.Context, c *testing.T) {
|
|
| 68 |
+func ensureSyscallTestBuild(ctx context.Context, t *testing.T) {
|
|
| 69 | 69 |
err := load.FrozenImagesLinux(ctx, testEnv.APIClient(), "debian:bookworm-slim") |
| 70 |
- assert.NilError(c, err) |
|
| 70 |
+ assert.NilError(t, err) |
|
| 71 | 71 |
|
| 72 | 72 |
var buildArgs []string |
| 73 | 73 |
if arg := os.Getenv("DOCKER_BUILD_ARGS"); strings.TrimSpace(arg) != "" {
|
| ... | ... |
@@ -75,32 +75,32 @@ func ensureSyscallTestBuild(ctx context.Context, c *testing.T) {
|
| 75 | 75 |
} |
| 76 | 76 |
buildArgs = append(buildArgs, []string{"-q", "-t", "syscall-test", "../contrib/syscall-test"}...)
|
| 77 | 77 |
buildArgs = append([]string{"build"}, buildArgs...)
|
| 78 |
- cli.DockerCmd(c, buildArgs...) |
|
| 78 |
+ cli.DockerCmd(t, buildArgs...) |
|
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 |
-func ensureNNPTest(ctx context.Context, c *testing.T) {
|
|
| 82 |
- defer testEnv.ProtectImage(c, "nnp-test:latest") |
|
| 81 |
+func ensureNNPTest(ctx context.Context, t *testing.T) {
|
|
| 82 |
+ defer testEnv.ProtectImage(t, "nnp-test:latest") |
|
| 83 | 83 |
|
| 84 | 84 |
// If the image already exists, there's nothing left to do. |
| 85 |
- if testEnv.HasExistingImage(c, "nnp-test:latest") {
|
|
| 85 |
+ if testEnv.HasExistingImage(t, "nnp-test:latest") {
|
|
| 86 | 86 |
return |
| 87 | 87 |
} |
| 88 | 88 |
|
| 89 | 89 |
// if no match, must build in docker, which is significantly slower |
| 90 | 90 |
// (slower mostly because of the vfs graphdriver) |
| 91 | 91 |
if testEnv.DaemonInfo.OSType != runtime.GOOS {
|
| 92 |
- ensureNNPTestBuild(ctx, c) |
|
| 92 |
+ ensureNNPTestBuild(ctx, t) |
|
| 93 | 93 |
return |
| 94 | 94 |
} |
| 95 | 95 |
|
| 96 | 96 |
tmp, err := os.MkdirTemp("", "docker-nnp-test")
|
| 97 |
- assert.NilError(c, err) |
|
| 97 |
+ assert.NilError(t, err) |
|
| 98 | 98 |
|
| 99 | 99 |
gcc, err := exec.LookPath("gcc")
|
| 100 |
- assert.NilError(c, err, "could not find gcc") |
|
| 100 |
+ assert.NilError(t, err, "could not find gcc") |
|
| 101 | 101 |
|
| 102 | 102 |
out, err := exec.Command(gcc, "-g", "-Wall", "-static", "../contrib/nnp-test/nnp-test.c", "-o", filepath.Join(tmp, "nnp-test")).CombinedOutput() |
| 103 |
- assert.NilError(c, err, string(out)) |
|
| 103 |
+ assert.NilError(t, err, string(out)) |
|
| 104 | 104 |
|
| 105 | 105 |
dockerfile := filepath.Join(tmp, "Dockerfile") |
| 106 | 106 |
content := ` |
| ... | ... |
@@ -109,7 +109,7 @@ func ensureNNPTest(ctx context.Context, c *testing.T) {
|
| 109 | 109 |
RUN chmod +s /usr/bin/nnp-test |
| 110 | 110 |
` |
| 111 | 111 |
err = os.WriteFile(dockerfile, []byte(content), 0o600) |
| 112 |
- assert.NilError(c, err, "could not write Dockerfile for nnp-test image") |
|
| 112 |
+ assert.NilError(t, err, "could not write Dockerfile for nnp-test image") |
|
| 113 | 113 |
|
| 114 | 114 |
var buildArgs []string |
| 115 | 115 |
if arg := os.Getenv("DOCKER_BUILD_ARGS"); strings.TrimSpace(arg) != "" {
|
| ... | ... |
@@ -117,12 +117,12 @@ func ensureNNPTest(ctx context.Context, c *testing.T) {
|
| 117 | 117 |
} |
| 118 | 118 |
buildArgs = append(buildArgs, []string{"-q", "-t", "nnp-test", tmp}...)
|
| 119 | 119 |
buildArgs = append([]string{"build"}, buildArgs...)
|
| 120 |
- cli.DockerCmd(c, buildArgs...) |
|
| 120 |
+ cli.DockerCmd(t, buildArgs...) |
|
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 |
-func ensureNNPTestBuild(ctx context.Context, c *testing.T) {
|
|
| 123 |
+func ensureNNPTestBuild(ctx context.Context, t *testing.T) {
|
|
| 124 | 124 |
err := load.FrozenImagesLinux(ctx, testEnv.APIClient(), "debian:bookworm-slim") |
| 125 |
- assert.NilError(c, err) |
|
| 125 |
+ assert.NilError(t, err) |
|
| 126 | 126 |
|
| 127 | 127 |
var buildArgs []string |
| 128 | 128 |
if arg := os.Getenv("DOCKER_BUILD_ARGS"); strings.TrimSpace(arg) != "" {
|
| ... | ... |
@@ -130,5 +130,5 @@ func ensureNNPTestBuild(ctx context.Context, c *testing.T) {
|
| 130 | 130 |
} |
| 131 | 131 |
buildArgs = append(buildArgs, []string{"-q", "-t", "npp-test", "../contrib/nnp-test"}...)
|
| 132 | 132 |
buildArgs = append([]string{"build"}, buildArgs...)
|
| 133 |
- cli.DockerCmd(c, buildArgs...) |
|
| 133 |
+ cli.DockerCmd(t, buildArgs...) |
|
| 134 | 134 |
} |
| ... | ... |
@@ -115,7 +115,7 @@ type elementListOptions struct {
|
| 115 | 115 |
element, format string |
| 116 | 116 |
} |
| 117 | 117 |
|
| 118 |
-func existingElements(c *testing.T, opts elementListOptions) []string {
|
|
| 118 |
+func existingElements(t *testing.T, opts elementListOptions) []string {
|
|
| 119 | 119 |
var args []string |
| 120 | 120 |
switch opts.element {
|
| 121 | 121 |
case "container": |
| ... | ... |
@@ -132,7 +132,7 @@ func existingElements(c *testing.T, opts elementListOptions) []string {
|
| 132 | 132 |
if opts.format != "" {
|
| 133 | 133 |
args = append(args, "--format", opts.format) |
| 134 | 134 |
} |
| 135 |
- out := cli.DockerCmd(c, args...).Combined() |
|
| 135 |
+ out := cli.DockerCmd(t, args...).Combined() |
|
| 136 | 136 |
var lines []string |
| 137 | 137 |
for _, l := range strings.Split(out, "\n") {
|
| 138 | 138 |
if l != "" {
|
| ... | ... |
@@ -143,13 +143,13 @@ func existingElements(c *testing.T, opts elementListOptions) []string {
|
| 143 | 143 |
} |
| 144 | 144 |
|
| 145 | 145 |
// ExistingContainerIDs returns a list of currently existing container IDs. |
| 146 |
-func ExistingContainerIDs(c *testing.T) []string {
|
|
| 147 |
- return existingElements(c, elementListOptions{element: "container", format: "{{.ID}}"})
|
|
| 146 |
+func ExistingContainerIDs(t *testing.T) []string {
|
|
| 147 |
+ return existingElements(t, elementListOptions{element: "container", format: "{{.ID}}"})
|
|
| 148 | 148 |
} |
| 149 | 149 |
|
| 150 | 150 |
// ExistingContainerNames returns a list of existing container names. |
| 151 |
-func ExistingContainerNames(c *testing.T) []string {
|
|
| 152 |
- return existingElements(c, elementListOptions{element: "container", format: "{{.Names}}"})
|
|
| 151 |
+func ExistingContainerNames(t *testing.T) []string {
|
|
| 152 |
+ return existingElements(t, elementListOptions{element: "container", format: "{{.Names}}"})
|
|
| 153 | 153 |
} |
| 154 | 154 |
|
| 155 | 155 |
// RemoveLinesForExistingElements removes existing elements from the output of a |