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
d628b7a0
Commit
d628b7a0
authored
7 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
add space check for local backups too
parent
e2513417
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_backup.py
+6
-4
6 additions, 4 deletions
tests/test_backup.py
with
6 additions
and
4 deletions
tests/test_backup.py
+
6
−
4
View file @
d628b7a0
...
@@ -55,8 +55,10 @@ def test_last_backup_is_recent(server):
...
@@ -55,8 +55,10 @@ def test_last_backup_is_recent(server):
return
False
return
False
def
test_backup_space
(
server
):
def
test_backup_space
(
server
=
None
,
path
=
"
/backup
"
):
cmd
=
'
ssh -o StrictHostKeyChecking=no %s df -h /backup | tail -n 1
'
%
(
server
)
cmd
=
'
df -h %s | tail -n 1
'
%
path
if
server
:
cmd
=
'
ssh -o StrictHostKeyChecking=no %s
'
%
server
+
cmd
status
,
out
=
subprocess
.
getstatusoutput
(
cmd
)
status
,
out
=
subprocess
.
getstatusoutput
(
cmd
)
if
status
==
0
:
if
status
==
0
:
dev
,
total
,
used
,
free
,
used_perc
,
mount
=
out
.
strip
().
split
()
dev
,
total
,
used
,
free
,
used_perc
,
mount
=
out
.
strip
().
split
()
...
@@ -71,7 +73,6 @@ def test_backup_space(server):
...
@@ -71,7 +73,6 @@ def test_backup_space(server):
print
(
'
Failed to check backup space
'
)
print
(
'
Failed to check backup space
'
)
return
False
return
False
def
check_local_backup
(
path
):
def
check_local_backup
(
path
):
all_ok
=
True
all_ok
=
True
backup_folder
=
os
.
path
.
dirname
(
path
)
backup_folder
=
os
.
path
.
dirname
(
path
)
...
@@ -106,6 +107,7 @@ def check_local_backups(paths):
...
@@ -106,6 +107,7 @@ def check_local_backups(paths):
status
,
out
=
subprocess
.
getstatusoutput
(
cmd
)
status
,
out
=
subprocess
.
getstatusoutput
(
cmd
)
for
bf
in
out
.
split
(
'
\n
'
):
for
bf
in
out
.
split
(
'
\n
'
):
all_ok
=
min
(
check_local_backup
(
bf
),
all_ok
)
all_ok
=
min
(
check_local_backup
(
bf
),
all_ok
)
all_ok
=
min
(
test_backup_space
(
path
=
f
),
all_ok
)
return
all_ok
return
all_ok
...
@@ -123,7 +125,7 @@ if os.path.isfile('../utils.py'):
...
@@ -123,7 +125,7 @@ if os.path.isfile('../utils.py'):
if
not
test_last_backup_is_recent
(
BACKUP_SERVER
):
if
not
test_last_backup_is_recent
(
BACKUP_SERVER
):
sys
.
exit
(
1
)
sys
.
exit
(
1
)
else
:
else
:
if
not
test_backup_space
(
BACKUP_SERVER
):
if
not
test_backup_space
(
server
=
BACKUP_SERVER
):
sys
.
exit
(
1
)
sys
.
exit
(
1
)
else
:
else
:
sys
.
exit
(
0
)
sys
.
exit
(
0
)
...
...
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