Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
mediaserver
envsetup
Commits
cb649ea8
Commit
cb649ea8
authored
8 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Added skyreach API test (refs
#19905
).
parent
2d2c6241
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_skyreach.py
+53
-0
53 additions, 0 deletions
tests/test_skyreach.py
with
53 additions
and
0 deletions
tests/test_skyreach.py
0 → 100755
+
53
−
0
View file @
cb649ea8
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
Check that the skyreach server is reachable.
'''
import
os
import
re
import
requests
import
sys
# SkyReach APT file test
apt_source
=
'
/etc/apt/sources.list.d/skyreach.list
'
if
not
os
.
path
.
exists
(
apt_source
):
print
(
'
The file
"
%s
"
does not exists.
'
%
apt_source
)
sys
.
exit
(
1
)
with
open
(
apt_source
,
'
r
'
)
as
fo
:
content
=
fo
.
read
()
# content hould be something like:
# # skyreach repo
# deb https://panel.ubicast.eu packaging/apt/s0000000000000000000000000000000/
expected
=
r
'
^deb (http[s]{0,1}://[A-Za-z0-9\.\-\_]+) packaging/apt/([A-Za-z0-9]+)/$
'
url
=
None
api_key
=
None
if
content
:
for
line
in
content
.
split
(
'
\n
'
):
m
=
re
.
match
(
expected
,
line
)
if
m
:
url
,
api_key
=
m
.
groups
()
if
not
url
or
not
api_key
:
print
(
'
The file
"
%s
"
is not correct: skyreach url not found.
'
%
apt_source
)
sys
.
exit
(
1
)
print
(
'
SkyReach url is %s and API key is %s.
'
%
(
url
,
api_key
))
# Test SkyReach responses
req
=
requests
.
get
(
url
)
if
not
req
.
ok
:
print
(
'
Request to %s failed (%s):
'
%
(
url
,
req
.
status_code
))
print
(
req
.
text
)
else
:
print
(
'
Request to %s: OK.
'
%
url
)
apt_url
=
'
%s/packaging/apt/%s/Packages
'
%
(
url
,
api_key
)
req
=
requests
.
get
(
apt_url
)
if
not
req
.
ok
:
print
(
'
Request to %s failed (%s):
'
%
(
apt_url
,
req
.
status_code
))
print
(
req
.
text
)
else
:
print
(
'
Request to %s: OK.
'
%
apt_url
)
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