* [tarantool-patches] [PATCH] test: use yaml.safe_load() instead of yaml.load()
@ 2019-04-30 3:00 Alexander Turenko
2019-04-30 3:05 ` [tarantool-patches] " Alexander Turenko
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Turenko @ 2019-04-30 3:00 UTC (permalink / raw)
To: tarantool-patches; +Cc: Alexander Turenko
The primary reason why this change is needed is that yaml.load() w/o an
explicit loader was banned in Gentoo Linux for recent pyyaml versions;
see [1].
We don't use the pyyaml feature that allows to construct a Python object
based on a yaml tag, so safe_load() fit our needs.
See also related changes in test-run and tarantool-python ([2], [3], [4]).
[1]: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=79ba924d94cb0cf8559565178414c2a1d687b90c
[2]: https://github.com/tarantool/test-run/commit/38400e91c600677fb661154d00459d660fa9880d
[3]: https://github.com/tarantool/test-run/commit/89808d60eb3b5130e227fc1a7866f2ad5a197bea
[4]: https://github.com/tarantool/tarantool-python/commit/350771d240a18eec188a53e8c696028b41baa13f
---
no issue
https://github.com/tarantool/tarantool/tree/Totktonada/python-use-yaml-safe-load
test/box-py/snapshot.test.py | 6 +++---
test/replication-py/cluster.test.py | 6 +++---
test/replication-py/conflict.test.py | 4 ++--
test/replication-py/multi.test.py | 4 ++--
test/xlog-py/dup_key.test.py | 2 +-
test/xlog-py/empty.test.py | 2 +-
test/xlog-py/lsn_gap.test.py | 2 +-
test/xlog-py/misc.test.py | 10 +++++-----
test/xlog-py/missing.test.py | 2 +-
9 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/test/box-py/snapshot.test.py b/test/box-py/snapshot.test.py
index fb798bd43..2bfb8f621 100644
--- a/test/box-py/snapshot.test.py
+++ b/test/box-py/snapshot.test.py
@@ -23,7 +23,7 @@ admin("box.snapshot()")
admin("space:insert{2, 'second tuple'}")
#
# Check for other errors, e.g. "Permission denied".
-lsn = int(yaml.load(admin("box.info.lsn", silent=True))[0])
+lsn = int(yaml.safe_load(admin("box.info.lsn", silent=True))[0])
snapshot = str(lsn).zfill(20) + ".snap"
snapshot = os.path.join(os.path.join(server.vardir, server.name), snapshot)
# Make snapshot path unwritable
@@ -49,8 +49,8 @@ print """
admin("space:insert{1, 'Test tuple'}")
-pid = int(yaml.load(admin("box.info.pid", silent=True))[0])
-lsn = int(yaml.load(admin("box.info.lsn", silent=True))[0])
+pid = int(yaml.safe_load(admin("box.info.pid", silent=True))[0])
+lsn = int(yaml.safe_load(admin("box.info.lsn", silent=True))[0])
snapshot = str(lsn).zfill(20) + ".snap"
snapshot = os.path.join(os.path.join(server.vardir, server.name), snapshot)
diff --git a/test/replication-py/cluster.test.py b/test/replication-py/cluster.test.py
index b328b1c89..0140a6bdb 100644
--- a/test/replication-py/cluster.test.py
+++ b/test/replication-py/cluster.test.py
@@ -9,7 +9,7 @@ from lib.tarantool_server import TarantoolServer
## Get cluster uuid
cluster_uuid = ''
try:
- cluster_uuid = yaml.load(server.admin("box.space._schema:get('cluster')",
+ cluster_uuid = yaml.safe_load(server.admin("box.space._schema:get('cluster')",
silent = True))[0][1]
uuid.UUID('{' + cluster_uuid + '}')
print 'ok - cluster uuid'
@@ -170,7 +170,7 @@ replica.admin('box.info.vclock[%d] == 1' % replica_id)
print '-------------------------------------------------------------'
print 'Connect master to replica'
print '-------------------------------------------------------------'
-replication_source = yaml.load(replica.admin('box.cfg.listen', silent = True))[0]
+replication_source = yaml.safe_load(replica.admin('box.cfg.listen', silent = True))[0]
sys.stdout.push_filter(replication_source, '<replication_source>')
master.admin("box.cfg{ replication_source = '%s' }" % replication_source)
master.wait_lsn(replica_id, replica.get_lsn(replica_id))
@@ -200,7 +200,7 @@ print '-------------------------------------------------------------'
print 'Master must not crash then receives orphan rows from replica'
print '-------------------------------------------------------------'
-replication_source = yaml.load(replica.admin('box.cfg.listen', silent = True))[0]
+replication_source = yaml.safe_load(replica.admin('box.cfg.listen', silent = True))[0]
sys.stdout.push_filter(replication_source, '<replication>')
master.admin("box.cfg{ replication = '%s' }" % replication_source)
diff --git a/test/replication-py/conflict.test.py b/test/replication-py/conflict.test.py
index f40148318..1dcd66765 100644
--- a/test/replication-py/conflict.test.py
+++ b/test/replication-py/conflict.test.py
@@ -25,10 +25,10 @@ def parallel_run(cmd1, cmd2, compare):
replica.admin.socket.recv(2048)
# wait for status changing in tarantool
- master_status = yaml.load(master.admin(
+ master_status = yaml.safe_load(master.admin(
'box.info().replication[2].upstream.status', silent=True
))[0]
- replica_status = yaml.load(replica.admin(
+ replica_status = yaml.safe_load(replica.admin(
'box.info().replication[1].upstream.status', silent=True
))[0]
diff --git a/test/replication-py/multi.test.py b/test/replication-py/multi.test.py
index 15d5a409a..233802458 100644
--- a/test/replication-py/multi.test.py
+++ b/test/replication-py/multi.test.py
@@ -34,7 +34,7 @@ for i in range(REPLICA_N - 1):
# Make a list of servers
sources = []
for server in cluster:
- sources.append(yaml.load(server.admin('box.cfg.listen', silent = True))[0])
+ sources.append(yaml.safe_load(server.admin('box.cfg.listen', silent = True))[0])
server.id = server.get_param('id')
print 'done'
@@ -89,7 +89,7 @@ print
print 'Check data'
for server in cluster:
- cnt = yaml.load(server.admin("box.space.test:len()", silent = True))[0]
+ cnt = yaml.safe_load(server.admin("box.space.test:len()", silent = True))[0]
print 'server', server.id, 'is', cnt == ROW_N and 'ok' or 'not ok'
print 'Done'
print
diff --git a/test/xlog-py/dup_key.test.py b/test/xlog-py/dup_key.test.py
index 1c033da40..7609c9555 100644
--- a/test/xlog-py/dup_key.test.py
+++ b/test/xlog-py/dup_key.test.py
@@ -13,7 +13,7 @@ server.admin("space = box.schema.space.create('test')")
server.admin("index = box.space.test:create_index('primary')")
server.admin("box.snapshot()")
-lsn = int(yaml.load(server.admin("box.info.lsn", silent=True))[0])
+lsn = int(yaml.safe_load(server.admin("box.info.lsn", silent=True))[0])
filename = str(lsn).zfill(20) + ".xlog"
vardir = os.path.join(server.vardir, server.name)
wal_old = os.path.join(vardir, "old_" + filename)
diff --git a/test/xlog-py/empty.test.py b/test/xlog-py/empty.test.py
index 0d932d58b..d6f89e0fb 100644
--- a/test/xlog-py/empty.test.py
+++ b/test/xlog-py/empty.test.py
@@ -12,7 +12,7 @@ from os.path import abspath
#
server.stop()
server.deploy()
-lsn = str(yaml.load(server.admin("box.info.lsn", silent=True))[0])
+lsn = str(yaml.safe_load(server.admin("box.info.lsn", silent=True))[0])
path = os.path.join(server.vardir, server.name)
filename = os.path.join(path, lsn.zfill(20) + ".xlog")
f = open(filename, "w+")
diff --git a/test/xlog-py/lsn_gap.test.py b/test/xlog-py/lsn_gap.test.py
index d15257f72..7a503ff07 100644
--- a/test/xlog-py/lsn_gap.test.py
+++ b/test/xlog-py/lsn_gap.test.py
@@ -12,7 +12,7 @@ server.admin("space = box.schema.space.create('test')")
server.admin("index = box.space.test:create_index('primary')")
server.admin("box.space.test:insert{1, 'first tuple'}")
server.admin("box.space.test:insert{2, 'second tuple'}")
-lsn = int(yaml.load(server.admin("box.info.lsn", silent=True))[0])
+lsn = int(yaml.safe_load(server.admin("box.info.lsn", silent=True))[0])
path = os.path.join(server.vardir, server.name)
wal = os.path.join(path, str(lsn).zfill(20) + ".xlog")
server.stop()
diff --git a/test/xlog-py/misc.test.py b/test/xlog-py/misc.test.py
index 51e78b9bc..e39ae1495 100644
--- a/test/xlog-py/misc.test.py
+++ b/test/xlog-py/misc.test.py
@@ -6,7 +6,7 @@ from os.path import abspath
# cleanup server.vardir
server.stop()
server.deploy()
-lsn = int(yaml.load(server.admin("box.info.lsn", silent=True))[0])
+lsn = int(yaml.safe_load(server.admin("box.info.lsn", silent=True))[0])
server.stop()
data_path = os.path.join(server.vardir, server.name)
@@ -56,7 +56,7 @@ filename = str(lsn).zfill(20) + ".xlog"
wal = os.path.join(data_path, filename)
server.admin("box.space.tweedledum:insert{4, 'fourth tuple'}")
server.admin("box.space.tweedledum:insert{5, 'Unfinished record'}")
-pid = int(yaml.load(server.admin("require('tarantool').pid()", silent=True))[0])
+pid = int(yaml.safe_load(server.admin("require('tarantool').pid()", silent=True))[0])
from signal import SIGKILL
if pid > 0:
os.kill(pid, SIGKILL)
@@ -78,13 +78,13 @@ server.stop()
lsn += 1
server.start()
-orig_lsn = int(yaml.load(admin("box.info.lsn", silent=True))[0])
+orig_lsn = int(yaml.safe_load(admin("box.info.lsn", silent=True))[0])
# create .snap.inprogress
admin("box.snapshot()")
admin("box.space._schema:insert({'test', 'test'})")
admin("box.snapshot()")
-lsn = int(yaml.load(admin("box.info.lsn", silent=True))[0])
+lsn = int(yaml.safe_load(admin("box.info.lsn", silent=True))[0])
snapshot = str(lsn).zfill(20) + ".snap"
snapshot = os.path.join(data_path, snapshot)
server.stop()
@@ -96,6 +96,6 @@ for f in os.listdir(data_path):
# check that .snap.inprogress is ignored during scan
server.start()
-lsn = int(yaml.load(admin("box.info.lsn", silent=True))[0])
+lsn = int(yaml.safe_load(admin("box.info.lsn", silent=True))[0])
if lsn == orig_lsn:
print ".snap.inprogress is ignored"
diff --git a/test/xlog-py/missing.test.py b/test/xlog-py/missing.test.py
index 8d4c90417..df35dc6d7 100644
--- a/test/xlog-py/missing.test.py
+++ b/test/xlog-py/missing.test.py
@@ -14,7 +14,7 @@ server.stop()
server.start()
# these inserts will be in their own xlog, which then will
# get "lost"
-lsn = int(yaml.load(server.admin("box.info.lsn", silent=True))[0])
+lsn = int(yaml.safe_load(server.admin("box.info.lsn", silent=True))[0])
data_path = os.path.join(server.vardir, server.name)
wal = os.path.join(data_path, str(lsn).zfill(20) + ".xlog")
server.admin("box.space.test:insert{1, 'first tuple'}")
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-30 3:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30 3:00 [tarantool-patches] [PATCH] test: use yaml.safe_load() instead of yaml.load() Alexander Turenko
2019-04-30 3:05 ` [tarantool-patches] " Alexander Turenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox