gitlab-qa 12.3.0 → 12.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/gitlab/qa/component/alpine.rb +2 -1
- data/lib/gitlab/qa/component/base.rb +2 -1
- data/lib/gitlab/qa/component/mock_server.rb +53 -14
- data/lib/gitlab/qa/docker/engine.rb +2 -2
- data/lib/gitlab/qa/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06d3630b5975bd6c560b29280de76f5c6fdfeec2acf65775ca48646c2b413c06
|
4
|
+
data.tar.gz: 21d8d5abef70cf7fdcc47af4700d1c3392739efb2e923c0de71fe2614317e7e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fad44c2bdf42d67c7b71686907cf62990ee96948e0b759615cb79745d57c0c8ec91ab75298992972712dab3139fa464b69c0eb078cc3d22ef4ae2db5e2efb807
|
7
|
+
data.tar.gz: 2117d2c4e221dc908ef562800302c1c821f55a2cb9040f3b82529989579613da4cceeddd280497a73de45860e44ce3e611934b2907b2ded4c8a7a65e6eaa9d30
|
data/Gemfile.lock
CHANGED
@@ -10,7 +10,7 @@ module Gitlab
|
|
10
10
|
# and has to be performed before main component containers are started
|
11
11
|
#
|
12
12
|
class Alpine < Base
|
13
|
-
DOCKER_IMAGE = "alpine"
|
13
|
+
DOCKER_IMAGE = "alpine/curl"
|
14
14
|
DOCKER_IMAGE_TAG = "latest"
|
15
15
|
|
16
16
|
def name
|
@@ -21,6 +21,7 @@ module Gitlab
|
|
21
21
|
docker.run(image: image, tag: tag, args: ["tail", "-f", "/dev/null"]) do |command|
|
22
22
|
command << "-d"
|
23
23
|
command << "--name #{name}"
|
24
|
+
command << "--network #{network}" if network
|
24
25
|
|
25
26
|
volumes.each { |to, from| command.volume(to, from, 'Z') }
|
26
27
|
environment.each { |key, value| command.env(key, value) }
|
@@ -8,7 +8,7 @@ module Gitlab
|
|
8
8
|
|
9
9
|
CERTIFICATES_PATH = File.expand_path('../../../../tls_certificates', __dir__)
|
10
10
|
|
11
|
-
attr_reader :docker
|
11
|
+
attr_reader :docker, :logger
|
12
12
|
attr_writer :name, :exec_commands
|
13
13
|
attr_accessor :volumes,
|
14
14
|
:ports,
|
@@ -21,6 +21,7 @@ module Gitlab
|
|
21
21
|
|
22
22
|
def initialize
|
23
23
|
@docker = Docker::Engine.new
|
24
|
+
@logger = Runtime::Logger.logger
|
24
25
|
@environment = {}
|
25
26
|
@volumes = {}
|
26
27
|
@ports = []
|
@@ -18,23 +18,24 @@ module Gitlab
|
|
18
18
|
@tls_path = "/etc/smocker/tls"
|
19
19
|
@ports = [80, 8081]
|
20
20
|
@environment = { "SMOCKER_MOCK_SERVER_LISTEN_PORT" => 80 }
|
21
|
-
@
|
21
|
+
@tls_volume = { "smocker-ssl" => @tls_path }
|
22
22
|
end
|
23
23
|
|
24
|
-
attr_reader :name
|
24
|
+
attr_reader :name, :tls_volume
|
25
25
|
attr_writer :tls
|
26
26
|
|
27
27
|
def prepare
|
28
28
|
super
|
29
29
|
|
30
|
+
alpine_service_container.start_instance
|
30
31
|
setup_tls if tls
|
31
32
|
end
|
32
33
|
|
33
|
-
# Print smocker log output by using docker logs command because smocker only logs to stdout
|
34
|
-
#
|
35
|
-
# @return [void]
|
36
34
|
def teardown!
|
35
|
+
# Print smocker log output by using docker logs command because smocker only logs to stdout
|
37
36
|
Docker::Command.execute("logs #{name}")
|
37
|
+
# Remove alpine service container
|
38
|
+
alpine_service_container.teardown!
|
38
39
|
|
39
40
|
super
|
40
41
|
end
|
@@ -43,26 +44,64 @@ module Gitlab
|
|
43
44
|
|
44
45
|
attr_reader :tls_path, :tls
|
45
46
|
|
47
|
+
# Run healthcheck validate startup of mock server
|
48
|
+
#
|
49
|
+
# @return [void]
|
50
|
+
def wait_until_ready
|
51
|
+
logger.info("Waiting for mock server to start!")
|
52
|
+
poll_mock_healthcheck(3)
|
53
|
+
logger.info("Mock server container is healthy!")
|
54
|
+
end
|
55
|
+
|
56
|
+
# Poll healthcheck endpoint
|
57
|
+
#
|
58
|
+
# @param [Integer] max_tries
|
59
|
+
# @return [void]
|
60
|
+
def poll_mock_healthcheck(max_tries)
|
61
|
+
url = "#{tls ? 'https' : 'http'}://#{hostname}:8081/version"
|
62
|
+
curl_cmd = "curl --cacert #{tls_path}/smocker.crt -s -f -o /dev/null -w '%{http_code}' #{url}"
|
63
|
+
tries = 0
|
64
|
+
|
65
|
+
loop do
|
66
|
+
# Poll healthcheck endpoint and remove service container if it passes
|
67
|
+
if docker.exec(alpine_service_container.name, curl_cmd, shell: "sh")
|
68
|
+
alpine_service_container.teardown!
|
69
|
+
break
|
70
|
+
end
|
71
|
+
rescue Support::ShellCommand::StatusError => e
|
72
|
+
# re-raise StatusError so that built in startup retry is used in case of failure
|
73
|
+
raise e if tries >= max_tries
|
74
|
+
|
75
|
+
tries += 1
|
76
|
+
sleep 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
46
80
|
# Set up tls certs
|
47
81
|
#
|
48
82
|
# @return [void]
|
49
83
|
def setup_tls
|
50
|
-
@volumes =
|
84
|
+
@volumes = tls_volume
|
51
85
|
@ports = [443, 8081]
|
52
86
|
@environment = {
|
53
87
|
"SMOCKER_MOCK_SERVER_LISTEN_PORT" => 443,
|
54
88
|
"SMOCKER_TLS_ENABLE" => "true",
|
55
|
-
"SMOCKER_TLS_CERT_FILE" => "#{
|
56
|
-
"SMOCKER_TLS_PRIVATE_KEY_FILE" => "#{
|
89
|
+
"SMOCKER_TLS_CERT_FILE" => "#{tls_path}/smocker.crt",
|
90
|
+
"SMOCKER_TLS_PRIVATE_KEY_FILE" => "#{tls_path}/smocker.key"
|
57
91
|
}
|
58
92
|
|
59
|
-
|
60
|
-
|
93
|
+
docker.copy(alpine_service_container.name, "#{CERTIFICATES_PATH}/smocker/.", tls_path)
|
94
|
+
end
|
61
95
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
96
|
+
# Helper container to run tls cert copy and curl healthcheck command
|
97
|
+
# Separate container is required because tls certs have to be copied before smocker startup and smocker
|
98
|
+
# container itself doesn't ship with curl to perform healthcheck requests
|
99
|
+
#
|
100
|
+
# @return [Component::Alpine]
|
101
|
+
def alpine_service_container
|
102
|
+
@alpine_service_container ||= Alpine.new.tap do |alpine|
|
103
|
+
alpine.volumes = tls_volume
|
104
|
+
alpine.network = network
|
66
105
|
end
|
67
106
|
end
|
68
107
|
end
|
@@ -81,10 +81,10 @@ module Gitlab
|
|
81
81
|
), mask_secrets: mask_secrets)
|
82
82
|
end
|
83
83
|
|
84
|
-
def exec(name, command, mask_secrets: nil)
|
84
|
+
def exec(name, command, mask_secrets: nil, shell: "bash")
|
85
85
|
cmd = ['exec']
|
86
86
|
cmd << '--privileged' if privileged_command?(command)
|
87
|
-
Docker::Command.execute(%(#{cmd.join(' ')} #{name}
|
87
|
+
Docker::Command.execute(%(#{cmd.join(' ')} #{name} #{shell} -c "#{command.gsub('"', '\\"')}"),
|
88
88
|
mask_secrets: mask_secrets)
|
89
89
|
end
|
90
90
|
|
data/lib/gitlab/qa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-qa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.
|
4
|
+
version: 12.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab Quality
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|