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

fix client sig #995

Open
wants to merge 13 commits into
base: sprint-1.17
Choose a base branch
from
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.1

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.14.0-RC2
github.com/0chain/gosdk v1.15.2-0.20240614082721-1b8ad4f48bc6
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 @@ -26,7 +26,7 @@ require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect
github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17 // indirect
github.com/hitenjain14/fasthttp v0.0.0-20240527123209-06019e79bff9 // 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
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ 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.14.0-RC2 h1:OIpjj7mDKxVqJVlxJKm8/fPzdJRN5roXO7/plBCtmTg=
github.com/0chain/gosdk v1.14.0-RC2/go.mod h1:tgAiVAuIy+Vs1tGfKCPEuuWWARwNQBEw32y950LrqrU=
github.com/0chain/gosdk v1.15.2-0.20240614082721-1b8ad4f48bc6 h1:f8fN6PuvE/Iu1LqrJH5q20eWOFB/NjlDA8TIDMqZgAg=
github.com/0chain/gosdk v1.15.2-0.20240614082721-1b8ad4f48bc6/go.mod h1:Hzl56JJ66ZmoyNS7CbTJue7wUugBYvNx8/qJzTRWmkI=
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 @@ -240,6 +242,7 @@ github.com/herumi/bls-go-binary v1.31.0 h1:L1goQ2tMtGgpXCg5AwHAdJQpLs/pfnWWEc3Wo
github.com/herumi/bls-go-binary v1.31.0/go.mod h1:O4Vp1AfR4raRGwFeQpr9X/PQtncEicMoOe6BQt1oX0Y=
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/hitenjain14/fasthttp v0.0.0-20240527123209-06019e79bff9/go.mod h1:RZMcXy7u4S+E97IXYTe7WHZ3+mCYOh4vys8PkIGZeXk=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8=
Expand Down
1 change: 0 additions & 1 deletion internal/api/model/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,6 @@ type LatestWriteMarker struct {
}

