Skip to content
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

Add tests for stream upload #1027

Draft
wants to merge 3 commits into
base: sprint-1.13
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.11.1-0.20240204123736-4997432ef46e
github.com/0chain/gosdk v1.13.0-RC2.0.20240306153005-cb8d73ac4941
github.com/go-resty/resty/v2 v2.7.0
github.com/herumi/bls-go-binary v1.31.0
github.com/shopspring/decimal v1.3.1
Expand All @@ -22,7 +22,7 @@ require (
require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hitenjain14/fasthttp v0.0.0-20240201092245-8e4835c0e974 // indirect
github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17 // indirect
github.com/klauspost/compress v1.17.0 // indirect
github.com/lithammer/shortuuid/v3 v3.0.7 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.11.1-0.20240204123736-4997432ef46e h1:jp32bMKBQB0X7hTy965p9FayT3V5+LRdSjyDZYuHlAM=
github.com/0chain/gosdk v1.11.1-0.20240204123736-4997432ef46e/go.mod h1:ld0CtqdivpMrEoTWA5Z0nbv3A6Q7+w2/cA3iRGCGYS8=
github.com/0chain/gosdk v1.13.0-RC2.0.20240306153005-cb8d73ac4941 h1:SBf50ETWKveeDMVALcE43PAGqLmZm3dE3b26GW81FSY=
github.com/0chain/gosdk v1.13.0-RC2.0.20240306153005-cb8d73ac4941/go.mod h1:RRBLJvF1FsPkG95D+8UxeasgpFxnLO5s7QV2svXg69E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=
Expand Down Expand Up @@ -224,8 +224,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/herumi/bls-go-binary v1.31.0 h1:L1goQ2tMtGgpXCg5AwHAdJQpLs/pfnWWEc3Wog6OhmI=
github.com/herumi/bls-go-binary v1.31.0/go.mod h1:O4Vp1AfR4raRGwFeQpr9X/PQtncEicMoOe6BQt1oX0Y=
github.com/hitenjain14/fasthttp v0.0.0-20240201092245-8e4835c0e974 h1:oEjH9SSKBlzwDyYjzZaqRpxo7GlfUJCyRoOk7QHKSDs=
github.com/hitenjain14/fasthttp v0.0.0-20240201092245-8e4835c0e974/go.mod h1:RZMcXy7u4S+E97IXYTe7WHZ3+mCYOh4vys8PkIGZeXk=
github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17 h1:FbyIK0BfvXVZTOxKOe2dlxJqSPSF2ZXOv2Mc7dvS7sc=
github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17/go.mod h1:RZMcXy7u4S+E97IXYTe7WHZ3+mCYOh4vys8PkIGZeXk=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
Expand Down
3 changes: 3 additions & 0 deletions internal/api/util/client/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ func (c *SDKClient) AddUploadOperation(t *test.SystemTest, path, format string,
FileMeta: fileMeta,
Workdir: homeDir,
RemotePath: fileMeta.RemotePath,
Opts: []sdk.ChunkedUploadOption{
sdk.WithChunkNumber(120),
},
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/api_tests/repair_allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func TestRepairAllocation(testSetup *testing.T) {
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 2
blobberRequirements.ParityShards = 2
blobberRequirements.Size = 2056
blobberRequirements.Size = 240 * MB
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)

alloc, err := sdk.GetAllocation(allocationID)
require.NoError(t, err)
lastBlobber := alloc.Blobbers[0]
alloc.Blobbers[0].Baseurl = "http://0zus.com/"
op := sdkClient.AddUploadOperation(t, "", "")
op := sdkClient.AddUploadOperation(t, "", "", 100*MB)
sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op}, client.WithRepair(alloc.Blobbers))

sdkClient.RepairAllocation(t, allocationID)
Expand Down
34 changes: 34 additions & 0 deletions tests/api_tests/stream_upload_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package api_tests

import (
"testing"

"github.com/0chain/gosdk/zboxcore/sdk"
"github.com/0chain/system_test/internal/api/model"
"github.com/0chain/system_test/internal/api/util/client"
"github.com/0chain/system_test/internal/api/util/test"
"github.com/stretchr/testify/require"
)

func TestStreamUpload(testSetup *testing.T) {
t := test.NewSystemTest(testSetup)
t.SetSmokeTests("Stream upload should work")

t.RunSequentially("Stream upload should work", func(t *test.SystemTest) {
wallet := initialisedWallets[walletIdx]
walletIdx++
balance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(balance.Nonce)
sdkClient.SetWallet(t, wallet)
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.Size = 150 * MB
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)
op := sdkClient.AddUploadOperation(t, "", "", 100*MB)
op.FileMeta.ActualSize = 0
op.StreamUpload = true
sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op})
listResult := sdkClient.GetFileList(t, allocationID, "/")
require.Equal(t, 1, len(listResult.Children), "files count mismatch expected %v actual %v", 10, len(listResult.Children))
})
}
Loading