Class: Gitlab::QA::Component::Chaos

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

Constant Summary collapse

DOCKER_IMAGE =
'ghcr.io/shopify/toxiproxy'
DOCKER_IMAGE_TAG =
'2.5.0'

Constants inherited from Base

Base::CERTIFICATES_PATH

Instance Attribute Summary

Attributes inherited from Base

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

Instance Method Summary collapse

Methods inherited from Base

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

Methods included from Scenario::Actable

#act, included

Constructor Details

#initializeChaos

Returns a new instance of Chaos.



12
13
14
15
# File 'lib/gitlab/qa/component/chaos.rb', line 12

def initialize
  super
  @network = "test"
end

Instance Method Details

#nameObject



17
18
19
# File 'lib/gitlab/qa/component/chaos.rb', line 17

def name
  @name ||= "chaos"
end

#proxiesObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/gitlab/qa/component/chaos.rb', line 39

def proxies
  [
    {
      name: "postgres",
      listen: "[::]:5432",
      upstream: "postgres.test:5432",
      enabled: true
    },
    {
      name: "praefect",
      listen: "[::]:2305",
      upstream: "praefect.test:2305",
      enabled: true
    },
    {
      name: "gitaly1",
      listen: "[::]:8076",
      upstream: "gitaly1.test:8076",
      enabled: true
    },
    {
      name: "gitaly2",
      listen: "[::]:8077",
      upstream: "gitaly2.test:8077",
      enabled: true
    },
    {
      name: "gitaly3",
      listen: "[::]:8078",
      upstream: "gitaly3.test:8078",
      enabled: true
    }
  ]
end

#startObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gitlab/qa/component/chaos.rb', line 21

def start
  prepare
  docker.run(image: image, tag: tag) do |command|
    command << '-d '
    command << "--name #{name}"
    command << "--network #{@network}"
    command << "--publish 8474:8474"
  end

  QA::Support::Shellout.shell <<~CMD
      docker run --network #{@network} --rm curlimages/curl:7.85.0 \
        -i -s \
        -X POST http://#{name}:8474/populate \
        -H 'Content-Type: application/json' \
        -d '#{proxies.to_json}'
  CMD
end