type BlobberGetFileRefsResponse struct {
TotalPages int `json:"total_pages"`
OffsetPath string `json:"offset_path"`
Refs []*RefsData `json:"refs"`
LatestWriteMarker *LatestWriteMarker `json:"latest_write_marker"`
Expand Down
26 changes: 13 additions & 13 deletions internal/api/util/client/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,11 @@ func (c *APIClient) V1BlobberGetHashNodeRoot(t *test.SystemTest, blobberGetHashn
var hashnode *model.BlobberGetHashnodeResponse

headers := map[string]string{
"X-App-Client-Id": blobberGetHashnodeRequest.ClientId,
"X-App-Client-Key": blobberGetHashnodeRequest.ClientKey,
"X-App-Client-Signature": blobberGetHashnodeRequest.ClientSignature,
"allocation": blobberGetHashnodeRequest.AllocationID,
"ALLOCATION-ID": blobberGetHashnodeRequest.AllocationID,
"X-App-Client-Id": blobberGetHashnodeRequest.ClientId,
"X-App-Client-Key": blobberGetHashnodeRequest.ClientKey,
"X-App-Client-Signature-V2": blobberGetHashnodeRequest.ClientSignature,
"allocation": blobberGetHashnodeRequest.AllocationID,
"ALLOCATION-ID": blobberGetHashnodeRequest.AllocationID,
}

blobberGetHashNodeRootURL := blobberGetHashnodeRequest.URL + "/" + strings.Replace(GetHashNodeRoot, ":allocation", blobberGetHashnodeRequest.AllocationID, 1)
Expand Down Expand Up @@ -1948,10 +1948,10 @@ func (c *APIClient) V1BlobberGetFileRefs(t *test.SystemTest, blobberGetFileRefsR
blobberGetFileRefsURL := blobberGetFileRefsRequest.URL + strings.Replace(GetFileRef, ":allocation_id", blobberGetFileRefsRequest.AllocationID, 1) + "?" + "path=" + blobberGetFileRefsRequest.RemotePath + "&" + "refType=" + blobberGetFileRefsRequest.RefType

headers := map[string]string{
"X-App-Client-Id": blobberGetFileRefsRequest.ClientID,
"X-App-Client-Key": blobberGetFileRefsRequest.ClientKey,
"X-App-Client-Signature": blobberGetFileRefsRequest.ClientSignature,
"ALLOCATION-ID": blobberGetFileRefsRequest.AllocationID,
"X-App-Client-Id": blobberGetFileRefsRequest.ClientID,
"X-App-Client-Key": blobberGetFileRefsRequest.ClientKey,
"X-App-Client-Signature-V2": blobberGetFileRefsRequest.ClientSignature,
"ALLOCATION-ID": blobberGetFileRefsRequest.AllocationID,
}
resp, err := c.executeForServiceProvider(
t,
Expand Down Expand Up @@ -2043,10 +2043,10 @@ func (c *APIClient) V1BlobberObjectTree(t *test.SystemTest, blobberObjectTreeReq
blobberObjectTreeURL := blobberObjectTreeRequest.URL + strings.Replace(GetObjectTree, ":allocation_id", blobberObjectTreeRequest.AllocationID, 1) + "?" + "path=" + blobberObjectTreeRequest.Path

headers := map[string]string{
"X-App-Client-Id": blobberObjectTreeRequest.ClientID,
"X-App-Client-Key": blobberObjectTreeRequest.ClientKey,
"X-App-Client-Signature": blobberObjectTreeRequest.ClientSignature,
"ALLOCATION-ID": blobberObjectTreeRequest.AllocationID,
"X-App-Client-Id": blobberObjectTreeRequest.ClientID,
"X-App-Client-Key": blobberObjectTreeRequest.ClientKey,
"X-App-Client-Signature-V2": blobberObjectTreeRequest.ClientSignature,
"ALLOCATION-ID": blobberObjectTreeRequest.AllocationID,
}
resp, err := c.executeForServiceProvider(
t,
Expand Down
8 changes: 8 additions & 0 deletions internal/cli/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,14 @@ type ReadMarker struct {
BlockNumber int64 `json:"block_number"`
}

// holds result of repair size
type RepairSize struct {
// upload size in bytes
UploadSize uint64 `json:"upload_size"`
// download size in bytes
DownloadSize uint64 `json:"download_size"`
}

var StorageKeySettings = []string{
"owner_id",
}
Expand Down
10 changes: 5 additions & 5 deletions tests/api_tests/blobber_hashnode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ func TestHashnodeRoot(testSetup *testing.T) {
usedBlobberID := getFirstUsedStorageNodeID(allocationBlobbers.Blobbers, allocation.Blobbers)
require.NotZero(t, usedBlobberID, "Old blobber ID contains zero value")

sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocation.ID)), "bls0chain", []*model.KeyPair{wallet.Keys})
require.Nil(t, err)

blobberUrl := getBlobberURL(usedBlobberID, allocation.Blobbers)

sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocation.Tx+blobberUrl)), "bls0chain", []*model.KeyPair{wallet.Keys})
require.Nil(t, err)

blobberRequest := &model.BlobberGetHashnodeRequest{
AllocationID: allocation.ID,
URL: blobberUrl,
Expand All @@ -58,7 +58,7 @@ func TestHashnodeRoot(testSetup *testing.T) {

blobberUrl := apiClient.HealthyServiceProviders.Blobbers[0]

sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocationID)), "bls0chain", []*model.KeyPair{wallet.Keys})
sign, err := crypto.SignHashUsingSignatureScheme(crypto.Sha3256([]byte(allocationID+blobberUrl)), "bls0chain", []*model.KeyPair{wallet.Keys})
require.Nil(t, err)

blobberRequest := &model.BlobberGetHashnodeRequest{
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestHashnodeRoot(testSetup *testing.T) {

getBlobberResponse, restyResponse, err := apiClient.V1BlobberGetHashNodeRoot(t, blobberRequest, client.HttpOkStatus)
require.NotNil(t, err)
require.Equal(t, "bad request: invalid signature badsign\n", string(restyResponse.Body()))
require.Equal(t, "bad request: invalid signature \n", string(restyResponse.Body()))
require.Nil(t, getBlobberResponse)
})

