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
c06c6122
Commit
c06c6122
authored
6 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Fixed RAID test (refs
#25198
).
parent
701fd2e8
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_raid.py
+18
-8
18 additions, 8 deletions
tests/test_raid.py
with
18 additions
and
8 deletions
tests/test_raid.py
+
18
−
8
View file @
c06c6122
...
...
@@ -14,33 +14,43 @@ GREEN = '\033[92m'
RED
=
'
\033
[91m
'
DEF
=
'
\033
[0m
'
def
print_red
(
string
):
print
(
RED
+
string
+
DEF
)
def
print_green
(
string
):
print
(
GREEN
+
string
+
DEF
)
def
check_raid
(
dev
):
cmd
=
'
mdadm -D %s
'
%
dev
status
,
output
=
subprocess
.
getstatusoutput
(
cmd
)
ok
=
status
==
0
print
(
'
%s status: %s
'
%
(
dev
,
ok
))
return
ok
if
status
!=
0
:
print_red
(
'
The mdadm command on %s failed:
'
%
dev
)
elif
'
degraded
'
in
output
:
print_red
(
'
The %s RAID partition is degraded:
'
%
dev
)
else
:
print_green
(
'
The %s RAID partition is ok.
'
%
dev
)
return
True
print
(
cmd
)
print
(
output
)
return
False
if
os
.
path
.
isfile
(
'
/proc/mdstat
'
):
all_ok
=
True
for
r
in
glob
.
glob
(
'
/dev/md*
'
):
# ignore /dev/md folder
if
os
.
path
.
isfile
(
r
):
if
os
.
path
.
exists
(
r
)
and
not
os
.
path
.
isdir
(
r
):
all_ok
=
min
(
check_raid
(
r
),
all_ok
)
if
all_ok
:
print_green
(
'
Everything fine
'
)
else
:
print_red
(
'
Some array is in bad shape
'
)
with
open
(
'
/proc/mdstat
'
,
'
r
'
)
as
f
:
d
=
f
.
read
()
print
(
d
)
sys
.
exit
(
not
all_ok
)
with
open
(
'
/proc/mdstat
'
,
'
r
'
)
as
fo
:
print
(
fo
.
read
())
sys
.
exit
(
int
(
not
all_ok
))
else
:
print
(
'
No software RAID array found, untestable
'
)
sys
.
exit
(
2
)
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