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

Add minimalistic "health" check route #5092

Merged
merged 1 commit into from
Apr 24, 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
1 change: 1 addition & 0 deletions lib/OpenQA/WebAPI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ sub startup ($self) {
# Default route
$r->get('/' => sub ($c) { $c->render('main/index') })->name('index');
$r->get('/changelog')->name('changelog')->to('main#changelog');
$r->get('/health')->name('health')->to('main#health');

# shorter version of route to individual job results
$r->get('/t<testid:num>' => sub ($c) { $c->redirect_to('test') });
Expand Down
5 changes: 5 additions & 0 deletions lib/OpenQA/WebAPI/Controller/Main.pm
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,9 @@ sub changelog ($self) {
$self->render(changelog => $changelog);
}

# Inspired by https://testfully.io/blog/api-health-check-monitoring/
sub health ($self) {
$self->render(text => 'ok');
}

1;
2 changes: 2 additions & 0 deletions t/22-dashboard.t
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ subtest 'Changelog' => sub {
$t->get_ok('/changelog')->status_is(200)->content_like(qr/Custom changelog works/);
};

$t->get_ok('/health')->status_is(200)->content_is('ok', 'health check route just returns plain ok');

$t->get_ok('/dashboard_build_results')->status_is(200);
@h2 = $t->tx->res->dom->find('h2 a')->map('text')->each;
is_deeply(\@h2, ['opensuse', 'opensuse test'], 'empty parent group not shown');
Expand Down