Expand Down
8 changes: 4 additions & 4 deletions tests/api_tests/blobber_objecttree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestObjectTree(testSetup *testing.T) {
blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -69,7 +69,7 @@ func TestObjectTree(testSetup *testing.T) {
blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -103,7 +103,7 @@ func TestObjectTree(testSetup *testing.T) {
blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
blobberUrl := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + blobberUrl)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)
blobberObjectTreeRequest := newBlobberObjectTreeRequest(blobberUrl, wallet, "invalid_allocation_id", clientSignature, remoteFilePath)
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestObjectTree(testSetup *testing.T) {
blobber := apiClient.GetBlobber(t, blobberID, client.HttpOkStatus)
blobberUrl := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + blobberUrl)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)
blobberObjectTreeRequest := newBlobberObjectTreeRequest(blobberUrl, wallet, allocation.ID, clientSignature, "invalid_path")
Expand Down
20 changes: 9 additions & 11 deletions tests/api_tests/get_blobberFileRef_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
refType := "regular"
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand All @@ -47,7 +47,6 @@ func TestBlobberFileRefs(testSetup *testing.T) {
require.Nil(t, err)
require.NotNil(t, blobberFileRefsResponse)
require.Equal(t, resp.StatusCode(), client.HttpOkStatus, resp)
require.GreaterOrEqual(t, blobberFileRefsResponse.TotalPages, int(1))
require.Equal(t, blobberFileRefsResponse.OffsetPath, remoteFilePath)
require.Greater(t, len(blobberFileRefsResponse.Refs), int(0))
require.NotNil(t, blobberFileRefsResponse.LatestWriteMarker.AllocationRoot)
Expand All @@ -66,7 +65,6 @@ func TestBlobberFileRefs(testSetup *testing.T) {
require.Nil(t, err)
require.NotNil(t, blobberFileRefsResponse)
require.Equal(t, resp.StatusCode(), client.HttpOkStatus)
require.GreaterOrEqual(t, blobberFileRefsResponse.TotalPages, int(1))
require.Equal(t, blobberFileRefsResponse.OffsetPath, remoteFilePath)
require.Greater(t, len(blobberFileRefsResponse.Refs), int(0))
require.NotNil(t, blobberFileRefsResponse.LatestWriteMarker.AllocationRoot)
Expand Down Expand Up @@ -95,7 +93,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
refType := "regular"
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -126,7 +124,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
refType := "regular"
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -157,7 +155,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
refType := "invalid-ref-type"
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -188,7 +186,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
refType := "invalid-ref-type"
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -219,7 +217,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
refType := ""
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -250,7 +248,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
refType := ""
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -308,7 +306,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, wallet.Mnemonics)
refType := "regular"
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down Expand Up @@ -344,7 +342,7 @@ func TestBlobberFileRefs(testSetup *testing.T) {
url := blobber.BaseURL
keyPair := crypto.GenerateKeys(t, initialisedWallet.Mnemonics)
refType := "regular"
sign := encryption.Hash(allocation.Tx)
sign := encryption.Hash(allocation.Tx + url)

clientSignature := crypto.SignHexString(t, sign, &keyPair.PrivateKey)

Expand Down
100 changes: 100 additions & 0 deletions tests/api_tests/repair_allocation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,103 @@ func TestRepairAllocation(testSetup *testing.T) {
}
})
}

func TestRepairSize(testSetup *testing.T) {
t := test.NewSystemTest(testSetup)
wallet := createWallet(t)
sdkClient.SetWallet(t, wallet)
apiClient.CreateReadPool(t, wallet, 0.5, client.TxSuccessfulStatus)

t.RunSequentiallyWithTimeout("repair size in case of no blobber failure should be zero", 5 * time.Minute, func(t *test.SystemTest) {
// create allocation with default blobber requirements
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)
t.Logf("allocationID: %v", allocationID)

// create and upload a file of 2KB to allocation.
op := sdkClient.AddUploadOperation(t, "", "", int64(1024 * 2))
sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op})

// assert both upload and download size should be zero
alloc, err := sdk.GetAllocation(allocationID)
require.NoErrorf(t, err, "allocation ID %v is not found", allocationID)
rs, err := alloc.RepairSize("/")
require.Nil(t, err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(0), rs.UploadSize, "upload size doesn't match")
require.Equal(t, uint64(0), rs.DownloadSize, "download size doesn't match")
})

