Add the library to the test section in your application's Gemfile:
group :test do
gem 'testcontainers-opensearch'
endAnd then execute:
$ bundle installOr install it yourself as:
$ gem install testcontainers-opensearchrequire "testcontainers/opensearch"
container = Testcontainers::OpensearchContainer.new.start
begin
container.wait_for_healthcheck
client = OpenSearch::Client.new(url: container.opensearch_url)
client.ping # => true
ensure
container.stop if container.running?
container.remove if container.exists?
endThe container exposes ports 9200 (HTTP) and 9600 (metrics) by default and
disables the security plugin so you can connect without credentials. Override
environment variables via with_env before calling start if you need to
change the defaults.
Bug reports and pull requests are welcome on GitHub at https://github.com/testcontainers/testcontainers-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Testcontainers project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.