This file is indexed.

/usr/share/pyshared/ZEO/tests/protocols.test is in python-zodb 1:3.9.7-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
Test that multiple protocols are supported
==========================================

A full test of all protocols isn't practical.  But we'll do a limited
test that at least the current and previous protocols are supported in
both directions.

Let's start a Z308 server

    >>> storage_conf = '''
    ... <blobstorage>
    ...    blob-dir server-blobs
    ...    <filestorage>
    ...       path Data.fs
    ...    </filestorage>
    ... </blobstorage>
    ... '''

    >>> addr, admin = start_server(
    ...    storage_conf, dict(invalidation_queue_size=5), protocol='Z308')

A current client should be able to connect to a old server:

    >>> import ZEO, ZODB.blob, transaction
    >>> db = ZEO.DB(addr, client='client', blob_dir='blobs')
    >>> wait_connected(db.storage)
    >>> db.storage._connection.peer_protocol_version
    'Z308'

    >>> conn = db.open()
    >>> conn.root().x = 0
    >>> transaction.commit()
    >>> len(db.history(conn.root()._p_oid, 99))
    2

    >>> conn.root()['blob1'] = ZODB.blob.Blob()
    >>> conn.root()['blob1'].open('w').write('blob data 1')
    >>> transaction.commit()

    >>> db2 = ZEO.DB(addr, blob_dir='server-blobs', shared_blob_dir=True)
    >>> wait_connected(db2.storage)
    >>> conn2 = db2.open()
    >>> for i in range(5):
    ...     conn2.root().x += 1
    ...     transaction.commit()
    >>> conn2.root()['blob2'] = ZODB.blob.Blob()
    >>> conn2.root()['blob2'].open('w').write('blob data 2')
    >>> transaction.commit()


    >>> conn.sync()
    >>> conn.root().x
    5

    >>> db.close()

    >>> for i in range(2):
    ...     conn2.root().x += 1
    ...     transaction.commit()

    >>> db = ZEO.DB(addr, client='client', blob_dir='blobs')
    >>> wait_connected(db.storage)
    >>> conn = db.open()
    >>> conn.root().x
    7

    >>> db.close()

    >>> for i in range(10):
    ...     conn2.root().x += 1
    ...     transaction.commit()

    >>> db = ZEO.DB(addr, client='client', blob_dir='blobs')
    >>> wait_connected(db.storage)
    >>> conn = db.open()
    >>> conn.root().x
    17

    >>> conn.root()['blob1'].open().read()
    'blob data 1'
    >>> conn.root()['blob2'].open().read()
    'blob data 2'

Note that when taking to a 3.8 server, iteration won't work:

    >>> db.storage.iterator()
    Traceback (most recent call last):
    ...
    NotImplementedError

    >>> db2.close()
    >>> db.close()
    >>> stop_server(admin)

    >>> import os, zope.testing.setupstack
    >>> os.remove('client-1.zec')
    >>> zope.testing.setupstack.rmtree('blobs')
    >>> zope.testing.setupstack.rmtree('server-blobs')

And the other way around:

    >>> addr, _ = start_server(storage_conf, dict(invalidation_queue_size=5))

Note that we'll have to pull some hijinks:

    >>> import ZEO.zrpc.connection
    >>> old_current_protocol = ZEO.zrpc.connection.Connection.current_protocol
    >>> ZEO.zrpc.connection.Connection.current_protocol = 'Z308'

    >>> db = ZEO.DB(addr, client='client', blob_dir='blobs')
    >>> db.storage._connection.peer_protocol_version
    'Z308'
    >>> wait_connected(db.storage)
    >>> conn = db.open()
    >>> conn.root().x = 0
    >>> transaction.commit()
    >>> len(db.history(conn.root()._p_oid, 99))
    2

    >>> conn.root()['blob1'] = ZODB.blob.Blob()
    >>> conn.root()['blob1'].open('w').write('blob data 1')
    >>> transaction.commit()

    >>> db2 = ZEO.DB(addr, blob_dir='server-blobs', shared_blob_dir=True)
    >>> wait_connected(db2.storage)
    >>> conn2 = db2.open()
    >>> for i in range(5):
    ...     conn2.root().x += 1
    ...     transaction.commit()
    >>> conn2.root()['blob2'] = ZODB.blob.Blob()
    >>> conn2.root()['blob2'].open('w').write('blob data 2')
    >>> transaction.commit()


    >>> conn.sync()
    >>> conn.root().x
    5

    >>> db.close()

    >>> for i in range(2):
    ...     conn2.root().x += 1
    ...     transaction.commit()

    >>> db = ZEO.DB(addr, client='client', blob_dir='blobs')
    >>> wait_connected(db.storage)
    >>> conn = db.open()
    >>> conn.root().x
    7

    >>> db.close()

    >>> for i in range(10):
    ...     conn2.root().x += 1
    ...     transaction.commit()

    >>> db = ZEO.DB(addr, client='client', blob_dir='blobs')
    >>> wait_connected(db.storage)
    >>> conn = db.open()
    >>> conn.root().x
    17

    >>> conn.root()['blob1'].open().read()
    'blob data 1'
    >>> conn.root()['blob2'].open().read()
    'blob data 2'

Make some old protocol calls:

    >>> db.storage._server.rpc.call('getSerial', conn.root()._p_oid
    ...      ) == conn.root()._p_serial
    True

    >>> p, s, v, x, y = db.storage._server.rpc.call('zeoLoad',
    ...                                             conn.root()._p_oid)
    >>> (v, x, y) == ('', None, None)
    True
    >>> db.storage.load(conn.root()._p_oid) == (p, s)
    True


    >>> db2.close()
    >>> db.close()

Undo the hijinks:

    >>> ZEO.zrpc.connection.Connection.current_protocol = old_current_protocol