t.RunSequentiallyWithTimeout("repair size on single blobber failure should match", 5 * time.Minute, func(t *test.SystemTest) {
// create allocation with default blobber requirements
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 2
blobberRequirements.ParityShards = 2
blobberRequirements.Size = 2056
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)
t.Logf("allocationID: %v", allocationID)

// create and upload a file of 2KB to allocation.
// one blobber url is set invalid to mimic failure.
alloc, err := sdk.GetAllocation(allocationID)
require.NoErrorf(t, err, "allocation ID %v is not found", allocationID)
alloc.Blobbers[0].Baseurl = "http://0zus.com/"
op := sdkClient.AddUploadOperation(t, "", "", int64(1024 * 2))
sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op}, client.WithRepair(alloc.Blobbers))

// assert upload and download size should be 1KB and 2KB respectively
rs, err := alloc.RepairSize("/")
require.Nil(t, err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(1024), rs.UploadSize, "upload size doesn't match")
require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size doesn't match")
})

t.RunSequentiallyWithTimeout("repair size with nested directories and two blobber failure should match", 5 * time.Minute, func(t *test.SystemTest) {
// create allocation with default blobber requirements
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 2
blobberRequirements.ParityShards = 4
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus)
t.Logf("allocationID: %v", allocationID)

// create and upload two files of 1KB each to / and /dir1.
// two blobber url is set invalid to mimic failure.
alloc, err := sdk.GetAllocation(allocationID)
require.NoErrorf(t, err, "allocation ID %v is not found", allocationID)
alloc.Blobbers[0].Baseurl = "http://0zus.com/"
alloc.Blobbers[1].Baseurl = "http://0zus.com/"
ops := []sdk.OperationRequest{
sdkClient.AddUploadOperationWithPath(t, allocationID, "/dir1/"),
sdkClient.AddUploadOperationWithPath(t, allocationID, "/dir1/"),
sdkClient.AddUploadOperationWithPath(t, allocationID, "/"),
sdkClient.AddUploadOperationWithPath(t, allocationID, "/"),
}
sdkClient.MultiOperation(t, allocationID, ops, client.WithRepair(alloc.Blobbers))

// assert both upload and download size should be 2KB in /dir1
rs, err := alloc.RepairSize("/dir1")
require.Nilf(t, err, "error getting repair size in /dir1: %v", err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(1024 * 2), rs.UploadSize, "upload size in directory /dir1 doesn't match")
require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size in directory dir1 doesn't match")

// with trailing slash
// assert both upload and download size should be 2KB in /dir1/
rs, err = alloc.RepairSize("/dir1/")
require.Nilf(t, err, "error getting repair size in /dir1/: %v", err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(1024 * 2), rs.UploadSize, "upload size in directory /dir1/ doesn't match")
require.Equal(t, uint64(1024 * 2), rs.DownloadSize, "download size in directory /dir1/ doesn't match")

// assert both upload and download size should be 4KB in root directory
rs, err = alloc.RepairSize("/")
require.Nilf(t, err, "error getting repair size in /: %v", err)
t.Logf("repair size: %v", rs)
require.Equal(t, uint64(1024 * 4), rs.UploadSize, "upload size in root directory doesn't match")
require.Equal(t, uint64(1024 * 4), rs.DownloadSize, "download size in root directory doesn't match")
})
}
2 changes: 1 addition & 1 deletion tests/cli_tests/0_s3mgrt_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func Test0S3Migration(testSetup *testing.T) {

require.NotNil(t, err, "Expected a migration failure but got no error", strings.Join(output, "\n"))
require.Greater(t, len(output), 0, "More/Less output was returned than expected", strings.Join(output, "\n"))
require.Contains(t, output[0], "alloc: no enough space left in allocation", "Output was not as expected", strings.Join(output, "\n"))
require.Contains(t, output[0], "max_allocation_size", "Output was not as expected", strings.Join(output, "\n"))
})

t.RunSequentially("Should fail when bucket does not exist", func(t *test.SystemTest) {
Expand Down
Loading
Loading