Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
itminedu
snf-ganeti
Commits
23269c5b
Commit
23269c5b
authored
17 years ago
by
Michael Hanselmann
Browse files
Options
Downloads
Patches
Plain Diff
Colours and warnings.
- Implement colours in qa_utils. - Print warning for cron script. Reviewed-by: iustinp
parent
01ca31ae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
qa/ganeti-qa.py
+12
-4
12 additions, 4 deletions
qa/ganeti-qa.py
qa/qa_daemon.py
+9
-0
9 additions, 0 deletions
qa/qa_daemon.py
qa/qa_utils.py
+60
-0
60 additions, 0 deletions
qa/qa_utils.py
with
81 additions
and
4 deletions
qa/ganeti-qa.py
+
12
−
4
View file @
23269c5b
...
...
@@ -136,11 +136,19 @@ def main():
if
qa_config
.
TestEnabled
(
'
instance-info
'
):
RunTest
(
qa_instance
.
TestInstanceInfo
,
instance
)
if
qa_config
.
TestEnabled
(
'
instance-automatic-restart
'
):
RunTest
(
qa_daemon
.
TestInstanceAutomaticRestart
,
node
,
instance
)
automatic_restart
=
\
qa_config
.
TestEnabled
(
'
instance-automatic-restart
'
)
consecutive_failures
=
\
qa_config
.
TestEnabled
(
'
instance-consecutive-failures
'
)
if
qa_config
.
TestEnabled
(
'
instance-consecutive-failures
'
):
RunTest
(
qa_daemon
.
TestInstanceConsecutiveFailures
,
node
,
instance
)
if
automatic_restart
or
consecutive_failures
:
qa_daemon
.
PrintCronWarning
()
if
automatic_restart
:
RunTest
(
qa_daemon
.
TestInstanceAutomaticRestart
,
node
,
instance
)
if
consecutive_failures
:
RunTest
(
qa_daemon
.
TestInstanceConsecutiveFailures
,
node
,
instance
)
if
qa_config
.
TestEnabled
(
'
instance-export
'
):
expnode
=
qa_config
.
AcquireNode
(
exclude
=
node
)
...
...
This diff is collapsed.
Click to expand it.
qa/qa_daemon.py
+
9
−
0
View file @
23269c5b
...
...
@@ -78,6 +78,15 @@ def _ResetWatcherDaemon(node):
utils
.
ShellQuoteArgs
(
cmd
)).
wait
(),
0
)
def
PrintCronWarning
():
"""
Shows a warning about the required cron job.
"""
print
qa_utils
.
PrintWarning
(
"
The following tests require the cron script for
"
"
ganeti-watcher to be set up.
"
)
def
TestInstanceAutomaticRestart
(
node
,
instance
):
"""
Test automatic restart of instance by ganeti-watcher.
...
...
This diff is collapsed.
Click to expand it.
qa/qa_utils.py
+
60
−
0
View file @
23269c5b
...
...
@@ -21,6 +21,7 @@
"""
import
os
import
sys
import
subprocess
from
ganeti
import
utils
...
...
@@ -29,6 +30,37 @@ import qa_config
import
qa_error
_INFO_SEQ
=
None
_WARNING_SEQ
=
None
_ERROR_SEQ
=
None
_RESET_SEQ
=
None
def
_SetupColours
():
"""
Initializes the colour constants.
"""
global
_INFO_SEQ
,
_WARNING_SEQ
,
_ERROR_SEQ
,
_RESET_SEQ
try
:
import
curses
except
ImportError
:
# Don't use colours if curses module can't be imported
return
curses
.
setupterm
()
_RESET_SEQ
=
curses
.
tigetstr
(
"
op
"
)
setaf
=
curses
.
tigetstr
(
"
setaf
"
)
_INFO_SEQ
=
curses
.
tparm
(
setaf
,
curses
.
COLOR_GREEN
)
_WARNING_SEQ
=
curses
.
tparm
(
setaf
,
curses
.
COLOR_YELLOW
)
_ERROR_SEQ
=
curses
.
tparm
(
setaf
,
curses
.
COLOR_RED
)
_SetupColours
()
def
AssertEqual
(
first
,
second
,
msg
=
None
):
"""
Raises an error when values aren
'
t equal.
...
...
@@ -113,3 +145,31 @@ def ResolveInstanceName(instance):
AssertEqual
(
p
.
wait
(),
0
)
return
p
.
stdout
.
read
().
strip
()
def
_PrintWithColor
(
text
,
seq
):
f
=
sys
.
stdout
if
not
f
.
isatty
():
seq
=
None
if
seq
:
f
.
write
(
seq
)
f
.
write
(
text
)
f
.
write
(
"
\n
"
)
if
seq
:
f
.
write
(
_RESET_SEQ
)
def
PrintWarning
(
text
):
return
_PrintWithColor
(
text
,
_WARNING_SEQ
)
def
PrintError
(
f
,
text
):
return
_PrintWithColor
(
text
,
_ERROR_SEQ
)
def
PrintInfo
(
f
,
text
):
return
_PrintWithColor
(
text
,
_INFO_SEQ
)
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