Commit 67bf499c authored by Stan Hu's avatar Stan Hu

Include Redis in Workhorse-in-test-suite integration

This merge request was originally introduced in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40026 but reverted
in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40245. We fix
the issue it caused by using `Gitlab::Redis::SharedState.url`, which
handles the differences between the GDK and CI `resque.yml`
configuration formats.

We started using Workhorse in feature tests, but no `config.toml` was
 provided. As a result, we missed a startup issue that could have been
caught by testing the config loading.

A small subset of Workhorse functionality also relies on Workhorse and
Rails sharing a Redis database. If we configure it here, we can enhance
the runner API testing in rails to ensure it behaves as expected.

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/209245
parent 664612e1
......@@ -28,6 +28,25 @@ module Gitlab
end
# rubocop:enable Rails/Output
module Workhorse
extend Gitlab::SetupHelper
class << self
def configuration_toml(dir, _)
config = { redis: { URL: redis_url } }
TomlRB.dump(config)
end
def redis_url
Gitlab::Redis::SharedState.url
end
def get_config_path(dir)
File.join(dir, 'config.toml')
end
end
end
module Gitaly
extend Gitlab::SetupHelper
class << self
......
......@@ -247,8 +247,9 @@ module TestEnv
'GitLab Workhorse',
install_dir: workhorse_dir,
version: Gitlab::Workhorse.version,
task: "gitlab:workhorse:install[#{install_workhorse_args}]"
)
task: "gitlab:workhorse:install[#{install_workhorse_args}]") do
Gitlab::SetupHelper::Workhorse.create_configuration(workhorse_dir, nil)
end
end
def workhorse_dir
......@@ -259,6 +260,14 @@ module TestEnv
host = "[#{host}]" if host.include?(':')
listen_addr = [host, port].join(':')
config_path = Gitlab::SetupHelper::Workhorse.get_config_path(workhorse_dir)
# This should be set up in setup_workhorse, but since
# component_needs_update? only checks that versions are consistent,
# we need to ensure the config file exists. This line can be removed
# later after a new Workhorse version is updated.
Gitlab::SetupHelper::Workhorse.create_configuration(workhorse_dir, nil) unless File.exist?(config_path)
workhorse_pid = spawn(
{ 'PATH' => "#{ENV['PATH']}:#{workhorse_dir}" },
File.join(workhorse_dir, 'gitlab-workhorse'),
......@@ -266,10 +275,7 @@ module TestEnv
'-documentRoot', Rails.root.join('public').to_s,
'-listenAddr', listen_addr,
'-secretPath', Gitlab::Workhorse.secret_path.to_s,
# TODO: Needed for workhorse + redis features.
# https://gitlab.com/gitlab-org/gitlab/-/issues/209245
#
# '-config', '',
'-config', config_path,
'-logFile', 'log/workhorse-test.log',
'-logFormat', 'structured',
'-developmentMode' # to serve assets and rich error messages
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment