Skip to content

Commit 358108a

Browse files
committed
rename Generator to Direct
1 parent af2a330 commit 358108a

20 files changed

+121
-2914
lines changed

book/src/libs/wasp/benchspy/first_test.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Let's start with a simplest case, which doesn't require you to have any of the observability stack, but only `WASP` and the application you are testing.
44
`BenchSpy` comes with some built-in `QueryExecutors` each of which additionaly has predefined metrics that you can use. One of these executors is the
5-
`GeneratorQueryExecutor` that fetches metrics directly from `WASP` generators.
5+
`DirectQueryExecutor` that fetches metrics directly from `WASP` generators.
66

77
Our first test will follow the following logic:
88
* Run a simple load test
@@ -37,7 +37,7 @@ baseLineReport, err := benchspy.NewStandardReport(
3737
// random hash, this should be commit or hash of the Application Under Test (AUT)
3838
"e7fc5826a572c09f8b93df3b9f674113372ce924",
3939
// use built-in queries for an executor that fetches data directly from the WASP generator
40-
benchspy.WithStandardQueries(benchspy.StandardQueryExecutor_Generator),
40+
benchspy.WithStandardQueries(benchspy.StandardQueryExecutor_Direct),
4141
// WASP generators
4242
benchspy.WithGenerators(gen),
4343
)
@@ -85,7 +85,7 @@ defer cancelFn()
8585
currentReport, previousReport, err := benchspy.FetchNewStandardReportAndLoadLatestPrevious(
8686
fetchCtx,
8787
"e7fc5826a572c09f8b93df3b9f674113372ce925",
88-
benchspy.WithStandardQueries(benchspy.StandardQueryExecutor_Generator),
88+
benchspy.WithStandardQueries(benchspy.StandardQueryExecutor_Direct),
8989
benchspy.WithGenerators(newGen),
9090
)
9191
require.NoError(t, err, "failed to fetch current report or load the previous one")

book/src/libs/wasp/benchspy/loki_dillema.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# BenchSpy - To Loki or not to Loki?
22

3-
You might be asking yourself whether you should use `Loki` or `Generator` query executor if all you
3+
You might be asking yourself whether you should use `Loki` or `Direct` query executor if all you
44
need are basic latency metrics.
55

66
As a rule of thumb, if all you need is a single number that describes the median latency or error rate
77
and you are not interested in directly comparing time series, minimum or maximum values or any kinds
8-
of more advanced calculation on raw data, then you should go with the `Generator`.
8+
of more advanced calculation on raw data, then you should go with the `Direct`.
99

1010
Why?
1111

book/src/libs/wasp/benchspy/loki_std.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,7 @@ compareMedian(string(benchspy.ErrorRate))
101101

102102
We have used standard metrics, which are the same as in the first test, now let's see how you can use your custom LogQl queries.
103103

104+
> [!NOTE]
105+
> Don't know whether to use `Loki` or `Direct` query executors? [Read this!](./loki_dillema.md)
106+
104107
You can find the full example [here](...).

book/src/libs/wasp/benchspy/overview.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ It's main characteristics are:
66
* three built-in data sources:
77
* `Loki`
88
* `Prometheus`
9-
* `WASP generator`
9+
* `Direct`
1010
* standard/pre-defined metrics for each data source
1111
* ease of extensibility with custom metrics
1212
* ability to load latest performance report based on Git history
13+
* 88% unit test coverage
1314

1415
It doesn't come with any comparation logic, other than making sure that performance reports are comparable (e.g. they mesure the same metrics in the same way),
1516
leaving total freedom to the user.

book/src/libs/wasp/benchspy/reports/new_executor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# BenchSpy - Adding new QueryExecutor
22

33
As mentioned previously the `StandardReport` comes with support of three different data types:
4-
* `WASP generator`
4+
* `Direct`
55
* `Loki`
66
* `Prometheus`
77

book/src/libs/wasp/benchspy/reports/standard_report.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# BenchSpy - Standard Report
22

