Skip to content

Commit

Permalink
Merge pull request #80 from nspcc-dev/74-zero-size
Browse files Browse the repository at this point in the history
Add zero size objects support
  • Loading branch information
roman-khimov authored Mar 11, 2024
2 parents 8cf78b6 + 13e921d commit bbcedff
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions internal/datagen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type (
const TailSize = 1024

func NewGenerator(vu modules.VU, size int) Generator {
if size <= 0 {
panic("size should be positive")
if size < 0 {
panic("size should not be negative")
}
return Generator{vu: vu, size: size, buf: nil, offset: 0}
}
Expand Down
9 changes: 5 additions & 4 deletions internal/datagen/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ func TestGenerator(t *testing.T) {
})
})

t.Run("fails on zero size", func(t *testing.T) {
require.Panics(t, func() {
_ = NewGenerator(vu, 0)
})
t.Run("creates slice of zero size", func(t *testing.T) {
size := 0
g := NewGenerator(vu, size)
slice := g.nextSlice()
require.Len(t, slice, size)
})

t.Run("creates slice of specified size", func(t *testing.T) {
Expand Down
23 changes: 11 additions & 12 deletions scenarios/preset/helpers/neofs_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ def create_container(endpoint, policy, wallet_file, wallet_config):
print(f" > Container has not been created:\n{output}")
return False
else:
try:
fst_str = output.split('\n')[0]
except Exception:
print(f"Got empty output: {output}")
return False
splitted = fst_str.split(": ")
if len(splitted) != 2:
raise ValueError(f"no CID was parsed from command output: \t{fst_str}")

print(f"Created container: {splitted[1]}")

return splitted[1]
# Regular expression to find the container ID, case-insensitive
pattern = r"container ID: ([A-Za-z0-9]{43,44})"

# Search for the pattern in the output text with case-insensitive flag
match = re.search(pattern, output, re.IGNORECASE)
if match:
container_id = match.group(1)
print(f"Created container: {container_id}")
return container_id
else:
raise ValueError(f"no CID was parsed from command output: \t{output}")


def upload_object(container, payload_filepath, endpoint, wallet_file, wallet_config):
Expand Down

0 comments on commit bbcedff

Please sign in to comment.