Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show FQDN in VNC command if available via WORKER_HOSTNAME #5379

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/OpenQA/Schema/Result/Workers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,10 @@ sub reschedule_assigned_jobs {
}
}

sub vnc_argument ($self) {
my $hostname = $self->get_property('WORKER_HOSTNAME') // $self->host;
my $instance = $self->instance + 5990;
return "$hostname:$instance";
}

1;
2 changes: 1 addition & 1 deletion lib/OpenQA/WebAPI/Controller/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ sub live ($self) {
my $job = $self->_stash_job or return $self->reply->not_found;
my $current_user = $self->current_user;
my $worker = $job->worker;
my $worker_vnc = ($worker ? $worker->host . ':' . (5990 + $worker->instance) : undef);
my $worker_vnc = $worker ? $worker->vnc_argument : undef;
$self->stash(
{
ws_developer_url => determine_web_ui_web_socket_url($job->id),
Expand Down
8 changes: 8 additions & 0 deletions t/38-workers-table.t
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,12 @@ subtest 'tmpdir handling when assigning multiple jobs to a worker' => sub {
ok !-d $tmpdir, 'previous tmpdir removed';
path($worker->get_property('WORKER_TMPDIR'))->remove_tree;
};

subtest 'VNC argument' => sub {
my $worker = $workers->first;
is $worker->vnc_argument, 'remotehost:5991', 'host:instance returned';
$worker->set_property(WORKER_HOSTNAME => 'remotehost.foo.bar');
is $worker->vnc_argument, 'remotehost.foo.bar:5991', 'WORKER_HOSTNAME used if set';
};

done_testing();
Loading