Skip to content

Instantly share code, notes, and snippets.

@xuncheng
Last active January 23, 2017 06:15
Show Gist options
  • Save xuncheng/34168408a1b059f917b5bd1cf4672e43 to your computer and use it in GitHub Desktop.
Save xuncheng/34168408a1b059f917b5bd1cf4672e43 to your computer and use it in GitHub Desktop.
fix `Elasticsearch::Transport::Transport::Errors::ServiceUnavailable: [503]`
# fixed: Elasticsearch::Transport::Transport::Errors::ServiceUnavailable: [503]
# https://hugotunius.se/2015/06/22/elasticsearch-falkiness-in-tests.html
# https://medium.com/@thetron/dealing-with-503-errors-when-testing-elasticsearch-integration-in-rails-ec7a5f828274#.ex6quza03
# https://github.com/elastic/elasticsearch-ruby/issues/181#issuecomment-112781924
# spec/support/elasticsearch_cleaner.rb
RSpec.configure do |config|
config.before(:each, :es => true) do
ElasticsearchModel.create_index!(:force => true)
ElasticsearchModel.client.cluster.health(wait_for_status: 'yellow')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment