Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-scheduler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-scheduler
Commits
70581b67
Commit
70581b67
authored
6 years ago
by
David Douard
Browse files
Options
Downloads
Patches
Plain Diff
Add a /site-map endpoint that lists published routes for this server
parent
5880c52a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!61
Add a /site-map endpoint that lists published routes for this server
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/scheduler/api/server.py
+19
-0
19 additions, 0 deletions
swh/scheduler/api/server.py
swh/scheduler/tests/test_api_client.py
+17
-0
17 additions, 0 deletions
swh/scheduler/tests/test_api_client.py
with
36 additions
and
0 deletions
swh/scheduler/api/server.py
+
19
−
0
View file @
70581b67
...
...
@@ -33,6 +33,10 @@ def get_sched():
return
scheduler
def
has_no_empty_params
(
rule
):
return
len
(
rule
.
defaults
or
())
>=
len
(
rule
.
arguments
or
())
@app.route
(
'
/
'
)
@negotiate
(
MsgpackFormatter
)
@negotiate
(
JSONFormatter
)
...
...
@@ -159,6 +163,21 @@ def delete_archived_tasks():
return
get_sched
().
delete_archived_tasks
(
**
decode_request
(
request
))
@app.route
(
"
/site-map
"
)
@negotiate
(
MsgpackFormatter
)
@negotiate
(
JSONFormatter
)
def
site_map
():
links
=
[]
sched
=
get_sched
()
for
rule
in
app
.
url_map
.
iter_rules
():
if
has_no_empty_params
(
rule
)
and
hasattr
(
sched
,
rule
.
endpoint
):
links
.
append
(
dict
(
rule
=
rule
.
rule
,
description
=
getattr
(
sched
,
rule
.
endpoint
).
__doc__
))
# links is now a list of url, endpoint tuples
return
links
def
run_from_webserver
(
environ
,
start_response
,
config_path
=
DEFAULT_CONFIG_PATH
):
"""
Run the WSGI app from the webserver, loading the configuration.
"""
...
...
This diff is collapsed.
Click to expand it.
swh/scheduler/tests/test_api_client.py
+
17
−
0
View file @
70581b67
...
...
@@ -4,6 +4,7 @@
# See top-level LICENSE file for more information
import
unittest
import
requests
from
swh.core.tests.server_testing
import
ServerTestFixture
from
swh.scheduler
import
get_scheduler
...
...
@@ -34,3 +35,19 @@ class RemoteSchedulerTest(CommonSchedulerTest, ServerTestFixture,
# accessible through a remote scheduler accessible on the
# given port
self
.
backend
=
get_scheduler
(
'
remote
'
,
{
'
url
'
:
self
.
url
()})
def
test_site_map
(
self
):
sitemap
=
requests
.
get
(
self
.
url
()
+
'
site-map
'
)
assert
sitemap
.
headers
[
'
Content-Type
'
]
==
'
application/json
'
sitemap
=
sitemap
.
json
()
rules
=
set
(
x
[
'
rule
'
]
for
x
in
sitemap
)
# we expect at least these rules
expected_rules
=
set
(
'
/
'
+
rule
for
rule
in
(
'
set_status_tasks
'
,
'
create_task_type
'
,
'
get_task_type
'
,
'
get_task_types
'
,
'
create_tasks
'
,
'
disable_tasks
'
,
'
get_tasks
'
,
'
search_tasks
'
,
'
peek_ready_tasks
'
,
'
grab_ready_tasks
'
,
'
schedule_task_run
'
,
'
mass_schedule_task_runs
'
,
'
start_task_run
'
,
'
end_task_run
'
,
'
filter_task_to_archive
'
,
'
delete_archived_tasks
'
))
assert
rules
.
issuperset
(
expected_rules
),
expected_rules
-
rules
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment