-
-
Save reclosedev/cac5234c4b538d3fd3f0 to your computer and use it in GitHub Desktop.
Small test for elliptics python bindings: handling errors on writes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"loggers": { | |
"type": "/dev/stderr", | |
"level": 1, | |
"root": [ | |
{ | |
"formatter": { | |
"type": "string", | |
"pattern": "[%(timestamp)s]: %(message)s [%(...L)s]" | |
}, | |
"sink": { | |
"type": "files", | |
"path": "/dev/stdout", | |
"autoflush": true | |
} | |
} | |
] | |
}, | |
"options": { | |
"join": true, | |
"flags": 68, | |
"address": [ | |
"localhost:1025:2" | |
], | |
"remote": [ | |
"localhost:1025:2" | |
], | |
"wait_timeout": 60, | |
"check_timeout": 60, | |
"io_thread_num": 16, | |
"nonblocking_io_thread_num": 16, | |
"net_thread_num": 4, | |
"daemon": false, | |
"auth_cookie": "qwerty", | |
"bg_ionice_class": 3, | |
"bg_ionice_prio": 0, | |
"server_net_prio": 1, | |
"client_net_prio": 6, | |
"cache": { | |
"size": 128000000 | |
}, | |
"indexes_shard_count": 2, | |
"monitor": { | |
"port":20000, | |
"call_tree_timeout": 0 | |
} | |
}, | |
"backends": [ | |
{ | |
"backend_id": 1, | |
"type": "blob", | |
"group": 1, | |
"history": "/var/blob", | |
"data": "/var/blob/data", | |
"sync": 10, | |
"blob_flags": "582", | |
"blob_size": "1G", | |
"records_in_blob": "1000000", | |
"periodic_timeout": 15 | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import elliptics | |
from elliptics.core import exceptions_policy | |
def create_session(io_flags=0, no_exceptions=False): | |
log = elliptics.Logger("/dev/stdout", 1) | |
cfg = elliptics.Config() | |
cfg.config.wait_timeout = 5 | |
cfg.config.check_timeout = 60 | |
node = elliptics.Node(log, cfg) | |
node.add_remote("127.0.0.1", 1025, 2) | |
groups = [1] | |
session = elliptics.Session(node) | |
session.set_ioflags(io_flags) | |
session.set_cflags(0) | |
session.set_groups(groups) | |
if no_exceptions: | |
session.set_exceptions_policy(exceptions_policy.no_exceptions) | |
return session | |
def do_read_write(io_flags): | |
session = create_session(io_flags) | |
key, data = "ioserv.json", "data" | |
print "Writing using async Session.write_data()" | |
try: | |
result = session.write_data(key, data) | |
entries = result.get() | |
if len(entries): | |
print " FAILED, expected no entries, got", len(entries), entries | |
for entry in entries: | |
print " size: %s, error: '%s'" % (entry.size, entry.error) | |
else: | |
print " OK, write failed" | |
except Exception as e: | |
print " OK, write failed", e | |
#session = create_session(io_flags) | |
print "Writing using Session.write_file()" | |
try: | |
session.write_file(key, __file__) | |
print " FAIL, write_file didn't raised exception" | |
except Exception as e: | |
print " Ok, failed to session.write_file:", e | |
def main(): | |
print "\n\nFlags: elliptics.io_flags.append | elliptics.io_flags.cache" | |
do_read_write(elliptics.io_flags.append | elliptics.io_flags.cache) | |
print "\n\nFlags: elliptics.io_flags.append" | |
do_read_write(elliptics.io_flags.append) | |
print "\n\nFlags: 0" | |
do_read_write(0) | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Flags: elliptics.io_flags.append | elliptics.io_flags.cache | |
Writing using async Session.write_data() | |
FAILED, expected no entries, got 1 [<elliptics.core.LookupResultEntry object at 0x7fc41fea2848>] | |
size: 4, error: '' | |
Writing using Session.write_file() | |
FAIL, write_file didn't raised exception | |
Flags: elliptics.io_flags.append | |
Writing using async Session.write_data() | |
FAILED, expected no entries, got 1 [<elliptics.core.LookupResultEntry object at 0x7fc41fea27d0>] | |
size: 4, error: '' | |
Writing using Session.write_file() | |
FAIL, write_file didn't raised exception | |
Flags: 0 | |
Writing using async Session.write_data() | |
2015-04-07 10:41:36.311445 0/8533/8517 : 127.0.0.1:1025: trans: 2 TIMEOUT/need-exit: stall-check wait-ts: 5, need-exit: 0, cmd: WRITE [4], started: 2015-04-07 10:41:30.312008 | |
2015-04-07 10:41:36.311498 0/8533/8517 : 127.0.0.1:1025: TIMEOUT: transactions: 1, stall counter: 1/3, weight: 1.000000 | |
OK, write failed 1:927a008f7f94...1d90c7fc8a67: Failed to process WRITE command: Connection timed out: -110 | |
Writing using Session.write_file() | |
2015-04-07 10:41:36.312643 0/8517/8517 : Failed to write file '/home/rharitonov/projects/historydb-python/t_write_read.py' into the storage, transactions: 1, err: -28. | |
Ok, failed to session.write_file: 0:927a008f7f94...1d90c7fc8a67: WRITE: /home/rharitonov/projects/historydb-python/t_write_read.py, local_offset: 0, offset: 0, size: 0: No space left on device: -28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/bin/python2 /home/rharitonov/projects/historydb-python/t_write_read.py | |
Flags: elliptics.io_flags.append | |
Writing using async Session.write_data() | |
OK, write failed 1:927a008f7f94...1d90c7fc8a67: Failed to process WRITE command: No space left on device: -28 | |
Writing using Session.write_file() | |
2015-04-07 10:45:24.971930 0/8733/8733 : Failed to write file '/home/rharitonov/projects/historydb-python/t_write_read.py' into the storage, transactions: 1, err: -28. | |
Ok, failed to session.write_file: 0:927a008f7f94...1d90c7fc8a67: WRITE: /home/rharitonov/projects/historydb-python/t_write_read.py, local_offset: 0, offset: 0, size: 0: No space left on device: -28 | |
Flags: 0 | |
Writing using async Session.write_data() | |
OK, write failed 1:927a008f7f94...1d90c7fc8a67: Failed to process WRITE command: No space left on device: -28 | |
Writing using Session.write_file() | |
2015-04-07 10:45:25.974863 0/8733/8733 : Failed to write file '/home/rharitonov/projects/historydb-python/t_write_read.py' into the storage, transactions: 1, err: -28. | |
Ok, failed to session.write_file: 0:927a008f7f94...1d90c7fc8a67: WRITE: /home/rharitonov/projects/historydb-python/t_write_read.py, local_offset: 0, offset: 0, size: 0: No space left on device: -28 | |
Process finished with exit code 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment