FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
dagger/toolchains/engine-dev/bench.go at main · syncopatedNote/dagger · GitHub
syncopatedNote
dagger
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
dagger
/
toolchains
/
engine-dev
/
bench.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
244 lines (230 loc) · 5.81 KB
Breadcrumbs
dagger
/
toolchains
/
engine-dev
/
bench.go
Copy path
File metadata and controls
244 lines (230 loc) · 5.81 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
package
main
import
(
"context"
"fmt"
"time"
"dagger/engine-dev/internal/dagger"
)
// Perform a benchmark of the given test run
// +cache="session"
func
(
dev
*
EngineDev
)
Benchmark
(
ctx
context.
Context
,
// Only run these benchmarks
// +optional
run
string
,
// Skip these benchmarks
// +optional
skip
string
,
// +optional
// +default="./..."
pkg
string
,
// Abort bench run on first failure
// +optional
failfast
bool
,
// How long before timing out the benchmark run
// +optional
timeout
string
,
// +optional
race
bool
,
// +default=1
// +optional
count
int
,
// Enable verbose output
// +optional
testVerbose
bool
,
// run benchmarks once with metrics tagged "prewarm" before running for real
// +optional
prewarm
bool
,
// notify this discord webhook on failure
// +optional
discordWebhook
*
dagger.
Secret
,
// Git repository to extract git metadata for discord notification
// +defaultPath="/"
repo
*
dagger.
GitRepository
,
)
error
{
return
dev
.
notifyOnFailure
(
ctx
,
repo
,
dev
.
bench
(
ctx
,
&
benchOpts
{
runTestRegex
:
run
,
skipTestRegex
:
skip
,
pkg
:
pkg
,
failfast
:
failfast
,
timeout
:
timeout
,
race
:
race
,
count
:
count
,
testVerbose
:
testVerbose
,
prewarm
:
prewarm
,
},
),
discordWebhook
)
}
func
(
dev
*
EngineDev
)
notifyOnFailure
(
ctx
context.
Context
,
repo
*
dagger.
GitRepository
,
err
error
,
discordWebhook
*
dagger.
Secret
)
error
{
if
err
==
nil
{
return
nil
}
if
discordWebhook
==
nil
{
return
err
}
commit
,
err
:=
repo
.
Head
().
Commit
(
ctx
)
if
err
!=
nil
{
commit
=
"failed to find commit SHA"
}
daggerCloudURL
,
err
:=
dag
.
Notify
().
DaggerCloudTraceURL
(
ctx
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to fetch trace URL for failed benchmarks: %w"
,
err
)
}
message
:=
fmt
.
Sprintf
(
"[failed](%s) on SHA [%s](https://github.com/dagger/dagger/commit/%s)"
,
daggerCloudURL
,
commit
,
commit
,
)
_
,
discordErr
:=
dag
.
Notify
().
Discord
(
ctx
,
discordWebhook
,
message
)
if
discordErr
!=
nil
{
return
fmt
.
Errorf
(
"failed to notify discord that benchmarks failed: %w, discord error %w"
,
err
,
discordErr
)
}
return
err
}
// Run specific benchmarks while curling (pprof) dumps from their associated dev engine:
// defaults to heap dumps, eg: take a heap dump every second and one after the tests complete:
// `dagger call test dump --run=TestCache/TestVolume --pkg=./core/integration --interval=1s export --path=/tmp/dump-$(date +"%Y%m%d_%H%M%S")`
// but also works for profiles:
// `dagger call test dump --run=TestCache/TestVolume --pkg=./core/integration --route=pprof/profile --no-final export --path=/tmp/dump-$(date +"%Y%m%d_%H%M%S")`
// +cache="session"
func
(
dev
*
EngineDev
)
BenchmarkDump
(
ctx
context.
Context
,
// Only run these tests
// +optional
run
string
,
// Skip these tests
// +optional
skip
string
,
// +optional
// +default="./..."
pkg
string
,
// Abort test run on first failure
// +optional
failfast
bool
,
// How long before timing out the test run
// +optional
timeout
string
,
// +optional
race
bool
,
// +default=1
// +optional
count
int
,
// Enable verbose output
// +optional
testVerbose
bool
,
// debug subroute to dump, like pprof/profile, pprof/heap, or requests
// +optional
// +default="pprof/heap"
route
string
,
// when set, don't take a final dump after the tests have completed. usually good with --route="pprof/profile".
// +optional'
// +default=false
noFinal
bool
,
// wait this long before starting to take dumps. delay does not include engine startup.
// +optional
// +default="1s"
delay
string
,
// wait this long between dumps. negative values will fetch exactly 1 dump excluding the one controlled by "final"
// +optional
// +default="-1s"
interval
string
,
) (
*
dagger.
Directory
,
error
) {
d
,
err
:=
time
.
ParseDuration
(
delay
)
if
err
!=
nil
{
return
nil
,
err
}
i
,
err
:=
time
.
ParseDuration
(
interval
)
if
err
!=
nil
{
return
nil
,
err
}
return
dev
.
benchDump
(
ctx
,
&
benchOpts
{
runTestRegex
:
run
,
skipTestRegex
:
skip
,
pkg
:
pkg
,
failfast
:
failfast
,
timeout
:
timeout
,
race
:
race
,
count
:
count
,
testVerbose
:
testVerbose
,
},
&
dumpOpts
{
route
:
route
,
noFinal
:
noFinal
,
delay
:
d
,
interval
:
i
,
},
)
}
func
(
dev
*
EngineDev
)
benchDump
(
ctx
context.
Context
,
opts
*
benchOpts
,
dOpts
*
dumpOpts
,
) (
*
dagger.
Directory
,
error
) {
ctr
,
debugEndpoint
,
err
:=
dev
.
testContainer
(
ctx
,
nil
)
if
err
!=
nil
{
return
nil
,
err
}
ctr
=
dev
.
test
(
ctx
,
ctr
,
&
testOpts
{
runTestRegex
:
opts
.
runTestRegex
,
skipTestRegex
:
opts
.
skipTestRegex
,
pkg
:
opts
.
pkg
,
failfast
:
opts
.
failfast
,
parallel
:
0
,
timeout
:
opts
.
timeout
,
race
:
opts
.
race
,
count
:
opts
.
count
,
update
:
false
,
testVerbose
:
opts
.
testVerbose
,
bench
:
true
,
})
return
dev
.
pprofDump
(
ctx
,
ctr
,
debugEndpoint
,
dOpts
)
}
type
benchOpts
struct
{
runTestRegex
string
skipTestRegex
string
pkg
string
failfast
bool
timeout
string
race
bool
count
int
testVerbose
bool
prewarm
bool
}
func
(
dev
*
EngineDev
)
bench
(
ctx
context.
Context
,
opts
*
benchOpts
,
)
error
{
run
:=
func
(
cmd
*
dagger.
Container
)
*
dagger.
Container
{
return
dev
.
test
(
ctx
,
cmd
,
&
testOpts
{
runTestRegex
:
opts
.
runTestRegex
,
skipTestRegex
:
opts
.
skipTestRegex
,
pkg
:
opts
.
pkg
,
failfast
:
opts
.
failfast
,
parallel
:
0
,
timeout
:
opts
.
timeout
,
race
:
opts
.
race
,
count
:
opts
.
count
,
update
:
false
,
testVerbose
:
opts
.
testVerbose
,
bench
:
true
,
},
)
}
ctr
,
_
,
err
:=
dev
.
testContainer
(
ctx
,
nil
)
if
err
!=
nil
{
return
err
}
if
opts
.
prewarm
{
_
,
err
=
run
(
ctr
.
WithEnvVariable
(
"DAGGER_BENCH_PREWARM"
,
"true"
)).
Sync
(
ctx
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed during prewarm run: %w"
,
err
)
}
}
_
,
err
=
run
(
ctr
).
Sync
(
ctx
)
return
err
}
Back
|
FazBrowse Home
|
New Git URL