Class: Gitlab::QA::Component::Elasticsearch
- Inherits:
-
Object
- Object
- Gitlab::QA::Component::Elasticsearch
- Includes:
- Scenario::Actable
- Defined in:
- lib/gitlab/qa/component/elasticsearch.rb
Constant Summary collapse
- ELASTIC_IMAGE =
'docker.elastic.co/elasticsearch/elasticsearch'.freeze
Instance Attribute Summary collapse
-
#docker ⇒ Object
readonly
Returns the value of attribute docker.
-
#environment ⇒ Object
Returns the value of attribute environment.
- #name ⇒ Object
-
#network ⇒ Object
Returns the value of attribute network.
Instance Method Summary collapse
-
#initialize ⇒ Elasticsearch
constructor
A new instance of Elasticsearch.
- #instance ⇒ Object
- #prepare ⇒ Object
- #start ⇒ Object
- #teardown ⇒ Object
Methods included from Scenario::Actable
Constructor Details
#initialize ⇒ Elasticsearch
Returns a new instance of Elasticsearch.
13 14 15 16 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 13 def initialize @docker = Docker::Engine.new @environment = {} end |
Instance Attribute Details
#docker ⇒ Object (readonly)
Returns the value of attribute docker.
9 10 11 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 9 def docker @docker end |
#environment ⇒ Object
Returns the value of attribute environment.
10 11 12 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 10 def environment @environment end |
#name ⇒ Object
18 19 20 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 18 def name @name ||= "elastic68" end |
#network ⇒ Object
Returns the value of attribute network.
10 11 12 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 10 def network @network end |
Instance Method Details
#instance ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 22 def instance prepare start yield self ensure teardown end |
#prepare ⇒ Object
30 31 32 33 34 35 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 30 def prepare @docker.pull(ELASTIC_IMAGE, Runtime::Env.elastic_version) return if @docker.network_exists?(network) @docker.network_create(network) end |
#start ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 37 def start @docker.run(ELASTIC_IMAGE, Runtime::Env.elastic_version) do |command| command << "-d" command << "--name #{name}" command << "--net #{network}" command << "--publish 9200:9200" command << "--publish 9300:9300" command.env("discovery.type", "single-node") end end |
#teardown ⇒ Object
49 50 51 52 |
# File 'lib/gitlab/qa/component/elasticsearch.rb', line 49 def teardown @docker.stop(name) @docker.remove(name) end |