add concurrent field creation test

This commit is contained in:
Matt Jaffee 2019-09-23 07:51:04 -05:00
parent a24482e44d
commit ac8c4ed5fe
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF

View file

@ -318,6 +318,30 @@ func TestConfig_Parse_DataDir(t *testing.T) {
}
}
func TestConcurrentFieldCreation(t *testing.T) {
cluster := test.MustRunCluster(t, 3)
defer cluster.Close()
api0 := cluster[0].API
if _, err := api0.CreateIndex(context.Background(), "i", pilosa.IndexOptions{}); err != nil {
t.Fatalf("creating index: %v", err)
}
eg := errgroup.Group{}
for i := 0; i < 100; i++ {
i := i
eg.Go(func() error {
if _, err := api0.CreateField(context.Background(), "i", fmt.Sprintf("f%d", i)); err != nil {
return err
}
return nil
})
}
err := eg.Wait()
if err != nil {
t.Fatalf("creating concurrent field: %v", err)
}
}
func TestMain_RecalculateHashes(t *testing.T) {
const clusterSize = 5
cluster := test.MustRunCluster(t, clusterSize)