1- //go:build integration
2-
31package test
42
53import (
@@ -33,6 +31,7 @@ import (
3331
3432 "github.com/docker/docker/api/types"
3533 "github.com/docker/docker/api/types/container"
34+ imagetypes "github.com/docker/docker/api/types/image"
3635 "github.com/docker/docker/client"
3736 "github.com/docker/docker/pkg/stdcopy"
3837 "github.com/docker/go-connections/nat"
@@ -84,11 +83,11 @@ type backupTarget struct {
8483}
8584
8685type testOptions struct {
87- compact bool
86+ compact bool //nolint:unused // used in the future
8887 targets []string
8988 dc * dockerContext
9089 base string
91- prePost bool
90+ prePost bool //nolint:unused // used in the future
9291 backupData []byte
9392 mysql containerPort
9493 smb containerPort
@@ -335,8 +334,8 @@ func (d *dockerContext) makeSMB(smbImage string) error {
335334 if err != nil {
336335 return fmt .Errorf ("failed to build smb image: %w" , err )
337336 }
338- io .Copy (os .Stdout , resp .Body )
339- resp .Body .Close ()
337+ _ , _ = io .Copy (os .Stdout , resp .Body )
338+ _ = resp .Body .Close ()
340339
341340 return nil
342341}
@@ -442,7 +441,9 @@ DELIMITER ;
442441 if err != nil {
443442 return err
444443 }
445- defer fCompact .Close ()
444+ defer func () {
445+ _ = fCompact .Close ()
446+ }()
446447
447448 _ , _ = stdcopy .StdCopy (fCompact , & bufe , attachResp .Reader )
448449
@@ -463,12 +464,15 @@ DELIMITER ;
463464 if err != nil {
464465 return err
465466 }
466- defer f .Close ()
467+ defer func () {
468+ _ = f .Close ()
469+ }()
467470
468471 _ , _ = stdcopy .StdCopy (f , & bufe , attachResp .Reader )
469472 return err
470473}
471474
475+ //nolint:unused // useful in the future
472476func (d * dockerContext ) logContainers (cids ... string ) error {
473477 ctx := context .Background ()
474478 for _ , cid := range cids {
@@ -480,7 +484,9 @@ func (d *dockerContext) logContainers(cids ...string) error {
480484 if err != nil {
481485 return fmt .Errorf ("failed to get logs for container %s: %w" , cid , err )
482486 }
483- defer logs .Close ()
487+ defer func () {
488+ _ = logs .Close ()
489+ }()
484490
485491 if _ , err := io .Copy (os .Stdout , logs ); err != nil {
486492 return fmt .Errorf ("failed to stream logs for container %s: %w" , cid , err )
@@ -560,12 +566,12 @@ log_queries_not_using_indexes = 1
560566 return mysql , smb , s3url , s3backend , fmt .Errorf ("failed to create mysql log directory: %v" , err )
561567 }
562568 // ensure we have mysql image
563- resp , err := dc .cli .ImagePull (context .Background (), mysqlImage , types. ImagePullOptions {})
569+ resp , err := dc .cli .ImagePull (context .Background (), mysqlImage , imagetypes. PullOptions {})
564570 if err != nil {
565571 return mysql , smb , s3url , s3backend , fmt .Errorf ("failed to pull mysql image: %v" , err )
566572 }
567- io .Copy (os .Stdout , resp )
568- resp .Close ()
573+ _ , _ = io .Copy (os .Stdout , resp )
574+ _ = resp .Close ()
569575 mysqlCID , mysqlPort , err := dc .startContainer (mysqlImage , "mysql" , "3306/tcp" , []string {fmt .Sprintf ("%s:/etc/mysql/conf.d/log.conf:ro" , confFile ), fmt .Sprintf ("%s:/var/log/mysql" , logDir )}, nil , []string {
570576 fmt .Sprintf ("MYSQL_ROOT_PASSWORD=%s" , mysqlRootPass ),
571577 "MYSQL_DATABASE=tester" ,
@@ -594,8 +600,7 @@ func backupTargetsToStorage(targets []backupTarget, base, s3 string) ([]storage.
594600 var targetVals []storage.Storage
595601 // all targets should have the same sequence, with varying subsequence, so take any one
596602 for _ , tgt := range targets {
597- tg := tgt .String ()
598- tg = tgt .WithPrefix (base )
603+ tg := tgt .WithPrefix (base )
599604 localPath := tgt .LocalPath ()
600605 if err := os .MkdirAll (localPath , 0o755 ); err != nil {
601606 return nil , fmt .Errorf ("failed to create local path %s: %v" , localPath , err )
@@ -753,13 +758,13 @@ func checkDumpTest(t *testing.T, base string, expected []byte, s3backend gofakes
753758 if _ , err := os .Stat (postBackupOutFile ); err != nil {
754759 t .Errorf ("%s script didn't run, output file doesn't exist" , msg )
755760 }
756- os .RemoveAll (postBackupOutFile )
761+ _ = os .RemoveAll (postBackupOutFile )
757762
758763 msg = fmt .Sprintf ("%s %s pre-backup" , id , target .String ())
759764 if _ , err := os .Stat (preBackupOutFile ); err != nil {
760765 t .Errorf ("%s script didn't run, output file doesn't exist" , msg )
761766 }
762- os .RemoveAll (preBackupOutFile )
767+ _ = os .RemoveAll (preBackupOutFile )
763768 }
764769 p := target .Path ()
765770 if p == "" {
@@ -805,8 +810,6 @@ func checkDumpTest(t *testing.T, base string, expected []byte, s3backend gofakes
805810 // to each format
806811 assert .Equal (t , expectedFiltered , string (b ), "%s tar contents do not match actual dump" , id )
807812 }
808-
809- return
810813}
811814
812815// gunzipUntarScanFilter is a helper function to extract the actual data from a backup
@@ -817,7 +820,9 @@ func gunzipUntarScanFilter(r io.Reader) (b []byte, err error) {
817820 if err != nil {
818821 return nil , err
819822 }
820- defer gr .Close ()
823+ defer func () {
824+ _ = gr .Close ()
825+ }()
821826 tr := tar .NewReader (gr )
822827 if _ , err := tr .Next (); err != nil {
823828 return nil , err
@@ -886,12 +891,12 @@ func populatePrePost(base string, targets []backupTarget) (err error) {
886891}
887892
888893func startDatabase (dc * dockerContext , baseDir , image , name string ) (containerPort , error ) {
889- resp , err := dc .cli .ImagePull (context .Background (), image , types. ImagePullOptions {})
894+ resp , err := dc .cli .ImagePull (context .Background (), image , imagetypes. PullOptions {})
890895 if err != nil {
891896 return containerPort {}, fmt .Errorf ("failed to pull mysql image: %v" , err )
892897 }
893- io .Copy (os .Stdout , resp )
894- resp .Close ()
898+ _ , _ = io .Copy (os .Stdout , resp )
899+ _ = resp .Close ()
895900
896901 // start the mysql container; configure it for lots of debug logging, in case we need it
897902 mysqlConf := `
@@ -931,6 +936,7 @@ log_queries_not_using_indexes = 1
931936}
932937
933938func TestIntegration (t * testing.T ) {
939+ CheckSkipIntegration (t , "integration" )
934940 syscall .Umask (0 )
935941 dc , err := getDockerContext ()
936942 if err != nil {
0 commit comments