Skip to content

Commit

Permalink
Parallelize download and upload operations during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-krishna authored and eks-distro-pr-bot committed Aug 30, 2024
1 parent 8a42b34 commit b299662
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions internal/test/e2e/setup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package e2e

import (
"context"
"errors"
"fmt"
"os"
Expand All @@ -9,6 +10,7 @@ import (

"github.com/aws/aws-sdk-go/aws/session"
"github.com/go-logr/logr"
"golang.org/x/sync/errgroup"

"github.com/aws/eks-anywhere/internal/pkg/api"
"github.com/aws/eks-anywhere/internal/pkg/s3"
Expand Down Expand Up @@ -232,11 +234,21 @@ func (e *E2ESession) uploadRequiredFiles() error {
return err
}
}

errGroup, _ := errgroup.WithContext(context.Background())
for _, file := range e.requiredFiles {
err := e.uploadRequiredFile(file)
if err != nil {
return err
}
e, file := e, file
errGroup.Go(func() error {
err := e.uploadRequiredFile(file)
if err != nil {
return err
}

return nil
})
}
if err := errGroup.Wait(); err != nil {
return err
}

return nil
Expand All @@ -255,12 +267,22 @@ func (e *E2ESession) downloadRequiredFileInInstance(file string) error {
}

func (e *E2ESession) downloadRequiredFilesInInstance() error {
errGroup, _ := errgroup.WithContext(context.Background())
for _, file := range e.requiredFiles {
err := e.downloadRequiredFileInInstance(file)
if err != nil {
return err
}
e, file := e, file
errGroup.Go(func() error {
err := e.downloadRequiredFileInInstance(file)
if err != nil {
return err
}

return nil
})
}
if err := errGroup.Wait(); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit b299662

Please sign in to comment.