# coding=UTF-8 """ Tests the representation of set names in backup files. """ import lib SET_NAMES = [None] SET_NAMES += lib.identifier_variations(63, False) def put_sets(set_names, key, bin_name, value): """ Inserts the given key with the given bin with the given value into the given sets. """ for set_name in set_names: lib.write_record(set_name, key, [bin_name], [value]) def check_sets(set_names, key, bin_name, value): """ Ensures that the given key has the given bin with the given value across all given sets. """ for set_name in set_names: meta_key, meta_ttl, record = lib.read_record(set_name, key) lib.validate_record(key, record, [bin_name], [value]) lib.validate_meta(key, meta_key, meta_ttl) def test_set_name(): """
# coding=UTF-8 """ Tests the representation of set names in backup files. """ import lib SET_NAMES = [None] SET_NAMES += lib.identifier_variations(63, False) def put_sets(set_names, key, bin_name, value): """ Inserts the given key with the given bin with the given value into the given sets. """ for set_name in set_names: lib.write_record(set_name, key, [bin_name], [value]) def check_sets(set_names, key, bin_name, value): """ Ensures that the given key has the given bin with the given value across all given sets. """ for set_name in set_names: meta_key, meta_ttl, record = lib.read_record(set_name, key) lib.validate_record(key, record, [bin_name], [value]) lib.validate_meta(key, meta_key, meta_ttl)
# coding=UTF-8 """ Tests the representation of keys in backup files. """ import lib # XXX - not testing strings with NUL for now, as the Python client chokes on them STRING_KEYS = lib.identifier_variations(10, False) STRING_KEYS += lib.identifier_variations(100, False) STRING_KEYS += lib.identifier_variations(1000, False) STRING_KEYS += lib.identifier_variations(10000, False) BLOB_KEYS = lib.identifier_variations(10) BLOB_KEYS += lib.identifier_variations(100) BLOB_KEYS += lib.identifier_variations(1000) BLOB_KEYS += lib.identifier_variations(10000) BLOB_KEYS = [bytearray(string.encode("UTF-8")) for string in BLOB_KEYS if len(string) > 0] INTEGER_KEYS = [ 0, 1, -1, 32767, -32768, 2147483647, -2147483648, 4294967296, 1099511627776, 9223372036854775807, -9223372036854775808 ] def put_keys(set_name, keys, value, send_key): """
# coding=UTF-8 """ Tests the representation of values in backup files. """ import lib import aerospike STRING_VALUES = lib.identifier_variations(10, False) STRING_VALUES += lib.identifier_variations(100, False) STRING_VALUES += lib.identifier_variations(1000, False) STRING_VALUES += lib.identifier_variations(10000, False) BLOB_VALUES = lib.identifier_variations(10) BLOB_VALUES += lib.identifier_variations(100) BLOB_VALUES += lib.identifier_variations(1000) BLOB_VALUES += lib.identifier_variations(10000) BLOB_VALUES = [bytearray(string.encode("UTF-8")) for string in BLOB_VALUES] INTEGER_VALUES = [ 0, 1, -1, 32767, -32768, 2147483647, -2147483648, 4294967296, 1099511627776, 9223372036854775807, -9223372036854775808 ] DOUBLE_VALUES = [ 0.0, 1.0, -1.0,
# coding=UTF-8 """ Tests the representation of bin names in backup files. """ import lib BIN_NAMES = lib.identifier_variations(14, False) def put_bins(set_name, key, bin_names, value): """ Inserts the given key with the given bins with the given value. """ values = [value] * len(bin_names) lib.write_record(set_name, key, bin_names, values) def check_bins(set_name, key, bin_names, value): """ Ensures that the given key has the given bins with the given value. """ meta_key, meta_ttl, record = lib.read_record(set_name, key) values = [value] * len(bin_names) lib.validate_record(key, record, bin_names, values) lib.validate_meta(key, meta_key, meta_ttl) def test_bin_name(): """ Test bin names. """ lib.backup_and_restore(
# coding=UTF-8 """ Tests the representation of keys in backup files. """ import lib STRING_KEYS = lib.identifier_variations(10, False) STRING_KEYS += lib.identifier_variations(100, False) STRING_KEYS += lib.identifier_variations(1000, False) STRING_KEYS += lib.identifier_variations(10000, False) BLOB_KEYS = lib.identifier_variations(10) BLOB_KEYS += lib.identifier_variations(100) BLOB_KEYS += lib.identifier_variations(1000) BLOB_KEYS += lib.identifier_variations(10000) BLOB_KEYS = [ bytearray(string.encode("UTF-8")) for string in BLOB_KEYS if len(string) > 0 ] INTEGER_KEYS = [ 0, 1, -1, 32767, -32768, 2147483647, -2147483648, 4294967296, 1099511627776, 9223372036854775807, -9223372036854775808 ] def put_keys(set_name, keys, value, send_key): """ Inserts the given keys with a single "value" bin with the given value. """
# coding=UTF-8 """ Tests the representation of UDF files in backup files. """ import lib, os.path COMMENTS = lib.identifier_variations(100, False) def put_udf_files(context, comments): """ Creates UDF files with the given comments. """ for comment in comments: content = u"--[=======[\n" + comment + u"\n--]=======]\n" path = lib.put_udf_file(content) context[os.path.basename(path)] = content def check_udf_files(context): """ Retrieves and verifies the UDF files referred to by the context. """ for path in context: content = lib.get_udf_file(path) assert lib.eq(content, context[path]), "UDF file %s has invalid content" % path def test_udf_file(): """ Test UDF files. """
# coding=UTF-8 """ Tests the representation of bin names in backup files. """ import lib BIN_NAMES = lib.identifier_variations(14, False) def put_bins(set_name, key, bin_names, value): """ Inserts the given key with the given bins with the given value. """ values = [value] * len(bin_names) lib.write_record(set_name, key, bin_names, values) def check_bins(set_name, key, bin_names, value): """ Ensures that the given key has the given bins with the given value. """ meta_key, meta_ttl, record = lib.read_record(set_name, key) values = [value] * len(bin_names) lib.validate_record(key, record, bin_names, values) lib.validate_meta(key, meta_key, meta_ttl) def test_bin_name(): """ Test bin names.
# coding=UTF-8 """ Tests the representation of UDF files in backup files. """ import os.path import lib COMMENTS = lib.identifier_variations(100, False) def put_udf_files(context, comments): """ Creates UDF files with the given comments. """ for comment in comments: content = u"--[=======[\n" + comment + u"\n--]=======]\n" path = lib.put_udf_file(content) context[os.path.basename(path)] = content def check_udf_files(context): """ Retrieves and verifies the UDF files referred to by the context. """ for path in context: content = lib.get_udf_file(path) assert lib.eq(content, context[path]), "UDF file %s has invalid content" % path