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

Use signatures in OpenQA::WebAPI::Controller::Test #6234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
56 changes: 14 additions & 42 deletions lib/OpenQA/WebAPI/Controller/Test.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ sub referer_check ($self) {
return 1;
}

sub list {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, I guess mojolicious finds the template automatically, and all this does page is doing ajax calls...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. So I deleted the empty method as I deemed it as not necessary. Of course the API route still exists. Full CI tests might tell us if that assumption is correction

my ($self) = @_;
}

sub _load_test_preset ($self, $preset_key) {
return undef unless defined $preset_key;
# avoid reading INI file again on subsequent calls
Expand Down Expand Up @@ -182,9 +178,7 @@ sub clone ($self) {
->catch(sub ($error, @) { $self->reply->gru_result($error, 400) });
}

sub get_match_param {
my ($self) = @_;

sub get_match_param ($self) {
my $match;
if (defined($self->param('match'))) {
$match = $self->param('match');
Expand Down Expand Up @@ -275,9 +269,7 @@ sub _render_comment_data_for_ajax ($self, $job_id, $comment_data) {
return \%data;
}

sub list_running_ajax {
my ($self) = @_;

sub list_running_ajax ($self) {
my $running = $self->schema->resultset('Jobs')->complex_query(
state => [OpenQA::Jobs::Constants::EXECUTION_STATES],
match => $self->get_match_param,
Expand Down Expand Up @@ -321,8 +313,7 @@ sub list_running_ajax {
$self->render(json => \%response);
}

sub list_scheduled_ajax {
my ($self) = @_;
sub list_scheduled_ajax ($self) {
my $limits = OpenQA::App->singleton->config->{misc_limits};
my $limit = min($limits->{generic_max_limit}, $self->param('limit') // $limits->{generic_default_limit});

Expand Down Expand Up @@ -374,9 +365,7 @@ sub _stash_job ($self, $args = undef) {
return $job;
}

sub _stash_job_and_module_list {
my ($self, $args) = @_;

sub _stash_job_and_module_list ($self, $args) {
return undef unless my $job = $self->_stash_job($args);
my $test_modules = read_test_modules($job);
$self->stash(modlist => ($test_modules ? $test_modules->{modules} : []));
Expand Down Expand Up @@ -454,9 +443,7 @@ sub downloads ($self) {
$self->render('test/downloads');
}

sub settings {
my ($self) = @_;

sub settings ($self) {
$self->_stash_job({prefetch => 'settings'}) or return $self->reply->not_found;
$self->render('test/settings');
}
Expand All @@ -472,8 +459,7 @@ So this works in the same way as the test module source.

=cut

sub show_filesrc {
my ($self) = @_;
sub show_filesrc ($self) {
my $job = $self->_stash_job or return $self->reply->not_found;
my $jobid = $self->param('testid');
my $dir = $self->stash('dir');
Expand Down Expand Up @@ -519,9 +505,7 @@ sub show_filesrc {
);
}

sub comments {
my ($self) = @_;

sub comments ($self) {
$self->_stash_job({prefetch => 'comments', order_by => 'comments.id'}) or return $self->reply->not_found;
$self->render('test/comments');
}
Expand All @@ -536,8 +520,7 @@ sub _stash_clone_info ($self, $job) {
});
}

sub infopanel {
my ($self) = @_;
sub infopanel ($self) {
my $job = $self->_stash_job or return $self->reply->not_found;
$self->stash({worker => $job->assigned_worker, additional_data => 1});
$self->_stash_clone_info($job);
Expand All @@ -554,8 +537,7 @@ sub _get_current_job ($self, $with_assets = 0) {

sub show ($self) { $self->_show($self->_get_current_job(1)) }

sub _show {
my ($self, $job) = @_;
sub _show ($self, $job) {
return $self->reply->not_found unless $job;

$self->stash(
Expand Down Expand Up @@ -663,9 +645,7 @@ sub job_next_previous_ajax ($self) {
$self->render(json => {data => \@data});
}

sub _calculate_preferred_machines {
my ($jobs) = @_;

sub _calculate_preferred_machines ($jobs) {
my %machines;
for my $job (@$jobs) {
next unless my $machine = $job->MACHINE;
Expand Down Expand Up @@ -830,9 +810,7 @@ sub _fetch_dependencies_by_jobs ($self, $ids) {
}

# appends the specified $distri and $version to $array_to_add_parts_to as string or if $raw as Mojo::ByteStream
sub _add_distri_and_version_to_summary {
my ($array_to_add_parts_to, $distri, $version, $raw) = @_;

sub _add_distri_and_version_to_summary ($array_to_add_parts_to, $distri, $version, $raw) {
for my $part ($distri, $version) {
# handle case when multiple distri/version parameters have been specified
$part = $part->{-in} if (ref $part eq 'HASH');
Expand All @@ -855,8 +833,7 @@ sub _add_distri_and_version_to_summary {
}

# A generic query page showing test results in a configurable matrix
sub overview {
my ($self) = @_;
sub overview ($self) {
my ($search_args, $groups) = $self->compose_job_overview_search_args;
my $config = OpenQA::App->singleton->config;
my $validation = $self->validation;
Expand Down Expand Up @@ -937,9 +914,7 @@ sub latest ($self) {

sub latest_badge ($self) { $self->_badge($self->_get_latest_job) }

sub module_fails {
my ($self) = @_;

sub module_fails ($self) {
return $self->reply->not_found unless defined $self->param('testid') and defined $self->param('moduleid');
my $module = $self->app->schema->resultset('JobModules')->search(
{
Expand Down Expand Up @@ -1022,7 +997,6 @@ sub _add_dependency_to_node ($node, $parent, $dependency_type) {
}

sub _add_job ($dependency_data, $job, $as_child_of, $preferred_depth) {

# add current job; return if already visited
my $job_id = $job->id;
my $visited = $dependency_data->{visited};
Expand Down Expand Up @@ -1076,7 +1050,6 @@ sub _add_job ($dependency_data, $job, $as_child_of, $preferred_depth) {
}

sub dependencies ($self) {

# build dependency graph starting from the current job
my $job = $self->_get_current_job or return $self->reply->not_found;
my (@nodes, @edges, %cluster);
Expand All @@ -1085,8 +1058,7 @@ sub dependencies ($self) {
$self->render(json => {nodes => \@nodes, edges => \@edges, cluster => \%cluster});
}

sub investigate {
my ($self) = @_;
sub investigate ($self) {
return $self->reply->not_found unless my $job = $self->_get_current_job;
my $git_limit = OpenQA::App->singleton->config->{global}->{job_investigate_git_log_limit} // 200;
my $investigation = $job->investigate(git_limit => $git_limit);
Expand Down