Skip to content

Commit 96330b9

Browse files
FelGelassaf758
authored andcommitted
Test fixes
1 parent f9da808 commit 96330b9

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

pkg/dataplane/test/sync_test.go

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package test
33
import (
44
"fmt"
55
"math/rand"
6+
"path/filepath"
67
"strconv"
78
"strings"
89
"testing"
@@ -864,7 +865,7 @@ func (suite *syncKVTestSuite) TestEMD() {
864865
// Delete everything
865866
//
866867

867-
suite.deleteItems(itemsToCreate)
868+
suite.deleteItems("/emd0", itemsToCreate)
868869
}
869870

870871
func (suite *syncKVTestSuite) TestPutItems() {
@@ -895,13 +896,15 @@ func (suite *syncKVTestSuite) TestPutItems() {
895896

896897
suite.verifyItems(items)
897898

898-
suite.deleteItems(items)
899+
suite.deleteItems(putItemsInput.Path, items)
899900
}
900901

901902
func (suite *syncKVTestSuite) TestScatteredCursor() {
902-
path := "/emd0"
903+
path := "/emd1/scattered_cursor"
903904

904-
items, scatteredItemKeys := suite.populateScatteredItems(path)
905+
numOfChunks := 4
906+
chunkSize := 30
907+
items, scatteredItemKeys := suite.populateScatteredItems(path, numOfChunks, chunkSize)
905908

906909
// Get cursor
907910
getItemsInput := v3io.GetItemsInput{
@@ -948,18 +951,20 @@ func (suite *syncKVTestSuite) TestScatteredCursor() {
948951
blobCounter++
949952
}
950953
}
951-
suite.Assert().Equal(6*30, blobCounter)
954+
suite.Assert().Equal(numOfChunks*chunkSize, blobCounter)
952955
}
953956
}
954957
}
955958

956-
suite.deleteItems(items)
959+
suite.deleteItems(path, items)
957960
}
958961

959962
func (suite *syncKVTestSuite) TestIncludeResponseInError() {
960-
path := "/emd0"
963+
path := "/emd1/response_in_error"
961964

962-
items, scatteredItemKeys := suite.populateScatteredItems(path)
965+
numOfChunks := 6
966+
chunkSize := 30
967+
items, scatteredItemKeys := suite.populateScatteredItems(path, numOfChunks, chunkSize)
963968

964969
// Issue GetItems request with scattering disabled. Since there are scattered items this will create an error
965970
getItemsInput := v3io.GetItemsInput{
@@ -1000,6 +1005,7 @@ func (suite *syncKVTestSuite) TestIncludeResponseInError() {
10001005

10011006
suite.Assert().Equal(len(items), receivedItems)
10021007
suite.Assert().ElementsMatch(scatteredItemKeys, errorItemKeys)
1008+
suite.deleteItems(path, items)
10031009
}
10041010

10051011
func (suite *syncKVTestSuite) TestPutItemsWithError() {
@@ -1035,10 +1041,12 @@ func (suite *syncKVTestSuite) TestPutItemsWithError() {
10351041

10361042
suite.verifyItems(items)
10371043

1038-
suite.deleteItems(items)
1044+
suite.deleteItems(putItemsInput.Path, items)
10391045
}
10401046

1041-
func (suite *syncKVTestSuite) populateScatteredItems(path string) (map[string]map[string]interface{}, []string) {
1047+
func (suite *syncKVTestSuite) populateScatteredItems(path string,
1048+
numOfChunks int,
1049+
chunkSize int) (map[string]map[string]interface{}, []string) {
10421050

10431051
scatteredItemKeys := []string{"louise", "karen"}
10441052
items := map[string]map[string]interface{}{
@@ -1070,9 +1078,9 @@ func (suite *syncKVTestSuite) populateScatteredItems(path string) (map[string]ma
10701078
}
10711079

10721080
// because of request size limit we will have to update items in parts
1073-
for i := 0; i < 6; i++ {
1081+
for i := 0; i < numOfChunks; i++ {
10741082
attributes := map[string]interface{}{}
1075-
for j := 0; j < 30; j++ {
1083+
for j := 0; j < chunkSize; j++ {
10761084
attributes[fmt.Sprintf("%s_%s_%d_%d", "blob", key, i, j)] = randomString(60000)
10771085
}
10781086
updateItemInput.Attributes = attributes
@@ -1117,12 +1125,15 @@ func (suite *syncKVTestSuite) verifyItems(items map[string]map[string]interface{
11171125
cursor.Release()
11181126
}
11191127

1120-
func (suite *syncKVTestSuite) deleteItems(items map[string]map[string]interface{}) {
1128+
func (suite *syncKVTestSuite) deleteItems(path string, items map[string]map[string]interface{}) {
1129+
if !strings.HasSuffix(path, "/") {
1130+
path = path + "/"
1131+
}
11211132

11221133
// delete the items
11231134
for itemKey := range items {
11241135
input := v3io.DeleteObjectInput{
1125-
Path: "/emd0/" + itemKey,
1136+
Path: filepath.Join(path, itemKey),
11261137
}
11271138

11281139
// when run against a context, will populate fields like container name
@@ -1134,7 +1145,7 @@ func (suite *syncKVTestSuite) deleteItems(items map[string]map[string]interface{
11341145
}
11351146

11361147
input := &v3io.DeleteObjectInput{
1137-
Path: "/emd0/",
1148+
Path: fmt.Sprintf("%s", path),
11381149
}
11391150

11401151
// when run against a context, will populate fields like container name

0 commit comments

Comments
 (0)