search_shards_test.go 888 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright 2012-present Oliver Eilhard. All rights reserved.
  2. // Use of this source code is governed by a MIT-license.
  3. // See http://olivere.mit-license.org/license.txt for details.
  4. package elastic
  5. import (
  6. "context"
  7. "testing"
  8. )
  9. func TestSearchShards(t *testing.T) {
  10. client := setupTestClientAndCreateIndex(t)
  11. indexes := []string{testIndexName}
  12. shardsInfo, err := client.SearchShards(indexes...).Do(context.TODO())
  13. if err != nil {
  14. t.Fatal(err)
  15. }
  16. if shardsInfo == nil {
  17. t.Fatal("expected to return an shards information")
  18. }
  19. if len(shardsInfo.Shards) < 1 {
  20. t.Fatal("expected to return minimun one shard information")
  21. }
  22. if shardsInfo.Shards[0][0].Index != testIndexName {
  23. t.Fatal("expected to return shard info concerning requested index")
  24. }
  25. if shardsInfo.Shards[0][0].State != "STARTED" {
  26. t.Fatal("expected to return STARTED status for running shards")
  27. }
  28. }