Merge branch 'master' into mutual-tls

This commit is contained in:
tgruben 2019-09-25 14:49:56 -05:00 committed by GitHub
commit 876493c67d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -601,7 +601,7 @@ func (s *Server) receiveMessage(m Message) error {
return fmt.Errorf("local index not found: %s", obj.Index)
}
opt := obj.Meta
_, err := idx.createField(obj.Field, *opt)
_, err := idx.createFieldIfNotExists(obj.Field, *opt)
if err != nil {
return err
}

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)