-
Notifications
You must be signed in to change notification settings - Fork 31
feat(redundancy): add redundancy level configuration for smoke check #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
e63ce38
08d39c4
199b519
a00ad6c
0dae27d
a9b0600
e801457
c14ea9b
5d5d384
1420fcf
47f4a1f
5581575
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import ( | |
| "reflect" | ||
| "time" | ||
|
|
||
| beeRedundancy "github.com/ethersphere/bee/v2/pkg/file/redundancy" | ||
| "github.com/ethersphere/beekeeper/pkg/beekeeper" | ||
| "github.com/ethersphere/beekeeper/pkg/check/act" | ||
| "github.com/ethersphere/beekeeper/pkg/check/balances" | ||
|
|
@@ -418,6 +419,7 @@ var Checks = map[string]CheckType{ | |
| RxOnErrWait *time.Duration `yaml:"rx-on-err-wait"` | ||
| NodesSyncWait *time.Duration `yaml:"nodes-sync-wait"` | ||
| Duration *time.Duration `yaml:"duration"` | ||
| RLevel *uint8 `yaml:"r-level"` | ||
|
akrem-chabchoub marked this conversation as resolved.
Outdated
|
||
| }) | ||
|
|
||
| if err := check.Options.Decode(checkOpts); err != nil { | ||
|
|
@@ -745,6 +747,19 @@ func applyCheckConfig(global CheckGlobalConfig, local, opts any) (err error) { | |
| ov.FieldByName(fieldName).Set(fieldValue) | ||
| } | ||
| } | ||
| case "RLevel": | ||
| if !lv.Field(i).IsNil() { // set locally | ||
| fieldValue := lv.FieldByName(fieldName).Elem() | ||
| level := uint8(fieldValue.Uint()) | ||
| rLevel := beeRedundancy.Level(level) | ||
| ft, ok := ot.FieldByName(fieldName) | ||
| if ok { | ||
| v := reflect.ValueOf(rLevel) | ||
| if v.Type().AssignableTo(ft.Type) { | ||
| ov.FieldByName(fieldName).Set(v) | ||
| } | ||
| } | ||
| } | ||
|
||
| default: | ||
| if lv.Field(i).IsNil() { | ||
| fmt.Printf("field %s not set, using default value\n", fieldName) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "fmt" | ||
| "time" | ||
|
|
||
| "github.com/ethersphere/bee/v2/pkg/file/redundancy" | ||
| "github.com/ethersphere/bee/v2/pkg/swarm" | ||
| "github.com/ethersphere/beekeeper/pkg/bee" | ||
| "github.com/ethersphere/beekeeper/pkg/bee/api" | ||
|
|
@@ -21,10 +22,10 @@ type test struct { | |
| logger logging.Logger | ||
| } | ||
|
|
||
| func (t *test) Upload(ctx context.Context, bee *bee.Client, data []byte, batchID string) (swarm.Address, time.Duration, error) { | ||
| func (t *test) Upload(ctx context.Context, bee *bee.Client, data []byte, batchID string, rLevel redundancy.Level) (swarm.Address, time.Duration, error) { | ||
| t.logger.Infof("node %s: uploading %d bytes, batch id %s", bee.Name(), len(data), batchID) | ||
| start := time.Now() | ||
| addr, err := bee.UploadBytes(ctx, data, api.UploadOptions{Pin: false, BatchID: batchID, Direct: true}) | ||
| addr, err := bee.UploadBytes(ctx, data, api.UploadOptions{Pin: false, BatchID: batchID, Direct: true, RLevel: rLevel}) | ||
| if err != nil { | ||
| return swarm.ZeroAddress, 0, fmt.Errorf("upload to node %s: %w", bee.Name(), err) | ||
| } | ||
|
|
@@ -35,11 +36,21 @@ func (t *test) Upload(ctx context.Context, bee *bee.Client, data []byte, batchID | |
| return addr, txDuration, nil | ||
| } | ||
|
|
||
| func (t *test) Download(ctx context.Context, bee *bee.Client, addr swarm.Address) ([]byte, time.Duration, error) { | ||
| func (t *test) Download(ctx context.Context, bee *bee.Client, addr swarm.Address, rLevel redundancy.Level) ([]byte, time.Duration, error) { | ||
| t.logger.Infof("node %s: downloading address %s", bee.Name(), addr) | ||
|
|
||
| start := time.Now() | ||
| data, err := bee.DownloadBytes(ctx, addr, nil) | ||
|
|
||
| var downloadOpts *api.DownloadOptions | ||
| if rLevel != redundancy.NONE { | ||
| fallbackMode := true | ||
| downloadOpts = &api.DownloadOptions{ | ||
| RLevel: rLevel, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RLevel should be assigned only if it is defined in the yaml file where is the configuration for the checks. |
||
| RedundancyFallbackMode: &fallbackMode, | ||
| } | ||
| } | ||
|
|
||
| data, err := bee.DownloadBytes(ctx, addr, downloadOpts) | ||
| if err != nil { | ||
| return nil, 0, fmt.Errorf("download from node %s: %w", bee.Name(), err) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.