Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
Kirill Smelkov
ZODB
Commits
3b6c3dcb
Commit
3b6c3dcb
authored
Jan 15, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend the monitor test suite to actually parse the monitor output.
parent
13c1b2d3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
3 deletions
+67
-3
src/ZEO/monitor.py
src/ZEO/monitor.py
+30
-1
src/ZEO/tests/testMonitor.py
src/ZEO/tests/testMonitor.py
+37
-2
No files found.
src/ZEO/monitor.py
View file @
3b6c3dcb
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
##############################################################################
##############################################################################
"""Monitor behavior of ZEO server and record statistics.
"""Monitor behavior of ZEO server and record statistics.
$Id: monitor.py,v 1.
2 2003/01/09 23:55:57
jeremy Exp $
$Id: monitor.py,v 1.
3 2003/01/15 21:23:16
jeremy Exp $
"""
"""
import
asyncore
import
asyncore
...
@@ -40,6 +40,35 @@ class StorageStats:
...
@@ -40,6 +40,35 @@ class StorageStats:
self
.
conflicts_resolved
=
0
self
.
conflicts_resolved
=
0
self
.
start
=
time
.
ctime
()
self
.
start
=
time
.
ctime
()
def
parse
(
self
,
s
):
# parse the dump format
lines
=
s
.
split
(
"
\
n
"
)
for
line
in
lines
:
field
,
value
=
line
.
split
(
":"
,
1
)
if
field
==
"Server started"
:
self
.
start
=
value
elif
field
==
"Clients"
:
self
.
clients
=
int
(
value
)
elif
field
==
"Clients verifying"
:
self
.
verifying_clients
=
int
(
value
)
elif
field
==
"Active transactions"
:
self
.
active_txns
=
int
(
value
)
elif
field
==
"Commit lock held for"
:
# This assumes
self
.
lock_time
=
time
.
time
()
-
int
(
value
)
elif
field
==
"Commits"
:
self
.
commits
=
int
(
value
)
elif
field
==
"Aborts"
:
self
.
aborts
=
int
(
value
)
elif
field
==
"Loads"
:
self
.
loads
=
int
(
value
)
elif
field
==
"Stores"
:
self
.
stores
=
int
(
value
)
elif
field
==
"Conflicts"
:
self
.
conflicts
=
int
(
value
)
elif
field
==
"Conflicts resolved"
:
self
.
conflicts_resolved
=
int
(
value
)
def
dump
(
self
,
f
):
def
dump
(
self
,
f
):
print
>>
f
,
"Server started:"
,
self
.
start
print
>>
f
,
"Server started:"
,
self
.
start
print
>>
f
,
"Clients:"
,
self
.
clients
print
>>
f
,
"Clients:"
,
self
.
clients
...
...
src/ZEO/tests/testMonitor.py
View file @
3b6c3dcb
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
##############################################################################
##############################################################################
"""Test that the monitor produce sensible results.
"""Test that the monitor produce sensible results.
$Id: testMonitor.py,v 1.
2 2003/01/13 21:43:24 tim_one
Exp $
$Id: testMonitor.py,v 1.
3 2003/01/15 21:23:17 jeremy
Exp $
"""
"""
import
socket
import
socket
...
@@ -21,6 +21,7 @@ import time
...
@@ -21,6 +21,7 @@ import time
import
unittest
import
unittest
from
ZEO.tests.ConnectionTests
import
CommonSetupTearDown
from
ZEO.tests.ConnectionTests
import
CommonSetupTearDown
from
ZEO.monitor
import
StorageStats
class
MonitorTests
(
CommonSetupTearDown
):
class
MonitorTests
(
CommonSetupTearDown
):
...
@@ -39,6 +40,37 @@ class MonitorTests(CommonSetupTearDown):
...
@@ -39,6 +40,37 @@ class MonitorTests(CommonSetupTearDown):
s
.
close
()
s
.
close
()
return
""
.
join
(
L
)
return
""
.
join
(
L
)
def
parse
(
self
,
s
):
# Return a list of StorageStats, one for each storage.
lines
=
s
.
split
(
"
\
n
"
)
self
.
assert_
(
lines
[
0
].
startswith
(
"ZEO monitor server"
))
# lines[1] is a date
# Break up rest of lines into sections starting with Storage:
# and ending with a blank line.
sections
=
[]
cur
=
None
for
line
in
lines
[
2
:]:
if
line
.
startswith
(
"Storage:"
):
cur
=
[
line
]
elif
line
:
cur
.
append
(
line
)
else
:
if
cur
is
not
None
:
sections
.
append
(
cur
)
cur
=
None
assert
cur
is
None
# bug in the test code if this fails
d
=
{}
for
sect
in
sections
:
hdr
=
sect
[
0
]
key
,
value
=
hdr
.
split
(
":"
)
storage
=
int
(
value
)
s
=
d
[
storage
]
=
StorageStats
()
s
.
parse
(
"
\
n
"
.
join
(
sect
[
1
:]))
return
d
def
getConfig
(
self
,
path
,
create
,
read_only
):
def
getConfig
(
self
,
path
,
create
,
read_only
):
return
"""
\
return
"""
\
<Storage>
<Storage>
...
@@ -53,7 +85,10 @@ class MonitorTests(CommonSetupTearDown):
...
@@ -53,7 +85,10 @@ class MonitorTests(CommonSetupTearDown):
s
=
self
.
get_monitor_output
()
s
=
self
.
get_monitor_output
()
self
.
storage
.
close
()
self
.
storage
.
close
()
self
.
assert_
(
s
.
find
(
"monitor"
)
!=
-
1
)
self
.
assert_
(
s
.
find
(
"monitor"
)
!=
-
1
)
d
=
self
.
parse
(
s
)
stats
=
d
[
1
]
self
.
assertEqual
(
stats
.
clients
,
1
)
self
.
assertEqual
(
stats
.
commits
,
0
)
def
test_suite
():
def
test_suite
():
return
unittest
.
makeSuite
(
MonitorTests
)
return
unittest
.
makeSuite
(
MonitorTests
)
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