diff options
Diffstat (limited to 'qa/qa/service/docker_run/smocker.rb')
-rw-r--r-- | qa/qa/service/docker_run/smocker.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/qa/qa/service/docker_run/smocker.rb b/qa/qa/service/docker_run/smocker.rb new file mode 100644 index 00000000000..83ab58887da --- /dev/null +++ b/qa/qa/service/docker_run/smocker.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +module QA + module Service + module DockerRun + class Smocker < Base + def initialize + @image = 'thiht/smocker:0.17.1' + @name = 'smocker-server' + @public_port = '8080' + @admin_port = '8081' + super + @network_cache = network + end + + def host_name + return '127.0.0.1' unless QA::Runtime::Env.running_in_ci? || QA::Runtime::Env.qa_hostname + + "#{@name}.#{@network_cache}" + end + + def base_url + "http://#{host_name}:#{@public_port}" + end + + def admin_url + "http://#{host_name}:#{@admin_port}" + end + + def wait_for_running + Support::Waiter.wait_until(raise_on_failure: false, reload_page: false) do + running? + end + end + + def register! + command = <<~CMD.tr("\n", ' ') + docker run -d --rm + --network #{@network_cache} + --hostname #{host_name} + --name #{@name} + --publish #{@public_port}:8080 + --publish #{@admin_port}:8081 + #{@image} + CMD + + unless QA::Runtime::Env.running_in_ci? || QA::Runtime::Env.qa_hostname + command.gsub!("--network #{@network_cache} ", '') + end + + shell command + end + end + end + end +end |