From 88369c36ce2a0d60794389aad9b10de938f587e1 Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Mon, 22 Apr 2024 23:15:23 -0700 Subject: [PATCH] do not run runLiveDotnetPlaywright (#3777) --- cli/azd/test/functional/aspire_test.go | 136 ++++++++++++------------- 1 file changed, 67 insertions(+), 69 deletions(-) diff --git a/cli/azd/test/functional/aspire_test.go b/cli/azd/test/functional/aspire_test.go index 5c6613bf295..2a5599fbbf5 100644 --- a/cli/azd/test/functional/aspire_test.go +++ b/cli/azd/test/functional/aspire_test.go @@ -13,7 +13,6 @@ import ( "testing" "time" - "github.com/azure/azure-dev/cli/azd/pkg/environment/azdcontext" "github.com/azure/azure-dev/cli/azd/pkg/exec" "github.com/azure/azure-dev/cli/azd/pkg/project" "github.com/azure/azure-dev/cli/azd/pkg/tools/bicep" @@ -22,7 +21,6 @@ import ( "github.com/azure/azure-dev/cli/azd/test/mocks/mockinput" "github.com/azure/azure-dev/cli/azd/test/snapshot" "github.com/bradleyjkemp/cupaloy/v2" - "github.com/joho/godotenv" "github.com/stretchr/testify/require" ) @@ -265,80 +263,80 @@ func Test_CLI_Aspire_Deploy(t *testing.T) { _, err = cli.RunCommandWithStdIn(ctx, stdinForProvision(), "up") require.NoError(t, err) - env, err := godotenv.Read(filepath.Join(dir, azdcontext.EnvironmentDirectoryName, envName, ".env")) - require.NoError(t, err) + //env, err := godotenv.Read(filepath.Join(dir, azdcontext.EnvironmentDirectoryName, envName, ".env")) + //require.NoError(t, err) - domain, has := env["AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN"] - require.True(t, has, "AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN should be in environment after deploy") + //domain, has := env["AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN"] + //require.True(t, has, "AZURE_CONTAINER_APPS_ENVIRONMENT_DEFAULT_DOMAIN should be in environment after deploy") - endpoint := fmt.Sprintf("https://%s.%s", "webfrontend", domain) - runLiveDotnetPlaywright(t, ctx, filepath.Join(dir, "AspireAzdTests"), endpoint) + //endpoint := fmt.Sprintf("https://%s.%s", "webfrontend", domain) + //runLiveDotnetPlaywright(t, ctx, filepath.Join(dir, "AspireAzdTests"), endpoint) _, err = cli.RunCommand(ctx, "down", "--force", "--purge") require.NoError(t, err) } -func runLiveDotnetPlaywright( - t *testing.T, - ctx context.Context, - projDir string, - endpoint string) { - runner := exec.NewCommandRunner(nil) - run := func() (res exec.RunResult, err error) { - wr := logWriter{initialTime: time.Now(), t: t, prefix: "webfrontend: "} - res, err = runner.Run(ctx, exec.NewRunArgs( - "dotnet", - "test", - "--logger", - "console;verbosity=detailed", - ).WithCwd(projDir).WithEnv(append( - os.Environ(), - "LIVE_APP_URL="+endpoint, - )).WithStdOut(&wr)) - return - } - - i := 0 // precautionary max retries - for { - res, err := run() - i++ - - if err != nil && i < 10 { - if strings.Contains(res.Stdout, "Permission denied") { - err := filepath.WalkDir(projDir, func(path string, d os.DirEntry, err error) error { - if err != nil { - return err - } - - if !d.IsDir() && d.Name() == "playwright.sh" { - return os.Chmod(path, 0700) - } - - return nil - }) - require.NoError(t, err, "failed to recover from permission denied error") - continue - } else if strings.Contains(res.Stdout, "Please run the following command to download new browsers") { - res, err := runner.Run(ctx, exec.NewRunArgs( - "pwsh", filepath.Join(projDir, "bin/Debug/net8.0/playwright.ps1"), "install")) - require.NoError(t, err, "failed to install playwright, stdout: %v, stderr: %v", res.Stdout, res.Stderr) - continue - } - } - - if cfg.CI { - require.NoError(t, err) - } else { - require.NoError( - t, - err, - "to troubleshoot, rerun `dotnet test` in %s with LIVE_APP_URL=%s", - projDir, - endpoint) - } - break - } -} +// func runLiveDotnetPlaywright( +// t *testing.T, +// ctx context.Context, +// projDir string, +// endpoint string) { +// runner := exec.NewCommandRunner(nil) +// run := func() (res exec.RunResult, err error) { +// wr := logWriter{initialTime: time.Now(), t: t, prefix: "webfrontend: "} +// res, err = runner.Run(ctx, exec.NewRunArgs( +// "dotnet", +// "test", +// "--logger", +// "console;verbosity=detailed", +// ).WithCwd(projDir).WithEnv(append( +// os.Environ(), +// "LIVE_APP_URL="+endpoint, +// )).WithStdOut(&wr)) +// return +// } + +// i := 0 // precautionary max retries +// for { +// res, err := run() +// i++ + +// if err != nil && i < 10 { +// if strings.Contains(res.Stdout, "Permission denied") { +// err := filepath.WalkDir(projDir, func(path string, d os.DirEntry, err error) error { +// if err != nil { +// return err +// } + +// if !d.IsDir() && d.Name() == "playwright.sh" { +// return os.Chmod(path, 0700) +// } + +// return nil +// }) +// require.NoError(t, err, "failed to recover from permission denied error") +// continue +// } else if strings.Contains(res.Stdout, "Please run the following command to download new browsers") { +// res, err := runner.Run(ctx, exec.NewRunArgs( +// "pwsh", filepath.Join(projDir, "bin/Debug/net8.0/playwright.ps1"), "install")) +// require.NoError(t, err, "failed to install playwright, stdout: %v, stderr: %v", res.Stdout, res.Stderr) +// continue +// } +// } + +// if cfg.CI { +// require.NoError(t, err) +// } else { +// require.NoError( +// t, +// err, +// "to troubleshoot, rerun `dotnet test` in %s with LIVE_APP_URL=%s", +// projDir, +// endpoint) +// } +// break +// } +// } // Snapshots a file located at targetPath. Saves the snapshot to snapshotRoot/rel, where rel is relative to targetRoot. func snapshotFile(