33
`StandardReport` comes with built-in support for three types of data sources:
4-
* `WASP Generator`
4+
* `Direct`
55
* `Loki`
66
* `Prometheus`
77

88
Each of them allows you to both use pre-defined metrics or use your own.
99

1010
## Pre-defined (standard) metrics
1111

12-
### WASP generator and Loki
12+
### Direct and Loki
1313
Both query executors focus on the characteristics of the load generated with WASP.
1414
The datasets they work on are almost identical, because the former allows you to query load-specific
1515
data before its sent to Loki. The latter offers you richer querying options (via `LogQL`) and access
@@ -79,10 +79,10 @@ var timeouts = func(responses *wasp.SliceBuffer[wasp.Response]) (float64, error)
7979
return timeoutCount / (timeoutCount + inTimeCount), nil
8080
}
8181

82-
generatorExectutor, err := NewGeneratorQueryExecutor(generator, map[string]GeneratorQueryFn{
82+
directExectutor, err := NewDirectQueryExecutor(generator, map[string]DirectQueryFn{
8383
"timeout_ratio": timeouts,
8484
})
85-
require.NoError(t, err, "failed to create WASP Generator Query Executor")
85+
require.NoError(t, err, "failed to create Direct Query Executor")
8686
```
8787

8888
### Loki
@@ -122,7 +122,7 @@ functional option `WithStandardQueries` you should pass the `QueryExecutors` cre
122122
```go
123123
report, err := benchspy.NewStandardReport(
124124
"2d1fa3532656c51991c0212afce5f80d2914e34e",
125-
benchspy.WithQueryExecutors(generatorExectutor, lokiQueryExecutor, prometheusExecutor),
125+
benchspy.WithQueryExecutors(directExectutor, lokiQueryExecutor, prometheusExecutor),
126126
benchspy.WithGenerators(gen),
127127
)
128128
require.NoError(t, err, "failed to create baseline report")

book/src/libs/wasp/benchspy/simplest_metrics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ so there's no dilemma, but with `Loki` and `Prometheus` things get a bit more co
1414
But first... since each of built-in `QueryExecutors` returns a different data type and we are using `interface{}` type to reflect that,
1515
we will use convenience functions to cast them to more usable types:
1616
```go
17-
currentAsFloat64 := benchspy.MustAllGeneratorResults(currentReport)
18-
previousAsloat64 := benchspy.MustAllGeneratorResults(previousReport)
17+
currentAsFloat64 := benchspy.MustAllDirectResults(currentReport)
18+
previousAsloat64 := benchspy.MustAllDirectResults(previousReport)
1919
```
2020

2121
> [!NOTE]

wasp/benchspy/TO_DO.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
Known things to do:
22
- [ ] add logger
3-
- [ ] add unit tests for prometheus
4-
- [ ] add wasp test for prometheus only
3+
- [x] add unit tests for prometheus
4+
- [x] add wasp test for prometheus only
55
- [ ] add e2e OCRv2 test with CTFv2
6-
- [ ] write documentation
6+
- [x] write documentation
77
- [ ] add report builder (?)
8-
- [ ] add wrapper function for executing some code and then creating a report
8+
- [x] add wrapper function for executing some code and then creating a report
99
- [ ] add helper method for a profile what would create a report based on all generators?
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@ import (
1111
"github.com/smartcontractkit/chainlink-testing-framework/wasp"
1212
)
1313

14-
type GeneratorQueryFn = func(responses *wasp.SliceBuffer[wasp.Response]) (float64, error)
14+
type DirectQueryFn = func(responses *wasp.SliceBuffer[wasp.Response]) (float64, error)
1515

16-
type GeneratorQueryExecutor struct {
17-
KindName string `json:"kind"`
18-
Generator *wasp.Generator `json:"generator_config"`
19-
Queries map[string]GeneratorQueryFn `json:"queries"`
20-
QueryResults map[string]interface{} `json:"query_results"`
16+
type DirectQueryExecutor struct {
17+
KindName string `json:"kind"`
18+
Generator *wasp.Generator `json:"generator_config"`
19+
Queries map[string]DirectQueryFn `json:"queries"`
20+
QueryResults map[string]interface{} `json:"query_results"`
2121
}
2222

23-
func NewStandardGeneratorQueryExecutor(generator *wasp.Generator) (*GeneratorQueryExecutor, error) {
24-
g := &GeneratorQueryExecutor{
25-
KindName: string(StandardQueryExecutor_Generator),
23+
func NewStandardDirectQueryExecutor(generator *wasp.Generator) (*DirectQueryExecutor, error) {
24+
g := &DirectQueryExecutor{
25+
KindName: string(StandardQueryExecutor_Direct),
2626
}
2727

2828
queries, err := g.generateStandardQueries()
2929
if err != nil {
3030
return nil, err
3131
}
3232

33-
return NewGeneratorQueryExecutor(generator, queries)
33+
return NewDirectQueryExecutor(generator, queries)
3434
}
3535

36-
func NewGeneratorQueryExecutor(generator *wasp.Generator, queries map[string]GeneratorQueryFn) (*GeneratorQueryExecutor, error) {
37-
g := &GeneratorQueryExecutor{
38-
KindName: string(StandardQueryExecutor_Generator),
36+
func NewDirectQueryExecutor(generator *wasp.Generator, queries map[string]DirectQueryFn) (*DirectQueryExecutor, error) {
37+
g := &DirectQueryExecutor{
38+
KindName: string(StandardQueryExecutor_Direct),
3939
Generator: generator,
4040
Queries: queries,
4141
QueryResults: make(map[string]interface{}),
@@ -44,22 +44,22 @@ func NewGeneratorQueryExecutor(generator *wasp.Generator, queries map[string]Gen
4444
return g, nil
4545
}
4646

47-
func (g *GeneratorQueryExecutor) Results() map[string]interface{} {
47+
func (g *DirectQueryExecutor) Results() map[string]interface{} {
4848
return g.QueryResults
4949
}
5050

51-
func (l *GeneratorQueryExecutor) Kind() string {
51+
func (l *DirectQueryExecutor) Kind() string {
5252
return l.KindName
5353
}
5454

55-
func (g *GeneratorQueryExecutor) IsComparable(otherQueryExecutor QueryExecutor) error {
55+
func (g *DirectQueryExecutor) IsComparable(otherQueryExecutor QueryExecutor) error {
5656
otherType := reflect.TypeOf(otherQueryExecutor)
5757

5858
if otherType != reflect.TypeOf(g) {
5959
return fmt.Errorf("expected type %s, got %s", reflect.TypeOf(g), otherType)
6060
}
6161

62-
otherGeneratorQueryExecutor := otherQueryExecutor.(*GeneratorQueryExecutor)
62+
otherGeneratorQueryExecutor := otherQueryExecutor.(*DirectQueryExecutor)
6363

6464
if compareGeneratorConfigs(g.Generator.Cfg, otherGeneratorQueryExecutor.Generator.Cfg) != nil {
6565
return errors.New("generators are not comparable")
@@ -68,7 +68,7 @@ func (g *GeneratorQueryExecutor) IsComparable(otherQueryExecutor QueryExecutor)
6868
return g.compareQueries(otherGeneratorQueryExecutor.Queries)
6969
}
7070

71-
func (l *GeneratorQueryExecutor) compareQueries(other map[string]GeneratorQueryFn) error {
71+
func (l *DirectQueryExecutor) compareQueries(other map[string]DirectQueryFn) error {
7272
this := l.Queries
7373
if len(this) != len(other) {
7474
return fmt.Errorf("queries count is different. Expected %d, got %d", len(this), len(other))
@@ -83,7 +83,7 @@ func (l *GeneratorQueryExecutor) compareQueries(other map[string]GeneratorQueryF
8383
return nil
8484
}
8585

86-
func (g *GeneratorQueryExecutor) Validate() error {
86+
func (g *DirectQueryExecutor) Validate() error {
8787
if g.Generator == nil {
8888
return errors.New("generator is not set")
8989
}
@@ -95,7 +95,7 @@ func (g *GeneratorQueryExecutor) Validate() error {
9595
return nil
9696
}
9797

98-
func (g *GeneratorQueryExecutor) Execute(_ context.Context) error {
98+
func (g *DirectQueryExecutor) Execute(_ context.Context) error {
9999
if g.Generator == nil {
100100
return errors.New("generator is not set")
101101
}
@@ -130,12 +130,12 @@ func (g *GeneratorQueryExecutor) Execute(_ context.Context) error {
130130
return nil
131131
}
132132

133-
func (g *GeneratorQueryExecutor) TimeRange(_, _ time.Time) {
133+
func (g *DirectQueryExecutor) TimeRange(_, _ time.Time) {
134134
// nothing to do here, since all responses stored in the generator are already in the right time range
135135
}
136136

137-
func (g *GeneratorQueryExecutor) generateStandardQueries() (map[string]GeneratorQueryFn, error) {
138-
standardQueries := make(map[string]GeneratorQueryFn)
137+
func (g *DirectQueryExecutor) generateStandardQueries() (map[string]DirectQueryFn, error) {
138+
standardQueries := make(map[string]DirectQueryFn)
139139

140140
for _, metric := range standardLoadMetrics {
141141
query, err := g.standardQuery(metric)
@@ -148,7 +148,7 @@ func (g *GeneratorQueryExecutor) generateStandardQueries() (map[string]Generator
148148
return standardQueries, nil
149149
}
150150

151-
func (g *GeneratorQueryExecutor) standardQuery(standardMetric StandardLoadMetric) (GeneratorQueryFn, error) {
151+
func (g *DirectQueryExecutor) standardQuery(standardMetric StandardLoadMetric) (DirectQueryFn, error) {
152152
switch standardMetric {
153153
case MedianLatency:
154154
medianFn := func(responses *wasp.SliceBuffer[wasp.Response]) (float64, error) {
@@ -194,7 +194,7 @@ func (g *GeneratorQueryExecutor) standardQuery(standardMetric StandardLoadMetric
194194
}
195195
}
196196

197-
func (g *GeneratorQueryExecutor) MarshalJSON() ([]byte, error) {
197+
func (g *DirectQueryExecutor) MarshalJSON() ([]byte, error) {
198198
// we need custom marshalling to only include query names, since the functions are not serializable
199199
type QueryExecutor struct {
200200
Kind string `json:"kind"`
@@ -222,10 +222,10 @@ func (g *GeneratorQueryExecutor) MarshalJSON() ([]byte, error) {
222222
})
223223
}
224224

225-
func (g *GeneratorQueryExecutor) UnmarshalJSON(data []byte) error {
225+
func (g *DirectQueryExecutor) UnmarshalJSON(data []byte) error {
226226
// helper struct with QueryExecutors as json.RawMessage and QueryResults as map[string]interface{}
227227
// and as actual types
228-
type Alias GeneratorQueryExecutor
228+
type Alias DirectQueryExecutor
229229
var raw struct {
230230
Alias
231231
GeneratorCfg wasp.Config `json:"generator_config"`
@@ -238,7 +238,7 @@ func (g *GeneratorQueryExecutor) UnmarshalJSON(data []byte) error {
238238
return err
239239
}
240240

241-
queries := make(map[string]GeneratorQueryFn)
241+
queries := make(map[string]DirectQueryFn)
242242

243243
// unmarshall only query names
244244
for _, rawQuery := range raw.Queries {
@@ -256,7 +256,7 @@ func (g *GeneratorQueryExecutor) UnmarshalJSON(data []byte) error {
256256
return conversionErr
257257
}
258258

259-
*g = GeneratorQueryExecutor(raw.Alias)
259+
*g = DirectQueryExecutor(raw.Alias)
260260
g.Queries = queries
261261
g.QueryResults = convertedTypes
262262
g.Generator = &wasp.Generator{

0 commit comments

Comments
 (0)