Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
slapos.toolbox
Commits
789d2d56
Commit
789d2d56
authored
Aug 02, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qa: minor code clean-up
parent
049c42b1
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
26 deletions
+20
-26
slapos/test/monitor/test_monitor_collect.py
slapos/test/monitor/test_monitor_collect.py
+3
-3
slapos/test/promise/plugin/__init__.py
slapos/test/promise/plugin/__init__.py
+3
-0
slapos/test/promise/plugin/test_check_error_on_http_log.py
slapos/test/promise/plugin/test_check_error_on_http_log.py
+0
-6
slapos/test/promise/plugin/test_check_error_on_zope_longrequest_log.py
...romise/plugin/test_check_error_on_zope_longrequest_log.py
+0
-2
slapos/test/promise/plugin/test_check_free_disk_space.py
slapos/test/promise/plugin/test_check_free_disk_space.py
+0
-2
slapos/test/promise/test_apache_mpm_watchdog.py
slapos/test/promise/test_apache_mpm_watchdog.py
+2
-3
slapos/test/promise/test_check_apachedex_result.py
slapos/test/promise/test_check_apachedex_result.py
+3
-3
slapos/test/promise/test_check_computer_memory.py
slapos/test/promise/test_check_computer_memory.py
+3
-2
slapos/test/promise/test_check_slow_queries_digest_result.py
slapos/test/promise/test_check_slow_queries_digest_result.py
+3
-3
slapos/test/promise/test_check_user_memory.py
slapos/test/promise/test_check_user_memory.py
+3
-2
No files found.
slapos/test/monitor/test_monitor_collect.py
View file @
789d2d56
...
@@ -30,13 +30,14 @@ import os
...
@@ -30,13 +30,14 @@ import os
import
sqlite3
import
sqlite3
import
time
import
time
from
slapos.test
.promise
import
data
from
.
.promise
import
data
from
slapos.monitor.collect
import
ResourceCollect
from
slapos.monitor.collect
import
ResourceCollect
class
TestMonitorCollect
(
unittest
.
TestCase
):
class
TestMonitorCollect
(
unittest
.
TestCase
):
base_path
,
=
data
.
__path__
def
setUp
(
self
):
def
setUp
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
self
.
status
=
"ok"
self
.
status
=
"ok"
# populate db
# populate db
...
@@ -49,7 +50,6 @@ class TestMonitorCollect(unittest.TestCase):
...
@@ -49,7 +50,6 @@ class TestMonitorCollect(unittest.TestCase):
# inititalise
# inititalise
self
.
collector
=
ResourceCollect
(
'/tmp/'
)
self
.
collector
=
ResourceCollect
(
'/tmp/'
)
def
test_getPartitionUsedMemoryAverage
(
self
):
def
test_getPartitionUsedMemoryAverage
(
self
):
self
.
assertEqual
(
1195.492578125
,
self
.
assertEqual
(
1195.492578125
,
self
.
collector
.
getPartitionUsedMemoryAverage
(
'slapuser15'
,
'2017-09-16'
))
self
.
collector
.
getPartitionUsedMemoryAverage
(
'slapuser15'
,
'2017-09-16'
))
...
...
slapos/test/promise/plugin/__init__.py
View file @
789d2d56
...
@@ -28,12 +28,15 @@ import os, shutil
...
@@ -28,12 +28,15 @@ import os, shutil
import
tempfile
import
tempfile
import
unittest
import
unittest
import
json
import
json
from
..
import
data
from
slapos.grid.promise
import
PromiseLauncher
from
slapos.grid.promise
import
PromiseLauncher
from
slapos.grid.promise.generic
import
(
PROMISE_RESULT_FOLDER_NAME
,
from
slapos.grid.promise.generic
import
(
PROMISE_RESULT_FOLDER_NAME
,
PROMISE_LOG_FOLDER_NAME
)
PROMISE_LOG_FOLDER_NAME
)
class
TestPromisePluginMixin
(
unittest
.
TestCase
):
class
TestPromisePluginMixin
(
unittest
.
TestCase
):
base_path
,
=
data
.
__path__
def
setUp
(
self
):
def
setUp
(
self
):
self
.
partition_dir
=
tempfile
.
mkdtemp
()
self
.
partition_dir
=
tempfile
.
mkdtemp
()
self
.
plugin_dir
=
os
.
path
.
join
(
self
.
partition_dir
,
'plugin'
)
self
.
plugin_dir
=
os
.
path
.
join
(
self
.
partition_dir
,
'plugin'
)
...
...
slapos/test/promise/plugin/test_check_error_on_http_log.py
View file @
789d2d56
...
@@ -28,7 +28,6 @@
...
@@ -28,7 +28,6 @@
from
slapos.test.promise.plugin
import
TestPromisePluginMixin
from
slapos.test.promise.plugin
import
TestPromisePluginMixin
import
os
import
os
import
time
import
time
from
slapos.test.promise
import
data
from
slapos.grid.promise
import
PromiseError
from
slapos.grid.promise
import
PromiseError
class
TestCheckErrorOnHttpLog
(
TestPromisePluginMixin
):
class
TestCheckErrorOnHttpLog
(
TestPromisePluginMixin
):
...
@@ -61,7 +60,6 @@ class TestCheckErrorOnHttpLog(TestPromisePluginMixin):
...
@@ -61,7 +60,6 @@ class TestCheckErrorOnHttpLog(TestPromisePluginMixin):
log_folder
=
os
.
path
.
join
(
self
.
partition_dir
,
'var/log'
)
log_folder
=
os
.
path
.
join
(
self
.
partition_dir
,
'var/log'
)
os
.
makedirs
(
log_folder
)
os
.
makedirs
(
log_folder
)
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
self
.
_update_logs
()
self
.
_update_logs
()
self
.
promise_name
=
"check-error-on-apache-log.py"
self
.
promise_name
=
"check-error-on-apache-log.py"
...
@@ -79,7 +77,6 @@ extra_config_dict = {
...
@@ -79,7 +77,6 @@ extra_config_dict = {
TestPromisePluginMixin
.
tearDown
(
self
)
TestPromisePluginMixin
.
tearDown
(
self
)
def
test_no_error
(
self
):
def
test_no_error
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
content
=
self
.
base_content
%
{
content
=
self
.
base_content
%
{
'log_file'
:
self
.
base_path
+
"/SOFTINST-0_infoonly_error_log"
,
'log_file'
:
self
.
base_path
+
"/SOFTINST-0_infoonly_error_log"
,
'maximum_delay'
:
0
'maximum_delay'
:
0
...
@@ -110,7 +107,6 @@ extra_config_dict = {
...
@@ -110,7 +107,6 @@ extra_config_dict = {
self
.
assertEqual
(
result
[
'result'
][
'message'
],
"OK"
)
self
.
assertEqual
(
result
[
'result'
][
'message'
],
"OK"
)
def
test_error
(
self
):
def
test_error
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
content
=
self
.
base_content
%
{
content
=
self
.
base_content
%
{
'log_file'
:
self
.
base_path
+
"/SOFTINST-0_apache_error_log"
,
'log_file'
:
self
.
base_path
+
"/SOFTINST-0_apache_error_log"
,
'maximum_delay'
:
0
'maximum_delay'
:
0
...
@@ -142,7 +138,6 @@ extra_config_dict = {
...
@@ -142,7 +138,6 @@ extra_config_dict = {
self
.
assertEqual
(
result
[
'result'
][
'message'
],
"ERROR=1 (NOROUTE=1, UNREACHABLENET=0, TIMEOUT=0)"
)
self
.
assertEqual
(
result
[
'result'
][
'message'
],
"ERROR=1 (NOROUTE=1, UNREACHABLENET=0, TIMEOUT=0)"
)
def
test_error_timeout
(
self
):
def
test_error_timeout
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
content
=
self
.
base_content
%
{
content
=
self
.
base_content
%
{
'log_file'
:
self
.
base_path
+
"/SOFTINST-0_timeout_error_log"
,
'log_file'
:
self
.
base_path
+
"/SOFTINST-0_timeout_error_log"
,
'maximum_delay'
:
0
'maximum_delay'
:
0
...
@@ -174,7 +169,6 @@ extra_config_dict = {
...
@@ -174,7 +169,6 @@ extra_config_dict = {
self
.
assertEqual
(
result
[
'result'
][
'message'
],
"ERROR=2 (NOROUTE=0, UNREACHABLENET=0, TIMEOUT=2)"
)
self
.
assertEqual
(
result
[
'result'
][
'message'
],
"ERROR=2 (NOROUTE=0, UNREACHABLENET=0, TIMEOUT=2)"
)
def
test_error_unreacheabler
(
self
):
def
test_error_unreacheabler
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
content
=
self
.
base_content
%
{
content
=
self
.
base_content
%
{
'log_file'
:
self
.
base_path
+
"/SOFTINST-0_unreachable_error_log"
,
'log_file'
:
self
.
base_path
+
"/SOFTINST-0_unreachable_error_log"
,
'maximum_delay'
:
0
'maximum_delay'
:
0
...
...
slapos/test/promise/plugin/test_check_error_on_zope_longrequest_log.py
View file @
789d2d56
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
from
slapos.test.promise.plugin
import
TestPromisePluginMixin
from
slapos.test.promise.plugin
import
TestPromisePluginMixin
import
os
import
os
from
slapos.test.promise
import
data
import
time
import
time
from
slapos.grid.promise
import
PromiseError
from
slapos.grid.promise
import
PromiseError
...
@@ -37,7 +36,6 @@ class TestCheckErrorOnZopeLongrequestLog(TestPromisePluginMixin):
...
@@ -37,7 +36,6 @@ class TestCheckErrorOnZopeLongrequestLog(TestPromisePluginMixin):
def
setUp
(
self
):
def
setUp
(
self
):
TestPromisePluginMixin
.
setUp
(
self
)
TestPromisePluginMixin
.
setUp
(
self
)
self
.
promise_name
=
"check-error-on-zope_longrequest-log.py"
self
.
promise_name
=
"check-error-on-zope_longrequest-log.py"
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
self
.
log_file
=
self
.
base_path
+
"/longrequest_logger_zope.log"
self
.
log_file
=
self
.
base_path
+
"/longrequest_logger_zope.log"
self
.
test_log_file
=
self
.
base_path
+
"/SOFTINST-0_longrequest_logger_zope.log"
self
.
test_log_file
=
self
.
base_path
+
"/SOFTINST-0_longrequest_logger_zope.log"
self
.
_update_logs
()
self
.
_update_logs
()
...
...
slapos/test/promise/plugin/test_check_free_disk_space.py
View file @
789d2d56
...
@@ -29,7 +29,6 @@ from slapos.test.promise.plugin import TestPromisePluginMixin
...
@@ -29,7 +29,6 @@ from slapos.test.promise.plugin import TestPromisePluginMixin
from
slapos.grid.promise
import
PromiseError
from
slapos.grid.promise
import
PromiseError
import
os
import
os
import
sqlite3
import
sqlite3
from
slapos.test.promise
import
data
from
slapos.grid.promise
import
PromiseError
from
slapos.grid.promise
import
PromiseError
class
TestCheckFreeDiskSpace
(
TestPromisePluginMixin
):
class
TestCheckFreeDiskSpace
(
TestPromisePluginMixin
):
...
@@ -40,7 +39,6 @@ class TestCheckFreeDiskSpace(TestPromisePluginMixin):
...
@@ -40,7 +39,6 @@ class TestCheckFreeDiskSpace(TestPromisePluginMixin):
os
.
makedirs
(
log_folder
)
os
.
makedirs
(
log_folder
)
self
.
db_file
=
'/tmp/collector.db'
self
.
db_file
=
'/tmp/collector.db'
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
# populate db
# populate db
self
.
conn
=
sqlite3
.
connect
(
self
.
db_file
)
self
.
conn
=
sqlite3
.
connect
(
self
.
db_file
)
...
...
slapos/test/promise/test_apache_mpm_watchdog.py
View file @
789d2d56
...
@@ -33,12 +33,11 @@ import psutil
...
@@ -33,12 +33,11 @@ import psutil
from
slapos.promise.apache_mpm_watchdog
import
watchServerStatus
,
\
from
slapos.promise.apache_mpm_watchdog
import
watchServerStatus
,
\
loadJSONFile
,
writeJSONFile
,
getServerStatus
,
search_pid_regex
loadJSONFile
,
writeJSONFile
,
getServerStatus
,
search_pid_regex
from
slapos.test.promise
import
data
from
.
import
data
class
TestApacheMPMWatchdog
(
unittest
.
TestCase
):
class
TestApacheMPMWatchdog
(
unittest
.
TestCase
):
def
setUp
(
self
):
base_path
,
=
data
.
__path__
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
def
text_searchPidRegex
(
self
):
def
text_searchPidRegex
(
self
):
...
...
slapos/test/promise/test_check_apachedex_result.py
View file @
789d2d56
...
@@ -32,7 +32,7 @@ import tempfile
...
@@ -32,7 +32,7 @@ import tempfile
import
datetime
import
datetime
import
shutil
import
shutil
from
slapos.test.promise
import
data
from
.
import
data
from
slapos.promise.check_apachedex_result
import
checkApachedexResult
from
slapos.promise.check_apachedex_result
import
checkApachedexResult
apdex_not_found_message
=
"No result found in the apdex file or the file is corrupted"
apdex_not_found_message
=
"No result found in the apdex file or the file is corrupted"
...
@@ -42,6 +42,8 @@ skip_message = "Instance has been just deployed. Skipping check.."
...
@@ -42,6 +42,8 @@ skip_message = "Instance has been just deployed. Skipping check.."
class
TestCheckApacheDigestResult
(
unittest
.
TestCase
):
class
TestCheckApacheDigestResult
(
unittest
.
TestCase
):
base_path
,
=
data
.
__path__
def
_create_file
(
self
,
date
,
with_content
):
def
_create_file
(
self
,
date
,
with_content
):
content
=
''
content
=
''
if
with_content
:
if
with_content
:
...
@@ -59,8 +61,6 @@ class TestCheckApacheDigestResult(unittest.TestCase):
...
@@ -59,8 +61,6 @@ class TestCheckApacheDigestResult(unittest.TestCase):
os
.
remove
(
self
.
base_dir
+
name
)
os
.
remove
(
self
.
base_dir
+
name
)
def
setUp
(
self
):
def
setUp
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
self
.
base_dir
=
"/tmp/ap/"
self
.
base_dir
=
"/tmp/ap/"
if
not
os
.
path
.
exists
(
self
.
base_dir
):
if
not
os
.
path
.
exists
(
self
.
base_dir
):
os
.
makedirs
(
self
.
base_dir
)
os
.
makedirs
(
self
.
base_dir
)
...
...
slapos/test/promise/test_check_computer_memory.py
View file @
789d2d56
...
@@ -29,15 +29,16 @@ import unittest
...
@@ -29,15 +29,16 @@ import unittest
import
os
import
os
import
sqlite3
import
sqlite3
from
slapos.test.promise
import
data
from
.
import
data
from
slapos.promise.check_computer_memory
import
getMemoryInfo
,
checkMemoryUsage
from
slapos.promise.check_computer_memory
import
getMemoryInfo
,
checkMemoryUsage
total_memory_fetch_failure_message
=
"couldn't fetch total memory, collectordb is empty?"
total_memory_fetch_failure_message
=
"couldn't fetch total memory, collectordb is empty?"
class
TestComputerMemory
(
unittest
.
TestCase
):
class
TestComputerMemory
(
unittest
.
TestCase
):
base_path
,
=
data
.
__path__
def
setUp
(
self
):
def
setUp
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
self
.
status
=
"ok"
self
.
status
=
"ok"
self
.
db_file
=
'/tmp/collector.db'
self
.
db_file
=
'/tmp/collector.db'
...
...
slapos/test/promise/test_check_slow_queries_digest_result.py
View file @
789d2d56
...
@@ -32,11 +32,13 @@ import tempfile
...
@@ -32,11 +32,13 @@ import tempfile
import
datetime
import
datetime
import
shutil
import
shutil
from
slapos.test.promise
import
data
from
.
import
data
from
slapos.promise.check_slow_queries_digest_result
import
checkMariadbDigestResult
from
slapos.promise.check_slow_queries_digest_result
import
checkMariadbDigestResult
class
TestCheckSlowQueriesDigestResult
(
unittest
.
TestCase
):
class
TestCheckSlowQueriesDigestResult
(
unittest
.
TestCase
):
base_path
,
=
data
.
__path__
def
_create_file
(
self
,
date
,
with_content
):
def
_create_file
(
self
,
date
,
with_content
):
content
=
''
content
=
''
if
with_content
:
if
with_content
:
...
@@ -54,8 +56,6 @@ class TestCheckSlowQueriesDigestResult(unittest.TestCase):
...
@@ -54,8 +56,6 @@ class TestCheckSlowQueriesDigestResult(unittest.TestCase):
os
.
remove
(
self
.
base_dir
+
name
)
os
.
remove
(
self
.
base_dir
+
name
)
def
setUp
(
self
):
def
setUp
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
self
.
base_dir
=
"/tmp/ap/"
self
.
base_dir
=
"/tmp/ap/"
if
not
os
.
path
.
exists
(
self
.
base_dir
):
if
not
os
.
path
.
exists
(
self
.
base_dir
):
os
.
makedirs
(
self
.
base_dir
)
os
.
makedirs
(
self
.
base_dir
)
...
...
slapos/test/promise/test_check_user_memory.py
View file @
789d2d56
...
@@ -30,15 +30,16 @@ import os
...
@@ -30,15 +30,16 @@ import os
import
sqlite3
import
sqlite3
from
datetime
import
datetime
from
datetime
import
datetime
from
slapos.test.promise
import
data
from
.
import
data
from
slapos.promise.check_user_memory
import
getMemoryInfo
,
checkMemoryUsage
from
slapos.promise.check_user_memory
import
getMemoryInfo
,
checkMemoryUsage
no_result_message
=
"No result found in collector.db."
no_result_message
=
"No result found in collector.db."
class
TestUserMemory
(
unittest
.
TestCase
):
class
TestUserMemory
(
unittest
.
TestCase
):
base_path
,
=
data
.
__path__
def
setUp
(
self
):
def
setUp
(
self
):
self
.
base_path
=
"/"
.
join
(
data
.
__file__
.
split
(
"/"
)[:
-
1
])
self
.
status
=
"ok"
self
.
status
=
"ok"
self
.
db_file
=
'/tmp/collector.db'
self
.
db_file
=
'/tmp/collector.db'
self
.
db_dir
=
os
.
path
.
dirname
(
self
.
db_file
)
self
.
db_dir
=
os
.
path
.
dirname
(
self
.
db_file
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment