diff --git a/acceptance/action.yml b/acceptance/action.yml index be6e6031..37a04496 100644 --- a/acceptance/action.yml +++ b/acceptance/action.yml @@ -27,6 +27,10 @@ inputs: codegen_path: description: 'Relative path to the .codegen.json file to use for configuring the acceptance tests' required: false # by default the first .codegen.json found in the project is used + n: + description: 'Number of parallel pytest workers (pytest-xdist -n).' + required: false + default: '10' outputs: sample: description: 'Sample output' diff --git a/acceptance/ecosystem/pytest_run.py b/acceptance/ecosystem/pytest_run.py index 9d7a97a2..a0401572 100644 --- a/acceptance/ecosystem/pytest_run.py +++ b/acceptance/ecosystem/pytest_run.py @@ -49,7 +49,7 @@ def pytest_runtest_logreport(self, report: pytest.TestReport): if __name__ == '__main__': sys.exit(pytest.main([ - '-n', '10', + '-n', (os.environ.get('PYTEST_N') or '').strip() or '10', "--log-disable", "urllib3.connectionpool", "--log-format", "%(asctime)s %(levelname)s [%(name)s] %(message)s", "--log-date-format", "%H:%M", diff --git a/acceptance/main.go b/acceptance/main.go index d68a9592..4aa971a2 100644 --- a/acceptance/main.go +++ b/acceptance/main.go @@ -71,6 +71,9 @@ func (a *acceptance) trigger(ctx context.Context) (*notify.Notification, error) // set codegen path file used for configuring the acceptance tests codegenPath := a.Action.GetInput("codegen_path") ctx = env.Set(ctx, "codegen_path", codegenPath) + if n := a.Action.GetInput("n"); n != "" { + ctx = env.Set(ctx, "PYTEST_N", n) + } redact := loaded.Redaction() report, err := a.runWithTimeout(ctx, redact, directory) if err != nil { diff --git a/acceptance/main_test.go b/acceptance/main_test.go index 4917ab76..c0af64df 100644 --- a/acceptance/main_test.go +++ b/acceptance/main_test.go @@ -12,6 +12,7 @@ func TestXxx(t *testing.T) { t.Skip() ctx := context.Background() ctx = env.Set(ctx, "INPUT_DIRECTORY", "../go-libs") + ctx = env.Set(ctx, "INPUT_N", "4") // verify PYTEST_N=4 in pytest output err := run(ctx) assert.NoError(t, err) } diff --git a/acceptance/testenv/githubOidc.go b/acceptance/testenv/githubOidc.go index 9df8cfa8..587109ed 100644 --- a/acceptance/testenv/githubOidc.go +++ b/acceptance/testenv/githubOidc.go @@ -73,7 +73,7 @@ func (cpf *credentialsProviderFunc) SetHeaders(r *http.Request) error { // Configure implements credentials provider for Databricks SDK func (c *ghOidcCreds) Configure(ctx context.Context, cfg *config.Config) (credentials.CredentialsProvider, error) { - ts, err := c.oidcTokenSource(ctx, cfg.Environment().AzureApplicationID) + ts, err := c.oidcTokenSource(ctx, environment.GetEnvironmentForHostname(cfg.CanonicalHostName()).AzureApplicationID) if err != nil { return nil, fmt.Errorf("oidc: %w", err) } diff --git a/acceptance/testenv/loaded.go b/acceptance/testenv/loaded.go index 5eb501c1..42d5a1b1 100644 --- a/acceptance/testenv/loaded.go +++ b/acceptance/testenv/loaded.go @@ -71,7 +71,7 @@ func (l *loadedEnv) Cloud() environment.Cloud { if err != nil { return environment.CloudAWS } - return cfg.Environment().Cloud + return environment.GetEnvironmentForHostname(cfg.CanonicalHostName()).Cloud } func (l *loadedEnv) Start(ctx context.Context) (context.Context, func(), error) { @@ -80,7 +80,8 @@ func (l *loadedEnv) Start(ctx context.Context) (context.Context, func(), error) return nil, nil, fmt.Errorf("config: %w", err) } srv := l.metadataServer(cfg) - ctx = env.Set(ctx, "CLOUD_ENV", strings.ToLower(string(cfg.Environment().Cloud))) + cloud := environment.GetEnvironmentForHostname(cfg.CanonicalHostName()).Cloud + ctx = env.Set(ctx, "CLOUD_ENV", strings.ToLower(string(cloud))) ctx = env.Set(ctx, "DATABRICKS_METADATA_SERVICE_URL", fmt.Sprintf("%s/%s", srv.URL, l.mpath)) ctx = env.Set(ctx, "DATABRICKS_AUTH_TYPE", "metadata-service") isAuth := map[string]bool{} @@ -104,7 +105,7 @@ func (l *loadedEnv) Start(ctx context.Context) (context.Context, func(), error) } func (l *loadedEnv) metadataServer(seed *config.Config) *httptest.Server { - accountHost := seed.Environment().DeploymentURL("accounts") + accountHost := environment.GetEnvironmentForHostname(seed.CanonicalHostName()).DeploymentURL("accounts") configurations := map[string]*config.Config{ seed.CanonicalHostName(): seed, accountHost: {