register was a first experience in a jepsen testing it contains two operations (write and read) written using Lua.
Although both can be implemented using SQL.
(defn read-v-by-k
"Reads the current value of a key."
[conn k]
(first (vals (first (j/execute! conn ["SELECT _READ(?, 'JEPSEN')" k])))))
(defn write-v-by-k
"Writes the current value of a key."
[conn k v]
(j/execute! conn ["SELECT _WRITE(?, ?, 'JEPSEN')"
k v]))
(defn compare-and-set
[conn id old new]
(first (vals (first (j/execute! conn ["SELECT _CAS(?, ?, ?, 'JEPSEN')"
id old new])))))
--[[ Function implements an WRITE operation, which takes a key and value
and sets the key to the value if and only if the key is already exists, and
insert value if it is absent.
Example: SELECT _WRITE(1, 3, 'JEPSEN')
]]
box.schema.func.create('_WRITE',
{language = 'LUA',
returns = 'integer',
body = [[function (id, value, table)
box.space[table]:upsert({id, value}, {{'=', 1, 1}, {'=', 2, value}})
return value
end]],
is_sandboxed = false,
param_list = {'integer', 'integer', 'string'},
exports = {'LUA', 'SQL'},
is_deterministic = true})
--[[ Function implements an READ operation, which takes a key and returns a
value.
Example: SELECT _READ(1, 'JEPSEN')
]]
box.schema.func.create('_READ',
{language = 'LUA',
returns = 'integer',
body = [[function (id, table)
box.begin()
local tuple = box.space[table]:get{id}
if tuple then
return tuple[2]
end
box.commit()
return nil
end]],
is_sandboxed = false,
param_list = {'integer', "string"},
exports = {'LUA', 'SQL'},
is_deterministic = true})
register was a first experience in a jepsen testing it contains two operations (
write
andread
) written using Lua. Although both can be implemented using SQL.https://github.com/tarantool/jepsen.tarantool/blob/master/src/tarantool/register.clj
https://github.com/tarantool/jepsen.tarantool/blob/master/src/tarantool/client.clj
https://github.com/tarantool/jepsen.tarantool/blob/master/resources/tarantool/jepsen.lua