Skip to content

Commit 6033cb5

Browse files
fix(load): use status endpoint to check for CommittedDepth (#456)
* fix(load): use status endpoint to check for CommittedDepth * fix(load): use status endpoint to check for CommittedDepth * fix(load): improve log msg * fix(load): replace storage radius with committed depth * fix(lint): resolve misspelled
1 parent ab5d6e0 commit 6033cb5

File tree

9 files changed

+107
-65
lines changed

9 files changed

+107
-65
lines changed

config/config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ checks:
372372
duration: 12h
373373
downloader-count: 3
374374
uploader-count: 2
375-
max-storage-radius: 2
375+
max-committed-depth: 2
376+
committed-depth-check-wait: 5m
376377
upload-groups:
377378
- bee
378379
download-groups:

config/public-testnet.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ checks:
137137
uploader-count: 2
138138
downloader-count: 0
139139
max-use-batch: 1h
140-
max-storage-radius: 3
140+
max-committed-depth: 3
141+
committed-depth-check-wait: 5m
141142
upload-groups:
142143
- bee-1
143144
- bee-2

config/staging.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ checks:
5757
uploader-count: 2
5858
downloader-count: 0
5959
max-use-batch: 1h
60-
max-storage-radius: 3
60+
max-committed-depth: 3
61+
committed-depth-check-wait: 5m
6162
upload-groups:
6263
- bee-1
6364
- bee-2

pkg/bee/api/api.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,19 @@ type Client struct {
4949
Act *ActService
5050
Bytes *BytesService
5151
Chunks *ChunksService
52-
Files *FilesService
5352
Dirs *DirsService
54-
Pinning *PinningService
55-
Tags *TagsService
56-
PSS *PSSService
57-
SOC *SOCService
58-
Stewardship *StewardshipService
53+
Feed *FeedService
54+
Files *FilesService
5955
Node *NodeService
6056
PingPong *PingPongService
57+
Pinning *PinningService
6158
Postage *PostageService
59+
PSS *PSSService
60+
SOC *SOCService
6261
Stake *StakingService
63-
Feed *FeedService
62+
Status *StatusService
63+
Stewardship *StewardshipService
64+
Tags *TagsService
6465
}
6566

6667
// ClientOptions holds optional parameters for the Client.
@@ -86,21 +87,24 @@ func NewClient(baseURL *url.URL, o *ClientOptions) (c *Client) {
8687
func newClient(httpClient *http.Client) (c *Client) {
8788
c = &Client{httpClient: httpClient}
8889
c.service.client = c
90+
8991
c.Act = (*ActService)(&c.service)
9092
c.Bytes = (*BytesService)(&c.service)
9193
c.Chunks = (*ChunksService)(&c.service)
92-
c.Files = (*FilesService)(&c.service)
9394
c.Dirs = (*DirsService)(&c.service)
94-
c.Pinning = (*PinningService)(&c.service)
95-
c.Tags = (*TagsService)(&c.service)
96-
c.PSS = (*PSSService)(&c.service)
97-
c.SOC = (*SOCService)(&c.service)
98-
c.Stewardship = (*StewardshipService)(&c.service)
95+
c.Feed = (*FeedService)(&c.service)
96+
c.Files = (*FilesService)(&c.service)
9997
c.Node = (*NodeService)(&c.service)
10098
c.PingPong = (*PingPongService)(&c.service)
99+
c.Pinning = (*PinningService)(&c.service)
101100
c.Postage = (*PostageService)(&c.service)
101+
c.PSS = (*PSSService)(&c.service)
102+
c.SOC = (*SOCService)(&c.service)
102103
c.Stake = (*StakingService)(&c.service)
103-
c.Feed = (*FeedService)(&c.service)
104+
c.Status = (*StatusService)(&c.service)
105+
c.Stewardship = (*StewardshipService)(&c.service)
106+
c.Tags = (*TagsService)(&c.service)
107+
104108
return c
105109
}
106110

pkg/bee/api/status.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package api
2+
3+
import (
4+
"context"
5+
"net/http"
6+
)
7+
8+
type StatusService service
9+
10+
type StatusResponse struct {
11+
Overlay string `json:"overlay"`
12+
Proximity uint `json:"proximity"`
13+
BeeMode string `json:"beeMode"`
14+
ReserveSize uint64 `json:"reserveSize"`
15+
ReserveSizeWithinRadius uint64 `json:"reserveSizeWithinRadius"`
16+
PullsyncRate float64 `json:"pullsyncRate"`
17+
StorageRadius uint8 `json:"storageRadius"`
18+
ConnectedPeers uint64 `json:"connectedPeers"`
19+
NeighborhoodSize uint64 `json:"neighborhoodSize"`
20+
RequestFailed bool `json:"requestFailed,omitempty"`
21+
BatchCommitment uint64 `json:"batchCommitment"`
22+
IsReachable bool `json:"isReachable"`
23+
LastSyncedBlock uint64 `json:"lastSyncedBlock"`
24+
CommittedDepth uint8 `json:"committedDepth"`
25+
}
26+
27+
// Ping pings given node
28+
func (s *StatusService) Status(ctx context.Context) (resp *StatusResponse, err error) {
29+
err = s.client.requestJSON(ctx, http.MethodGet, "/status", nil, &resp)
30+
return
31+
}

pkg/bee/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,3 +960,7 @@ func (c *Client) UpdateFeedWithReference(ctx context.Context, signer crypto.Sign
960960
func (c *Client) FindFeedUpdate(ctx context.Context, signer crypto.Signer, topic []byte, o *api.DownloadOptions) (*api.FindFeedUpdateResponse, error) {
961961
return c.api.Feed.FindUpdate(ctx, signer, topic, o)
962962
}
963+
964+
func (c *Client) Status(ctx context.Context) (*api.StatusResponse, error) {
965+
return c.api.Status.Status(ctx)
966+
}

pkg/check/smoke/load.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ func (c *LoadCheck) Run(ctx context.Context, cluster orchestration.Cluster, opts
4848
return errors.New("no uploaders requested, quiting")
4949
}
5050

51-
if o.MaxStorageRadius == 0 {
52-
return errors.New("max storage radius is not set")
51+
if o.MaxCommittedDepth == 0 {
52+
return errors.New("max committed depth is not set")
5353
}
5454

5555
c.logger.Infof("random seed: %v", o.RndSeed)
5656
c.logger.Infof("content size: %v", o.ContentSize)
5757
c.logger.Infof("max batch lifespan: %v", o.MaxUseBatch)
58-
c.logger.Infof("max storage radius: %v", o.MaxStorageRadius)
59-
c.logger.Infof("storage radius check wait time: %v", o.StorageRadiusCheckWait)
58+
c.logger.Infof("max committed depth: %v", o.MaxCommittedDepth)
59+
c.logger.Infof("committed depth check wait time: %v", o.CommittedDepthCheckWait)
6060

6161
clients, err := cluster.NodesClients(ctx)
6262
if err != nil {
@@ -116,7 +116,7 @@ func (c *LoadCheck) Run(ctx context.Context, cluster orchestration.Cluster, opts
116116
default:
117117
}
118118

119-
if !c.checkStorageRadius(ctx, test.clients[txName], o.MaxStorageRadius, o.StorageRadiusCheckWait) {
119+
if !c.checkcommittedDepth(ctx, test.clients[txName], o.MaxCommittedDepth, o.CommittedDepthCheckWait) {
120120
return
121121
}
122122

@@ -231,21 +231,21 @@ func (c *LoadCheck) Run(ctx context.Context, cluster orchestration.Cluster, opts
231231
return nil
232232
}
233233

234-
func (c *LoadCheck) checkStorageRadius(ctx context.Context, client *bee.Client, maxRadius uint8, wait time.Duration) bool {
234+
func (c *LoadCheck) checkcommittedDepth(ctx context.Context, client *bee.Client, maxDepth uint8, wait time.Duration) bool {
235235
for {
236-
rs, err := client.ReserveState(ctx)
236+
statusResp, err := client.Status(ctx)
237237
if err != nil {
238238
c.logger.Infof("error getting state: %v", err)
239239
return false
240240
}
241-
if rs.StorageRadius < maxRadius {
241+
if statusResp.CommittedDepth < maxDepth {
242242
return true
243243
}
244-
c.logger.Infof("waiting %v for StorageRadius to decrease. Current: %d, Max: %d", wait, rs.StorageRadius, maxRadius)
244+
c.logger.Infof("waiting %v for CommittedDepth to decrease. Current: %d, Max: %d", wait, statusResp.CommittedDepth, maxDepth)
245245

246246
select {
247247
case <-ctx.Done():
248-
c.logger.Infof("context done in StorageRadius check: %v", ctx.Err())
248+
c.logger.Infof("context done while waiting for CommittedDepth to decrease: %v", ctx.Err())
249249
return false
250250
case <-time.After(wait):
251251
}

pkg/check/smoke/smoke.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,33 @@ type Options struct {
2929
UploadTimeout time.Duration
3030
DownloadTimeout time.Duration
3131
// load test params
32-
UploaderCount int
33-
UploadGroups []string
34-
DownloaderCount int
35-
DownloadGroups []string
36-
MaxUseBatch time.Duration
37-
MaxStorageRadius uint8
38-
StorageRadiusCheckWait time.Duration
39-
IterationWait time.Duration
32+
UploaderCount int
33+
UploadGroups []string
34+
DownloaderCount int
35+
DownloadGroups []string
36+
MaxUseBatch time.Duration
37+
MaxCommittedDepth uint8
38+
CommittedDepthCheckWait time.Duration
39+
IterationWait time.Duration
4040
}
4141

4242
// NewDefaultOptions returns new default options
4343
func NewDefaultOptions() Options {
4444
return Options{
45-
ContentSize: 5000000,
46-
RndSeed: time.Now().UnixNano(),
47-
PostageAmount: 50_000_000,
48-
PostageDepth: 24,
49-
TxOnErrWait: 10 * time.Second,
50-
RxOnErrWait: 10 * time.Second,
51-
NodesSyncWait: time.Minute,
52-
Duration: 12 * time.Hour,
53-
UploadTimeout: 60 * time.Minute,
54-
DownloadTimeout: 60 * time.Minute,
55-
MaxUseBatch: 12 * time.Hour,
56-
MaxStorageRadius: 2,
57-
StorageRadiusCheckWait: 5 * time.Minute,
58-
IterationWait: 5 * time.Minute,
45+
ContentSize: 5000000,
46+
RndSeed: time.Now().UnixNano(),
47+
PostageAmount: 50_000_000,
48+
PostageDepth: 24,
49+
TxOnErrWait: 10 * time.Second,
50+
RxOnErrWait: 10 * time.Second,
51+
NodesSyncWait: time.Minute,
52+
Duration: 12 * time.Hour,
53+
UploadTimeout: 60 * time.Minute,
54+
DownloadTimeout: 60 * time.Minute,
55+
MaxUseBatch: 12 * time.Hour,
56+
MaxCommittedDepth: 2,
57+
CommittedDepthCheckWait: 5 * time.Minute,
58+
IterationWait: 5 * time.Minute,
5959
}
6060
}
6161

pkg/config/check.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -407,22 +407,22 @@ var Checks = map[string]CheckType{
407407
NewAction: smoke.NewLoadCheck,
408408
NewOptions: func(checkGlobalConfig CheckGlobalConfig, check Check) (interface{}, error) {
409409
checkOpts := new(struct {
410-
ContentSize *int64 `yaml:"content-size"`
411-
RndSeed *int64 `yaml:"rnd-seed"`
412-
PostageAmount *int64 `yaml:"postage-amount"`
413-
PostageDepth *uint64 `yaml:"postage-depth"`
414-
GasPrice *string `yaml:"gas-price"`
415-
TxOnErrWait *time.Duration `yaml:"tx-on-err-wait"`
416-
RxOnErrWait *time.Duration `yaml:"rx-on-err-wait"`
417-
NodesSyncWait *time.Duration `yaml:"nodes-sync-wait"`
418-
Duration *time.Duration `yaml:"duration"`
419-
UploaderCount *int `yaml:"uploader-count"`
420-
UploadGroups *[]string `yaml:"upload-groups"`
421-
DownloaderCount *int `yaml:"downloader-count"`
422-
DownloadGroups *[]string `yaml:"download-groups"`
423-
MaxUseBatch *time.Duration `yaml:"max-use-batch"`
424-
MaxStorageRadius *uint8 `yaml:"max-storage-radius"`
425-
StorageRadiusCheckWait *time.Duration `yaml:"storage-radius-check-wait"`
410+
ContentSize *int64 `yaml:"content-size"`
411+
RndSeed *int64 `yaml:"rnd-seed"`
412+
PostageAmount *int64 `yaml:"postage-amount"`
413+
PostageDepth *uint64 `yaml:"postage-depth"`
414+
GasPrice *string `yaml:"gas-price"`
415+
TxOnErrWait *time.Duration `yaml:"tx-on-err-wait"`
416+
RxOnErrWait *time.Duration `yaml:"rx-on-err-wait"`
417+
NodesSyncWait *time.Duration `yaml:"nodes-sync-wait"`
418+
Duration *time.Duration `yaml:"duration"`
419+
UploaderCount *int `yaml:"uploader-count"`
420+
UploadGroups *[]string `yaml:"upload-groups"`
421+
DownloaderCount *int `yaml:"downloader-count"`
422+
DownloadGroups *[]string `yaml:"download-groups"`
423+
MaxUseBatch *time.Duration `yaml:"max-use-batch"`
424+
MaxCommittedDepth *uint8 `yaml:"max-committed-depth"`
425+
CommittedDepthCheckWait *time.Duration `yaml:"committed-depth-check-wait"`
426426
})
427427
if err := check.Options.Decode(checkOpts); err != nil {
428428
return nil, fmt.Errorf("decoding check %s options: %w", check.Type, err)

0 commit comments

Comments
 (0)