Class: Gitlab::QA::Component::Jira

Inherits:
Object
  • Object
show all
Includes:
Scenario::Actable
Defined in:
lib/gitlab/qa/component/jira.rb

Constant Summary collapse

JIRA_IMAGE =
'registry.gitlab.com/gitlab-org/gitlab-qa/jira-gitlab'.freeze
JIRA_IMAGE_TAG =
'8.8-project-and-issue'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Scenario::Actable

#act, included

Constructor Details

#initializeJira

Returns a new instance of Jira.



14
15
16
17
# File 'lib/gitlab/qa/component/jira.rb', line 14

def initialize
  @docker = Docker::Engine.new
  @environment = {}
end

Instance Attribute Details

#dockerObject (readonly)

Returns the value of attribute docker.



10
11
12
# File 'lib/gitlab/qa/component/jira.rb', line 10

def docker
  @docker
end

#environmentObject

Returns the value of attribute environment.



11
12
13
# File 'lib/gitlab/qa/component/jira.rb', line 11

def environment
  @environment
end

#nameObject



19
20
21
# File 'lib/gitlab/qa/component/jira.rb', line 19

def name
  @name ||= "jira"
end

#networkObject

Returns the value of attribute network.



11
12
13
# File 'lib/gitlab/qa/component/jira.rb', line 11

def network
  @network
end

Instance Method Details

#hostnameObject



23
24
25
# File 'lib/gitlab/qa/component/jira.rb', line 23

def hostname
  "#{name}.#{network}"
end

#instanceObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/gitlab/qa/component/jira.rb', line 27

def instance
  raise 'Please provide a block!' unless block_given?

  prepare
  start

  yield self
ensure
  teardown
end

#prepareObject



38
39
40
41
42
43
44
# File 'lib/gitlab/qa/component/jira.rb', line 38

def prepare
  @docker.pull(JIRA_IMAGE, JIRA_IMAGE_TAG)

  return if @docker.network_exists?(network)

  @docker.network_create(network)
end

#restartObject



56
57
58
# File 'lib/gitlab/qa/component/jira.rb', line 56

def restart
  @docker.restart(name)
end

#set_jira_hostnameObject



67
68
69
# File 'lib/gitlab/qa/component/jira.rb', line 67

def set_jira_hostname
  ::Gitlab::QA::Runtime::Env.jira_hostname = hostname
end

#startObject



46
47
48
49
50
51
52
53
54
# File 'lib/gitlab/qa/component/jira.rb', line 46

def start
  docker.run(JIRA_IMAGE, JIRA_IMAGE_TAG) do |command|
    command << '-d '
    command << "--name #{name}"
    command << "--net #{network}"
    command << "--hostname #{hostname}"
    command << "--publish 8080:8080"
  end
end

#teardownObject



60
61
62
63
64
65
# File 'lib/gitlab/qa/component/jira.rb', line 60

def teardown
  raise 'Invalid instance name!' unless name

  @docker.stop(name)
  @docker.remove(name)
end