Skip to content

Commit aecaa0c

Browse files
feat: smoke file sizes (#505)
* feat: fize-sizes param for smoke * ci: file-sizes in configs * ci: file-sizes in staging * refactor: comments * refactor: backward compatibility for ContentSize * fix: comments * fix(load): use content-size for load check (#522) --------- Co-authored-by: Ljubiša Gačević <35105035+gacevicljubisa@users.noreply.github.com>
1 parent 1b6fdd9 commit aecaa0c

File tree

7 files changed

+196
-128
lines changed

7 files changed

+196
-128
lines changed

config/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ checks:
335335
type: settlements
336336
smoke:
337337
options:
338-
content-size: 5000
338+
file-sizes: [31457280, 104857600, 314572800] # [30MB, 100MB, 300MB]
339339
postage-ttl: 72h
340340
postage-depth: 21
341341
postage-label: test-label
@@ -369,7 +369,7 @@ checks:
369369
type: withdraw
370370
load:
371371
options:
372-
content-size: 500000 #5000000
372+
content-size: 500000
373373
gas-price: 10000000000
374374
postage-ttl: 72h
375375
postage-depth: 21

config/local.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ checks:
282282
type: settlements
283283
ci-smoke:
284284
options:
285-
content-size: 50000
285+
content-size: 3072
286+
file-sizes: [3072, 30720, 307200, 3145728] # [3KB, 30KB, 300KB, 3MB]
286287
postage-ttl: 24h
287288
postage-depth: 21
288289
postage-label: test-label
@@ -295,7 +296,7 @@ checks:
295296
type: smoke
296297
ci-load:
297298
options:
298-
content-size: 50000
299+
content-size: 3072
299300
postage-ttl: 24h
300301
postage-depth: 21
301302
postage-label: test-label

config/public-testnet.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ checks:
176176
type: load
177177
pt-smoke:
178178
options:
179-
content-size: 50000000
179+
file-sizes: [3072, 30720, 307200, 31457280, 104857600, 314572800] # [3KB, 30KB, 300KB, 30MB, 100MB, 300MB]
180180
postage-ttl: 360h # 15 days
181181
postage-depth: 22
182182
postage-label: test-label

pkg/check/smoke/load.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ func (c *LoadCheck) run(ctx context.Context, cluster orchestration.Cluster, o Op
6060
return errors.New("max committed depth is not set")
6161
}
6262

63+
contentSize := o.ContentSize
64+
6365
c.logger.Infof("random seed: %v", o.RndSeed)
64-
c.logger.Infof("content size: %v", o.ContentSize)
66+
c.logger.Infof("content size: %v", contentSize)
6567
c.logger.Infof("max committed depth: %v", o.MaxCommittedDepth)
6668
c.logger.Infof("committed depth check wait time: %v", o.CommittedDepthCheckWait)
6769
c.logger.Infof("total duration: %s", o.Duration.String())
@@ -82,18 +84,20 @@ func (c *LoadCheck) run(ctx context.Context, cluster orchestration.Cluster, o Op
8284
c.logger.Info("we are done")
8385
return nil
8486
default:
85-
c.logger.Infof("starting iteration: #%d", i)
87+
c.logger.Infof("starting iteration: #%d bytes (%.2f KB)", contentSize, float64(contentSize)/1024)
8688
}
8789

90+
sizeLabel := fmt.Sprintf("%d", contentSize)
91+
8892
var (
8993
txDuration time.Duration
9094
txData []byte
9195
address swarm.Address
9296
)
9397

94-
txData = make([]byte, o.ContentSize)
98+
txData = make([]byte, contentSize)
9599
if _, err := crand.Read(txData); err != nil {
96-
c.logger.Infof("unable to create random content: %v", err)
100+
c.logger.Infof("unable to create random content for size %d: %v", contentSize, err)
97101
continue
98102
}
99103

@@ -125,7 +129,7 @@ func (c *LoadCheck) run(ctx context.Context, cluster orchestration.Cluster, o Op
125129
return
126130
}
127131

128-
c.metrics.UploadAttempts.Inc()
132+
c.metrics.UploadAttempts.WithLabelValues(sizeLabel).Inc()
129133
var duration time.Duration
130134
c.logger.Infof("uploading to: %s", txName)
131135

@@ -139,7 +143,7 @@ func (c *LoadCheck) run(ctx context.Context, cluster orchestration.Cluster, o Op
139143

140144
address, duration, err = test.upload(ctx, txName, txData, batchID)
141145
if err != nil {
142-
c.metrics.UploadErrors.Inc()
146+
c.metrics.UploadErrors.WithLabelValues(sizeLabel).Inc()
143147
c.logger.Infof("upload failed: %v", err)
144148
c.logger.Infof("retrying in: %v", o.TxOnErrWait)
145149
time.Sleep(o.TxOnErrWait)
@@ -183,11 +187,11 @@ func (c *LoadCheck) run(ctx context.Context, cluster orchestration.Cluster, o Op
183187
default:
184188
}
185189

186-
c.metrics.DownloadAttempts.Inc()
190+
c.metrics.DownloadAttempts.WithLabelValues(sizeLabel).Inc()
187191

188192
rxData, rxDuration, err = test.download(ctx, rxName, address)
189193
if err != nil {
190-
c.metrics.DownloadErrors.Inc()
194+
c.metrics.DownloadErrors.WithLabelValues(sizeLabel).Inc()
191195
c.logger.Infof("download failed: %v", err)
192196
c.logger.Infof("retrying in: %v", o.RxOnErrWait)
193197
time.Sleep(o.RxOnErrWait)
@@ -202,7 +206,7 @@ func (c *LoadCheck) run(ctx context.Context, cluster orchestration.Cluster, o Op
202206
if !bytes.Equal(rxData, txData) {
203207
c.logger.Info("uploaded data does not match downloaded data")
204208

205-
c.metrics.DownloadMismatch.Inc()
209+
c.metrics.DownloadMismatch.WithLabelValues(sizeLabel).Inc()
206210

207211
rxLen, txLen := len(rxData), len(txData)
208212
if rxLen != txLen {
@@ -225,8 +229,16 @@ func (c *LoadCheck) run(ctx context.Context, cluster orchestration.Cluster, o Op
225229

226230
// We want to update the metrics when no error has been
227231
// encountered in order to avoid counter mismatch.
228-
c.metrics.UploadDuration.Observe(txDuration.Seconds())
229-
c.metrics.DownloadDuration.Observe(rxDuration.Seconds())
232+
c.metrics.UploadDuration.WithLabelValues(sizeLabel).Observe(txDuration.Seconds())
233+
c.metrics.DownloadDuration.WithLabelValues(sizeLabel).Observe(rxDuration.Seconds())
234+
if txDuration.Seconds() > 0 {
235+
uploadThroughput := float64(contentSize) / txDuration.Seconds()
236+
c.metrics.UploadThroughput.WithLabelValues(sizeLabel).Set(uploadThroughput)
237+
}
238+
if rxDuration.Seconds() > 0 {
239+
downloadThroughput := float64(contentSize) / rxDuration.Seconds()
240+
c.metrics.DownloadThroughput.WithLabelValues(sizeLabel).Set(downloadThroughput)
241+
}
230242
}()
231243
}
232244

pkg/check/smoke/metrics.go

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ import (
88
type metrics struct {
99
BatchCreateErrors prometheus.Counter
1010
BatchCreateAttempts prometheus.Counter
11-
UploadErrors prometheus.Counter
12-
UploadAttempts prometheus.Counter
13-
DownloadErrors prometheus.Counter
14-
DownloadMismatch prometheus.Counter
15-
DownloadAttempts prometheus.Counter
16-
UploadDuration prometheus.Histogram
17-
DownloadDuration prometheus.Histogram
18-
UploadSize prometheus.Gauge
11+
UploadErrors *prometheus.CounterVec
12+
UploadAttempts *prometheus.CounterVec
13+
DownloadErrors *prometheus.CounterVec
14+
DownloadMismatch *prometheus.CounterVec
15+
DownloadAttempts *prometheus.CounterVec
16+
UploadDuration *prometheus.HistogramVec
17+
DownloadDuration *prometheus.HistogramVec
18+
UploadThroughput *prometheus.GaugeVec
19+
DownloadThroughput *prometheus.GaugeVec
1920
}
2021

22+
const labelSizeBytes = "size_bytes"
23+
2124
func newMetrics(subsystem string) metrics {
2225
return metrics{
2326
BatchCreateAttempts: prometheus.NewCounter(
@@ -36,69 +39,86 @@ func newMetrics(subsystem string) metrics {
3639
Help: "Total errors encountered while creating batches.",
3740
},
3841
),
39-
UploadAttempts: prometheus.NewCounter(
42+
UploadAttempts: prometheus.NewCounterVec(
4043
prometheus.CounterOpts{
4144
Namespace: m.Namespace,
4245
Subsystem: subsystem,
4346
Name: "upload_attempts",
4447
Help: "Number of upload attempts.",
4548
},
49+
[]string{labelSizeBytes},
4650
),
47-
DownloadAttempts: prometheus.NewCounter(
51+
DownloadAttempts: prometheus.NewCounterVec(
4852
prometheus.CounterOpts{
4953
Namespace: m.Namespace,
5054
Subsystem: subsystem,
5155
Name: "download_attempts",
5256
Help: "Number of download attempts.",
5357
},
58+
[]string{labelSizeBytes},
5459
),
55-
UploadErrors: prometheus.NewCounter(
60+
UploadErrors: prometheus.NewCounterVec(
5661
prometheus.CounterOpts{
5762
Namespace: m.Namespace,
5863
Subsystem: subsystem,
5964
Name: "upload_errors_count",
6065
Help: "The total number of errors encountered before successful upload.",
6166
},
67+
[]string{labelSizeBytes},
6268
),
63-
DownloadErrors: prometheus.NewCounter(
69+
DownloadErrors: prometheus.NewCounterVec(
6470
prometheus.CounterOpts{
6571
Namespace: m.Namespace,
6672
Subsystem: subsystem,
6773
Name: "download_errors_count",
6874
Help: "The total number of errors encountered before successful download.",
6975
},
76+
[]string{labelSizeBytes},
7077
),
71-
DownloadMismatch: prometheus.NewCounter(
78+
DownloadMismatch: prometheus.NewCounterVec(
7279
prometheus.CounterOpts{
7380
Namespace: m.Namespace,
7481
Subsystem: subsystem,
7582
Name: "download_mismatch",
7683
Help: "The total number of times uploaded data is different from downloaded data.",
7784
},
85+
[]string{labelSizeBytes},
7886
),
79-
UploadDuration: prometheus.NewHistogram(
87+
UploadDuration: prometheus.NewHistogramVec(
8088
prometheus.HistogramOpts{
8189
Namespace: m.Namespace,
8290
Subsystem: subsystem,
8391
Name: "data_upload_duration",
8492
Help: "Data upload duration through the /bytes endpoint.",
8593
},
94+
[]string{labelSizeBytes},
8695
),
87-
DownloadDuration: prometheus.NewHistogram(
96+
DownloadDuration: prometheus.NewHistogramVec(
8897
prometheus.HistogramOpts{
8998
Namespace: m.Namespace,
9099
Subsystem: subsystem,
91100
Name: "data_download_duration",
92101
Help: "Data download duration through the /bytes endpoint.",
93102
},
103+
[]string{labelSizeBytes},
104+
),
105+
UploadThroughput: prometheus.NewGaugeVec(
106+
prometheus.GaugeOpts{
107+
Namespace: m.Namespace,
108+
Subsystem: subsystem,
109+
Name: "upload_throughput_bytes_per_second",
110+
Help: "Upload throughput in bytes per second.",
111+
},
112+
[]string{labelSizeBytes},
94113
),
95-
UploadSize: prometheus.NewGauge(
114+
DownloadThroughput: prometheus.NewGaugeVec(
96115
prometheus.GaugeOpts{
97116
Namespace: m.Namespace,
98117
Subsystem: subsystem,
99-
Name: "upload_size",
100-
Help: "Amount of data uploaded per upload.",
118+
Name: "download_throughput_bytes_per_second",
119+
Help: "Download throughput in bytes per second.",
101120
},
121+
[]string{labelSizeBytes},
102122
),
103123
}
104124
}

0 commit comments

Comments
 (0)