From 940766a6c2268a47c27a79e7eb1f2af217574c21 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Fri, 1 Nov 2019 10:28:03 +0000
Subject: [PATCH] Make the db write tests a bit faster

---
 db/db_test.go | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/db/db_test.go b/db/db_test.go
index ad92837..ee003ca 100644
--- a/db/db_test.go
+++ b/db/db_test.go
@@ -15,7 +15,11 @@ import (
 	ippb "git.autistici.org/ai3/tools/iprep/proto"
 )
 
-const manyEvents = 500000
+const (
+	// How many events to fill up the db, test/bench cases.
+	manyEventsTest  = 100000
+	manyEventsBench = 1000000
+)
 
 func randomIP() string {
 	return fmt.Sprintf("%d.%d.%d.%d", 1+rand.Intn(253), 1+rand.Intn(253), 1+rand.Intn(253), 1+rand.Intn(253))
@@ -68,7 +72,7 @@ func runRWTest(t *testing.T, driver string) {
 	defer db.Close()
 
 	// Write n elements.
-	n := manyEvents
+	n := manyEventsTest
 	events := randomEvents(n)
 	if err := db.AddAggregate(events); err != nil {
 		t.Fatalf("AddEvents: %v", err)
@@ -185,7 +189,7 @@ func runReadBenchmark(b *testing.B, driver string, eventsPerIP int, threadCounts
 	// Write a lot of events just to bulk up the database, but
 	// also write a couple of records for a known IP, that we're
 	// going to read in the benchmark.
-	n := manyEvents
+	n := manyEventsBench
 	db.AddAggregate(randomEvents(n))
 
 	// For a bunch of random IPs, add a known (possibly large)
-- 
GitLab