Class: Gitlab::QA::Component::MockServer

Inherits:
Base
  • Object
show all
Defined in:
lib/gitlab/qa/component/mock_server.rb

Overview

General purpose http mock server see: smocker.dev/

Constant Summary collapse

DOCKER_IMAGE =
"thiht/smocker"
DOCKER_IMAGE_TAG =
"0.18.2"

Constants inherited from Base

Base::CERTIFICATES_PATH

Instance Attribute Summary collapse

Attributes inherited from Base

#additional_hosts, #airgapped_network, #docker, #environment, #logger, #network, #network_aliases, #ports, #runner_network, #secrets, #volumes

Instance Method Summary collapse

Methods inherited from Base

#add_network_alias, #hostname, #image, #instance, #ip_address, #prepare_airgapped_network, #prepare_docker_container, #prepare_docker_image, #prepare_network, #prepare_runner_network, #process_exec_commands, #pull, #restart, #start, #start_instance, #tag, #teardown

Methods included from Scenario::Actable

#act, included

Constructor Details

#initializeMockServer

Returns a new instance of MockServer.



13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/qa/component/mock_server.rb', line 13

def initialize
  super

  @tls = false
  @name = "smocker"
  @tls_path = "/etc/smocker/tls"
  @ports = [80, 8081]
  @environment = { "SMOCKER_MOCK_SERVER_LISTEN_PORT" => 80 }
  @tls_volume = { "smocker-ssl" => @tls_path }
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



24
25
26
# File 'lib/gitlab/qa/component/mock_server.rb', line 24

def name
  @name
end

#tls=(value) ⇒ Object

Sets the attribute tls

Parameters:

  • value

    the value to set the attribute tls to.



25
26
27
# File 'lib/gitlab/qa/component/mock_server.rb', line 25

def tls=(value)
  @tls = value
end

#tls_volumeObject (readonly)

Returns the value of attribute tls_volume.



24
25
26
# File 'lib/gitlab/qa/component/mock_server.rb', line 24

def tls_volume
  @tls_volume
end

Instance Method Details

#prepareObject



27
28
29
30
31
32
# File 'lib/gitlab/qa/component/mock_server.rb', line 27

def prepare
  super

  alpine_service_container.start_instance
  setup_tls if tls
end

#teardown!Object



34
35
36
37
38
39
40
41
# File 'lib/gitlab/qa/component/mock_server.rb', line 34

def teardown!
  # Print smocker log output by using docker logs command because smocker only logs to stdout
  Docker::Command.execute("logs #{name}")
  # Remove alpine service container
  alpine_service_container.teardown!

  super
end