Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ checks:
download-timeout: 1m
iteration-wait: 5m
duration: 10m
r-levels: [0, 2, 4]
timeout: 11m
type: smoke
ci-load:
Expand Down
6 changes: 6 additions & 0 deletions pkg/bee/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"net/url"
"strconv"
"strings"

"github.com/ethersphere/bee/v2/pkg/file/redundancy"
)

const (
Expand All @@ -32,6 +34,7 @@ const (
swarmFeedIndexNextHeader = "Swarm-Feed-Index-Next"
swarmIndexDocumentHeader = "Swarm-Index-Document"
swarmErrorDocumentHeader = "Swarm-Error-Document"
swarmRedundancyLevelHeader = "Swarm-Redundancy-Level"
)

// Client manages communication with the Bee API.
Expand Down Expand Up @@ -223,6 +226,9 @@ func (c *Client) requestDataGetHeader(ctx context.Context, method, path string,
if opts != nil && opts.Cache != nil {
req.Header.Set(swarmCacheDownloadHeader, strconv.FormatBool(*opts.Cache))
}
if opts != nil && opts.RLevel != nil && *opts.RLevel != redundancy.NONE {
Comment thread
akrem-chabchoub marked this conversation as resolved.
Outdated
req.Header.Set(swarmRedundancyLevelHeader, strconv.Itoa(int(*opts.RLevel)))
}
if opts != nil && opts.RedundancyFallbackMode != nil {
req.Header.Set(swarmRedundancyFallbackMode, strconv.FormatBool(*opts.RedundancyFallbackMode))
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/bee/api/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"strconv"

"github.com/ethersphere/bee/v2/pkg/file/redundancy"
"github.com/ethersphere/bee/v2/pkg/swarm"
)

Expand Down Expand Up @@ -34,6 +35,10 @@ func (b *BytesService) Upload(ctx context.Context, data io.Reader, o UploadOptio
}
h.Add(deferredUploadHeader, strconv.FormatBool(!o.Direct))
h.Add(postageStampBatchHeader, o.BatchID)
if o.RLevel != nil && *o.RLevel != redundancy.NONE {
Comment thread
akrem-chabchoub marked this conversation as resolved.
Outdated
h.Add(swarmRedundancyLevelHeader, strconv.Itoa(int(*o.RLevel)))
}

err := b.client.requestWithHeader(ctx, http.MethodPost, "/"+apiVersion+"/bytes", h, data, &resp)
return resp, err
}
7 changes: 6 additions & 1 deletion pkg/bee/api/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package api

import "github.com/ethersphere/bee/v2/pkg/swarm"
import (
"github.com/ethersphere/bee/v2/pkg/file/redundancy"
"github.com/ethersphere/bee/v2/pkg/swarm"
)

type UploadOptions struct {
Act bool
Expand All @@ -9,6 +12,7 @@ type UploadOptions struct {
BatchID string
Direct bool
ActHistoryAddress swarm.Address
RLevel *redundancy.Level

// Dirs
IndexDocument string
Expand All @@ -21,6 +25,7 @@ type DownloadOptions struct {
ActPublicKey *swarm.Address
ActTimestamp *uint64
Cache *bool
RLevel *redundancy.Level
RedundancyFallbackMode *bool
OnlyRootChunk *bool
}
7 changes: 5 additions & 2 deletions pkg/check/load/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sync"
"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/beekeeper"
Expand Down Expand Up @@ -203,7 +204,8 @@ func (c *Check) run(ctx context.Context, cluster orchestration.Cluster, o Option

c.logger.WithField("batch_id", batchID).Infof("node %s: using batch", uploader.Name())

address, duration, err = test.Upload(ctx, uploader, txData, batchID)
rLevel := redundancy.NONE
address, duration, err = test.Upload(ctx, uploader, txData, batchID, &rLevel)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to have default value for the rLevel, we should take it from configuration directly as is, to be backwards compatibile. If the rLevel is defined we should forward it. If not, use nil.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can set it to nil and later we do proper update to load check ? because it will require some modification to the check itself, wdyt ?

if err != nil {
c.metrics.UploadErrors.WithLabelValues(sizeLabel).Inc()
c.logger.Errorf("upload failed: %v", err)
Expand Down Expand Up @@ -246,7 +248,8 @@ func (c *Check) run(ctx context.Context, cluster orchestration.Cluster, o Option

c.metrics.DownloadAttempts.WithLabelValues(sizeLabel).Inc()

rxData, rxDuration, err = test.Download(ctx, downloader, address)
rLevel := redundancy.NONE
rxData, rxDuration, err = test.Download(ctx, downloader, address, &rLevel)
Comment thread
akrem-chabchoub marked this conversation as resolved.
Outdated
if err != nil {
c.metrics.DownloadErrors.WithLabelValues(sizeLabel).Inc()
c.logger.Errorf("download failed for size %d: %v", contentSize, err)
Expand Down
Loading