Skip to content

Commit cac167b

Browse files
authored
Allow larger logs from acceptance tests and implement experimental OIDC refresh (#261)
1 parent 7348f7d commit cac167b

File tree

11 files changed

+156
-96
lines changed

11 files changed

+156
-96
lines changed

acceptance/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fmt: lint
66
@echo "✓ Formatting source code with gofmt ..."
77
@gofmt -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
88

9-
lint: vendor
9+
lint:
1010
@echo "✓ Linting source code with https://staticcheck.io/ ..."
1111
@staticcheck ./...
1212

acceptance/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ Executes tests, comments on PR, links to worflow run, uploads artifacts for late
3030

3131
![Alt text](docs/comments.png)
3232

33+
```mermaid
34+
sequenceDiagram
35+
acceptance->>+ACTIONS_ID_TOKEN_REQUEST_URL: (1) ACTIONS_ID_TOKEN_REQUEST_TOKEN
36+
ACTIONS_ID_TOKEN_REQUEST_URL->>-acceptance: (2) JWT assertion
37+
acceptance->>+Microsoft Entra: (3) JWT assertion + client ID + resource ID
38+
Microsoft Entra->>-acceptance: (4) Access Token for Azure Key Vault
39+
acceptance->>+Azure Key Vault: (5) request environment variables
40+
Azure Key Vault->>-acceptance: (6) test environment
41+
acceptance->>+Metadata Server: (7) start auth token proxy in a thread
42+
Metadata Server->>-acceptance: (8) http://localhost:<random-port>/<random-prefix>
43+
acceptance->>+Test Runner: (9) start test runner subprocess with relevant environment
44+
Test Runner->>+test: (10) start test execution
45+
test->>+SDK: (11) call API
46+
SDK->>+Metadata Server: (12) call localhost:<random-port>/<random-prefix>
47+
Metadata Server->>+ACTIONS_ID_TOKEN_REQUEST_URL: (13) ACTIONS_ID_TOKEN_REQUEST_TOKEN
48+
ACTIONS_ID_TOKEN_REQUEST_URL->>-Metadata Server: (14) JWT assertion to request token for Databricks
49+
Metadata Server->>+Microsoft Entra: (15) JWT assertion + client ID + resource ID
50+
Microsoft Entra->>-Metadata Server: (16) Access token for Databricks
51+
Metadata Server->>-SDK: (17) Access token for Databricks
52+
SDK->>+Databricks API: (18) call API
53+
Databricks API->>-SDK: (19) deserialized result
54+
SDK->>-test: (20) deserialized result
55+
test->>-Test Runner: (21) success or failure
56+
Test Runner->>-acceptance: (22) success or failure + redacted logs
57+
```
58+
3359
## Usage
3460

3561
Add to your `.github/workflows` folder:

acceptance/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ inputs:
1717
description: 'Slack Webhook'
1818
required: false
1919
timeout:
20-
description: 'Maximum suite execution time. Defaults to 1h'
20+
description: 'Maximum suite execution time. Defaults to 2h'
2121
required: false
22-
default: 1h
22+
default: 2h
2323
create_issues:
2424
description: 'Create issues in the repository for failed tests'
2525
required: false

acceptance/ecosystem/python.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import (
2121

2222
"github.com/databricks/databricks-sdk-go/logger"
2323
"github.com/databrickslabs/sandbox/acceptance/redaction"
24-
"github.com/databrickslabs/sandbox/go-libs/toolchain"
2524
"github.com/databrickslabs/sandbox/go-libs/env"
2625
"github.com/databrickslabs/sandbox/go-libs/fileset"
2726
"github.com/databrickslabs/sandbox/go-libs/process"
27+
"github.com/databrickslabs/sandbox/go-libs/toolchain"
2828
"github.com/nxadm/tail"
2929
)
3030

acceptance/ecosystem/report.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ func (tr TestResult) Failed() bool {
2929
return !tr.Pass && !tr.Skip
3030
}
3131

32-
func (tr TestResult) Summary() string {
32+
func (tr TestResult) Summary(cap int) string {
33+
out, padding := tr.Output, 512
34+
diff := len(out) + padding - cap
35+
if diff > 0 {
36+
out = fmt.Sprintf("... (skipped %d bytes)\n%s", diff, out[diff:])
37+
}
3338
res := []string{}
3439
res = append(res, "<details>")
3540
res = append(res, fmt.Sprintf("<summary>%s</summary>", tr))
36-
res = append(res, fmt.Sprintf("\n```\n%s\n```\n", tr.Output))
41+
res = append(res, fmt.Sprintf("\n```\n%s\n```\n", out))
3742
res = append(res, "</details>")
3843
return strings.Join(res, "\n")
3944
}
@@ -104,7 +109,7 @@ func (r TestReport) Failed() error {
104109
if r.Pass() {
105110
return nil
106111
}
107-
return fmt.Errorf(r.String())
112+
return fmt.Errorf("failed: %s", r.String())
108113
}
109114

110115
func (r TestReport) String() string {
@@ -148,13 +153,24 @@ func (r TestReport) String() string {
148153
return fmt.Sprintf("%s %s", emoji, strings.Join(parts, ", "))
149154
}
150155

156+
const CommentMaxSize = 65536
157+
151158
func (r TestReport) StepSummary() string {
152-
res := []string{r.String()}
159+
res, failures, maybeOutput, padding := []string{r.String()}, []TestResult{}, 0, 1024
153160
for _, v := range r {
154161
if !v.Failed() {
155162
continue
156163
}
157-
res = append(res, v.Summary())
164+
failures = append(failures, v)
165+
maybeOutput += len(v.Summary(CommentMaxSize))
166+
}
167+
summaryCap := CommentMaxSize - len(strings.Join(res, "\n")) - padding
168+
if maybeOutput > (CommentMaxSize - padding) {
169+
// if the output is too large, truncate the summaries up to a fraction of the total size
170+
summaryCap /= len(failures)
171+
}
172+
for _, v := range failures {
173+
res = append(res, v.Summary(summaryCap))
158174
}
159175
if r.Flaky() {
160176
res = append(res, "\nFlaky tests:\n")

acceptance/go.mod

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ require (
88
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets v0.12.0 // MIT
99
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0 // MIT
1010
github.com/databricks/databricks-sdk-go v0.40.0 // Apache 2.0
11-
github.com/databrickslabs/sandbox/go-libs v0.1.0 // Databricks License
11+
github.com/databrickslabs/sandbox/go-libs v0.4.0 // Databricks License
1212
github.com/nxadm/tail v1.4.11 // MIT
1313
github.com/sethvargo/go-githubactions v1.2.0 // Apache 2.0
14-
github.com/stretchr/testify v1.8.4 // MIT
15-
golang.org/x/oauth2 v0.17.0 // BSD
14+
github.com/stretchr/testify v1.9.0 // MIT
15+
golang.org/x/oauth2 v0.19.0 // BSD
1616
)
1717

1818
require (
@@ -38,23 +38,21 @@ require (
3838
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
3939
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4040
go.opencensus.io v0.24.0 // indirect
41-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 // indirect
42-
go.opentelemetry.io/otel v1.23.1 // indirect
43-
go.opentelemetry.io/otel/metric v1.23.1 // indirect
44-
go.opentelemetry.io/otel/trace v1.23.1 // indirect
45-
golang.org/x/crypto v0.19.0 // indirect
41+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
42+
go.opentelemetry.io/otel v1.24.0 // indirect
43+
go.opentelemetry.io/otel/metric v1.24.0 // indirect
44+
go.opentelemetry.io/otel/trace v1.24.0 // indirect
45+
golang.org/x/crypto v0.22.0 // indirect
4646
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
47-
golang.org/x/mod v0.15.0 // indirect
48-
golang.org/x/net v0.21.0 // indirect
49-
golang.org/x/sys v0.17.0 // indirect
47+
golang.org/x/mod v0.16.0 // indirect
48+
golang.org/x/net v0.24.0 // indirect
49+
golang.org/x/sys v0.19.0 // indirect
5050
golang.org/x/text v0.14.0 // indirect
5151
golang.org/x/time v0.5.0 // indirect
52-
google.golang.org/api v0.166.0 // indirect
53-
google.golang.org/appengine v1.6.8 // indirect
54-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect
52+
google.golang.org/api v0.169.0 // indirect
53+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304161311-37d4d3c04a78 // indirect
5554
google.golang.org/grpc v1.62.0 // indirect
56-
google.golang.org/protobuf v1.32.0 // indirect
57-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
55+
google.golang.org/protobuf v1.33.0 // indirect
5856
gopkg.in/ini.v1 v1.67.0 // indirect
5957
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
6058
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)