Commit 9030f36b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent fc9ce782
...@@ -19,33 +19,48 @@ ...@@ -19,33 +19,48 @@
# See COPYING file for full licensing terms. # See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options. # See https://www.nexedi.com/licensing for rationale and options.
# FIXME update text
# XXX review
"""Program treegen provides infrastructure to generate ZODB BTree states. """Program treegen provides infrastructure to generate ZODB BTree states.
It is used as helper for ΔBTree tests. It is used as helper for ΔBTree tests.
The following subcommands are provided: The following subcommands are provided:
- `trees` generates trees specified as arguments, - `trees` transition ZODB tree through requested tree states,
- `allstructs` generates subset of all possible tree changes in between two - `allstructs` generates subset of all possible tree topologies for changes in
trees represented by two key->value dicts. between two trees represented by two key->value dicts.
Because python/pkg_resources startup is very slow(*) all subcommands can be
used either in CLI or in server mode, where requests are continuously read from
stdin.
Subcommands documentation follows:
trees trees
----- -----
`treegen trees` ... `treegen trees <zurl>` transitions in-ZODB LOBTree through requested tree states.
Tree states are specified on stdin as topology-encoded strings, 1 state per 1 line.
For every request the tree is changed and modifications are committed to database.
For every made commit corresponding transaction ID is printed to stdout.
S: tree.srv start @<head> root=<tree-root-oid>
C: <tree>
S: <tid>
C: <tree>
S: <tid>
...
# tree1 (with values) for example
# tree2
# ...
# | treegen
# a zodb tree goes through tree states S: tree.srv start @03d85dd71ed0d2ee root=000000000000000b
# every state is committed as separate transaction & printed in the same C: T/B1:a
# format as treegen-allstructs does S: 03d85dd84fed7844
C: T2/B1:a-B3:c
S: 03d85dd871718899
...
The tree, that `treegen trees` works on, is also accessible as zconn.root()['treegen/tree'].
allstructs allstructs
...@@ -74,6 +89,11 @@ tree <oid> ...@@ -74,6 +89,11 @@ tree <oid>
<LF> <LF>
XXX XXX
--------
(*) 300-500ms, see https://github.com/pypa/setuptools/issues/510
""" """
from __future__ import print_function, absolute_import from __future__ import print_function, absolute_import
...@@ -114,7 +134,7 @@ class ZCtx(object): ...@@ -114,7 +134,7 @@ class ZCtx(object):
# .root # .root
# .valdict = zconn.root['treegen/values'] = {} v -> ZBlk(v) # .valdict = zconn.root['treegen/values'] = {} v -> ZBlk(v)
# ZCtx(zstor) opens connection to zstor. # ZCtx(zstor) opens connection to zstor and initializes .valdict.
def __init__(zctx, zstor): def __init__(zctx, zstor):
zctx.db = DB(zstor) zctx.db = DB(zstor)
zctx.zconn = zctx.db.open() zctx.zconn = zctx.db.open()
...@@ -151,8 +171,9 @@ class ZCtx(object): ...@@ -151,8 +171,9 @@ class ZCtx(object):
raise KeyError("%r not found in value registry" % (vobj,)) raise KeyError("%r not found in value registry" % (vobj,))
# TreesSrv generates tree structures given their topology encoding on input. # TreesSrv transitions ZODB tree through requested states.
# See top-level documentation for details. # See top-level documentation for details.
# XXX kill TreesSrv generates tree structures given their topology encoding on input.
@func @func
def TreesSrv(zstor, r): def TreesSrv(zstor, r):
zctx = ZCtx(zstor) zctx = ZCtx(zstor)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment