Skip to content

Commit

Permalink
fix: Log tunnel and region once (#980)
Browse files Browse the repository at this point in the history
* Log tunnel and region just once at start of run

* log region and tunnel when starting api test

* Log tunnel and region when starting imagerunner test
  • Loading branch information
mhan83 authored Nov 20, 2024
1 parent 84b47b1 commit 490b400
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 11 deletions.
1 change: 0 additions & 1 deletion internal/apitest/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ func (r *Runner) runSuites() bool {
Str("projectName", suite.ProjectName).
Str("suite", suite.Name).
Bool("parallel", true).
Str("tunnel", r.Project.Sauce.Tunnel.Name).
Msg("Starting suite")

if s.UseRemoteTests {
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/run/apitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package run
import (
"os"

"github.com/rs/zerolog/log"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/http"
"github.com/saucelabs/saucectl/internal/usage"
Expand Down Expand Up @@ -69,6 +70,10 @@ func runApitest(cmd *cobra.Command, isCLIDriven bool) (int, error) {
_ = tracker.Close()
}()

log.Info().
Str("region", regio.String()).
Str("tunnel", r.Project.Sauce.Tunnel.Name).
Msg("Running API Test in Sauce Labs.")
return r.RunProject()
}

Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/run/cucumber.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ func runCucumber(cmd *cobra.Command, isCLIDriven bool) (int, error) {
regio, creds.Username, creds.AccessKey, buildTimeout,
)

log.Info().Msg("Running Playwright-Cucumberjs in Sauce Labs")
log.Info().
Str("region", regio.String()).
Str("tunnel", p.Sauce.Tunnel.Name).
Msg("Running Playwright-Cucumberjs in Sauce Labs.")
r := saucecloud.CucumberRunner{
Project: p,
CloudRunner: saucecloud.CloudRunner{
Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/run/cypress.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ func runCypress(cmd *cobra.Command, cflags cypressFlags, isCLIDriven bool) (int,
regio, creds.Username, creds.AccessKey, buildTimeout,
)

log.Info().Msg("Running Cypress in Sauce Labs")
log.Info().
Str("region", regio.String()).
Str("tunnel", p.GetSauceCfg().Tunnel.Name).
Msg("Running Cypress in Sauce Labs.")
r := saucecloud.CypressRunner{
Project: p,
CloudRunner: saucecloud.CloudRunner{
Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/run/espresso.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ func runEspresso(cmd *cobra.Command, espressoFlags espressoFlags, isCLIDriven bo
}

func runEspressoInCloud(p espresso.Project, regio region.Region) (int, error) {
log.Info().Msg("Running Espresso in Sauce Labs")
log.Info().
Str("region", regio.String()).
Str("tunnel", p.Sauce.Tunnel.Name).
Msg("Running Espresso in Sauce Labs.")

creds := regio.Credentials()
restoClient := http.NewResto(regio, creds.Username, creds.AccessKey, 0)
Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/run/imagerunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package run
import (
"os"

"github.com/rs/zerolog/log"
cmds "github.com/saucelabs/saucectl/internal/cmd"
"github.com/saucelabs/saucectl/internal/config"
"github.com/saucelabs/saucectl/internal/http"
Expand Down Expand Up @@ -79,6 +80,10 @@ func runImageRunner(cmd *cobra.Command) (int, error) {
r := saucecloud.NewImgRunner(p, &imageRunnerClient, &restoClient, asyncEventManager,
reporters, gFlags.async)

log.Info().
Str("region", regio.String()).
Str("tunnel", r.Project.Sauce.Tunnel.Name).
Msg("Running in Sauce Labs.")
return r.RunProject()
}

Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/run/playwright.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ func runPlaywright(cmd *cobra.Command, pf playwrightFlags, isCLIDriven bool) (in
regio, creds.Username, creds.AccessKey, buildTimeout,
)

log.Info().Msg("Running Playwright in Sauce Labs")
log.Info().
Str("region", regio.String()).
Str("tunnel", p.Sauce.Tunnel.Name).
Msg("Running Playwright in Sauce Labs.")
r := saucecloud.PlaywrightRunner{
Project: p,
CloudRunner: saucecloud.CloudRunner{
Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/run/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ func runReplay(cmd *cobra.Command, isCLIDriven bool) (int, error) {
}

func runPuppeteerReplayInSauce(p replay.Project, regio region.Region) (int, error) {
log.Info().Msg("Replaying chrome devtools recordings")
log.Info().
Str("region", regio.String()).
Str("tunnel", p.Sauce.Tunnel.Name).
Msg("Replaying chrome devtools recordings.")

creds := regio.Credentials()
restoClient := http.NewResto(regio, creds.Username, creds.AccessKey, 0)
Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/run/testcafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ func runTestcafe(cmd *cobra.Command, tcFlags testcafeFlags, isCLIDriven bool) (i
regio, creds.Username, creds.AccessKey, buildTimeout,
)

log.Info().Msg("Running Testcafe in Sauce Labs")
log.Info().
Str("region", regio.String()).
Str("tunnel", p.Sauce.Tunnel.Name).
Msg("Running Testcafe in Sauce Labs.")
r := saucecloud.TestcafeRunner{
Project: p,
CloudRunner: saucecloud.CloudRunner{
Expand Down
5 changes: 4 additions & 1 deletion internal/cmd/run/xcuitest.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ func runXcuitest(cmd *cobra.Command, xcuiFlags xcuitestFlags, isCLIDriven bool)
}

func runXcuitestInCloud(p xcuitest.Project, regio region.Region) (int, error) {
log.Info().Msg("Running XCUITest in Sauce Labs")
log.Info().
Str("region", regio.String()).
Str("tunnel", p.Sauce.Tunnel.Name).
Msg("Running XCUITest in Sauce Labs.")

creds := regio.Credentials()

Expand Down
2 changes: 0 additions & 2 deletions internal/saucecloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ func (r *CloudRunner) findBuild(jobID string, isRDC bool) build.Build {
func (r *CloudRunner) runJob(opts job.StartOptions) (j job.Job, skipped bool, err error) {
log.Info().
Str("suite", opts.DisplayName).
Str("region", r.Region.String()).
Str("tunnel", opts.Tunnel.Name).
Msg("Starting suite.")

j, err = r.JobService.StartJob(context.Background(), opts)
Expand Down
1 change: 0 additions & 1 deletion internal/saucecloud/imagerunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ func (r *ImgRunner) runSuite(suite imagerunner.Suite) (imagerunner.Runner, error
log.Info().
Str("image", suite.Image).
Str("suite", suite.Name).
Str("tunnel", r.Project.Sauce.Tunnel.Name).
Msg("Starting suite.")

if suite.Timeout <= 0 {
Expand Down

0 comments on commit 490b400

Please sign in to comment.