1
0
Fork 0

Merge pull request #786 from rqlite/concurrent-compress

Ensure concurrent compression is OK
master
Philip O'Toole 3 years ago committed by GitHub
commit e0638c88c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,7 @@
package command package command
import ( import (
"sync"
"testing" "testing"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
@ -212,6 +213,40 @@ func Test_MarshalWontCompressBatch(t *testing.T) {
} }
} }
func Test_MarshalCompressedConcurrent(t *testing.T) {
rm := NewRequestMarshaler()
rm.SizeThreshold = 1
rm.ForceCompression = true
r := &QueryRequest{
Request: &Request{
Statements: []*Statement{
{
Sql: `INSERT INTO "names" VALUES(1,'bob','123-45-678')`,
},
},
},
Timings: true,
Freshness: 100,
}
var wg sync.WaitGroup
for i := 0; i < 100; i++ {
wg.Add(1)
go func() {
defer wg.Done()
_, comp, err := rm.Marshal(r)
if err != nil {
t.Fatalf("failed to marshal QueryRequest: %s", err)
}
if !comp {
t.Fatal("Marshaled QueryRequest wasn't compressed")
}
}()
}
wg.Wait()
}
func Test_MarshalWontCompressSize(t *testing.T) { func Test_MarshalWontCompressSize(t *testing.T) {
rm := NewRequestMarshaler() rm := NewRequestMarshaler()
rm.SizeThreshold = 1 rm.SizeThreshold = 1

Loading…
Cancel
Save