Skip to content

Commit

Permalink
Merge pull request #1116 from nats-io/fix_file_slice_max_bytes_cmd_line
Browse files Browse the repository at this point in the history
[FIXED] Command line `-file_slice_max_bytes 0` was not working
  • Loading branch information
kozlovic authored Oct 27, 2020
2 parents 7ce6644 + 85334be commit 4245418
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp,
var i64 int64
i64, flagErr = getBytes(f)
sopts.FileStoreOpts.ReadBufferSize = int(i64)
case "file_slice_max_bytes":
sopts.FileStoreOpts.SliceMaxBytes, flagErr = getBytes(f)
}
})
if flagErr != nil {
Expand Down
18 changes: 18 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1607,3 +1607,21 @@ SUAKYRHVIOREXV7EUZTBHUHL7NUMHPMAS7QMDU3GTIUWEI5LDNOXD43IZY
t.Fatal("Expected failure to start")
}
}

func TestFileSliceMaxBytesCmdLine(t *testing.T) {
fs := flag.NewFlagSet("test", flag.ContinueOnError)
noPrint := func() {}
sopts, nopts, err := ConfigureOptions(fs, []string{"-store", "file", "-dir", defaultDataStore, "-file_slice_max_bytes", "0"}, noPrint, noPrint, noPrint)
if err != nil {
t.Fatalf("Error on configure: %v", err)
}
s := runServerWithOpts(t, sopts, nopts)
defer s.Shutdown()

s.mu.Lock()
smb := s.opts.FileStoreOpts.SliceMaxBytes
s.mu.Unlock()
if smb != 0 {
t.Fatalf("Expected value to be 0, got %v", smb)
}
}

0 comments on commit 4245418

Please sign in to comment.