Skip to content

Commit 700a65f

Browse files
Fixed no limit being passed (either requests or duration) (#103)
* further logging on timeout error. * printing version * reverted hdrhistogram version change * setting continue on error default to true * Reducing default timeout to 60secs (from 600secs) * migrate CI to GitHub Actions, add integration test, support duration-based runs and input rewind * Ensuring integration tests cover stable branches * Added testdata/minimal.csv * refactor release targets, update hdrhistogram version, cleanup go.mod deps * refactor release targets, update hdrhistogram version, cleanup go.mod deps * Fixed no limit being passed (either requests or duration) --------- Co-authored-by: filipecosta90 <filipecosta.90@gmail.com>
1 parent 67f7559 commit 700a65f

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

benchmark_runner/redisearch_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,54 @@ func TestFTSBWithRequests(t *testing.T) {
100100
t.Errorf("Expected Limit to be 50000, got %v", parsed["Limit"])
101101
}
102102
}
103+
104+
func TestFTSBWithNoLimitNoDuration(t *testing.T) {
105+
t.Log("Starting Redis container...")
106+
dockerRun := exec.Command("docker", "run", "--rm", "-d", "-p", "6379:6379", "redis:8.0-M04-bookworm")
107+
containerIDRaw, err := dockerRun.Output()
108+
if err != nil {
109+
t.Fatalf("Failed to start Redis container: %v", err)
110+
}
111+
containerID := strings.TrimSpace(string(containerIDRaw))
112+
t.Cleanup(func() {
113+
t.Log("Stopping Redis container...")
114+
exec.Command("docker", "stop", containerID).Run()
115+
})
116+
117+
t.Log("Waiting for Redis to be ready...")
118+
time.Sleep(2 * time.Second)
119+
120+
t.Log("Running ftsb_redisearch with no --requests or --duration")
121+
jsonPath := "../testdata/results.nolimit.json"
122+
cmd := exec.Command("../bin/ftsb_redisearch",
123+
"--input", "../testdata/minimal.csv",
124+
"--json-out-file", jsonPath,
125+
)
126+
cmd.Env = append(os.Environ(), "REDIS_URL=redis://localhost:6379")
127+
output, err := cmd.CombinedOutput()
128+
if err != nil {
129+
t.Fatalf("Benchmark failed: %v\nOutput: %s", err, string(output))
130+
}
131+
132+
data, err := os.ReadFile(jsonPath)
133+
if err != nil {
134+
t.Fatalf("Failed to read json output file: %v", err)
135+
}
136+
137+
var parsed struct {
138+
Limit int `json:"Limit"`
139+
Totals struct {
140+
TotalOps int `json:"TotalOps"`
141+
} `json:"Totals"`
142+
}
143+
if err := json.Unmarshal(data, &parsed); err != nil {
144+
t.Fatalf("Failed to parse JSON output: %v", err)
145+
}
146+
147+
if parsed.Limit != 0 {
148+
t.Errorf("Expected Limit to be 0, got %v", parsed.Limit)
149+
}
150+
if parsed.Totals.TotalOps <= 0 {
151+
t.Errorf("Expected Totals.TotalOps to be > 0, got %v", parsed.Totals.TotalOps)
152+
}
153+
}

benchmark_runner/scan.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ SCAN_LOOP:
259259

260260
item := decoder.Decode(br)
261261
if item == nil {
262+
// If no limit or duration is set, do not rewind, just exit
263+
if limit == 0 && duration == 0 {
264+
break SCAN_LOOP
265+
}
262266
// Attempt to rewind input
263267
newBr, newDecoder := resetReader()
264268
if newBr == nil || newDecoder == nil {

0 commit comments

Comments
 (0)