Skip to content

Commit

Permalink
worker: Use WORKER_HOSTNAME instead of real hostname
Browse files Browse the repository at this point in the history
Otherwise the "setup info" output is potentially misleading.
  • Loading branch information
kalikiana committed Oct 30, 2020
1 parent 57a95a4 commit 1786e30
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/OpenQA/Worker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ sub new {
app => $app,
settings => $settings,
clients_by_webui_host => undef,
worker_hostname => $hostname,
worker_hostname => ($settings->global_settings->{WORKER_HOSTNAME} // $hostname),
isotovideo_interface_version => $isotovideo_interface_version,
);
$self->{_cli_options} = $cli_options;
Expand Down
13 changes: 6 additions & 7 deletions lib/OpenQA/Worker/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,14 @@ sub _upload_results {
sub _upload_results_step_0_prepare {
my ($self, $callback) = @_;

my $worker_id = $self->client->worker_id;
my $job_url = $self->isotovideo_client->url;
my $global_settings = $self->worker->settings->global_settings;
my $pooldir = $self->worker->pool_directory;
my $status_file = "$pooldir/" . AUTOINST_STATUSFILE;
my %status = (
my $worker_id = $self->client->worker_id;
my $job_url = $self->isotovideo_client->url;
my $pooldir = $self->worker->pool_directory;
my $status_file = "$pooldir/" . AUTOINST_STATUSFILE;
my %status = (
worker_id => $worker_id,
cmd_srv_url => $job_url,
worker_hostname => $global_settings->{WORKER_HOSTNAME},
worker_hostname => $self->worker->worker_hostname,
test_execution_paused => 0,
);

Expand Down
1 change: 1 addition & 0 deletions t/24-worker-jobs.t
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ sub wait_until_uploading_logs_and_assets_concluded {
has instance_number => 1;
has settings => sub { OpenQA::Worker::Settings->new(1, {}) };
has pool_directory => undef;
has worker_hostname => undef;
}
{
package Test::FakeClient;
Expand Down
10 changes: 7 additions & 3 deletions t/24-worker-overall.t
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ my @webui_hosts = sort keys %{$worker->clients_by_webui_host};
is_deeply(\@webui_hosts, [qw(http://localhost:9527 https://remotehost)], 'client for each web UI host')
or diag explain \@webui_hosts;


combined_like { $worker->log_setup_info }
qr/.*http:\/\/localhost:9527,https:\/\/remotehost.*qemu_i386,qemu_x86_64.*/s, 'setup info';
combined_like { $worker->log_setup_info } qr/
worker\ hostname:.+myworker
.*
web\ UI\ hosts:.+http:\/\/localhost:9527,https:\/\/remotehost
.*
class:.+qemu_i386,qemu_x86_64
/sx, 'setup info';

push(@{$worker->settings->parse_errors}, 'foo', 'bar');
combined_like { $worker->log_setup_info }
Expand Down
2 changes: 1 addition & 1 deletion t/data/24-worker-overall/workers.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[global]
HOST = http://localhost:9527 https://remotehost
WORKER_HOSTNAME = 127.0.0.1
WORKER_HOSTNAME = myworker
LOG_LEVEL = debug

[1]
Expand Down

0 comments on commit 1786e30

Please sign in to comment.