[PATCH] tox: Remove python 2 tests, add python 3.7, 3.8 tests
by Nir Soffer
Python 2 is dead for a while, and there is no point in running the tests
now. Python 3.7 and 3.8 are available and we want to test them on
travis.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
.travis.yml | 4 ++--
tox.ini | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 89fb52a..bea805d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,10 +3,10 @@ dist: xenial
language: python
python:
- - "2.7"
- "3.6"
- "3.7"
- - "3.8-dev"
+ - "3.8"
+ - "3.9-dev"
addons:
apt:
diff --git a/tox.ini b/tox.ini
index 4a28561..af8a6cc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,7 +4,7 @@
# and then run "tox" from this directory.
[tox]
-envlist = py27,py36,flake8
+envlist = py{36,37,38},flake8
skipsdist = True
skip_missing_interpreters = True
@@ -18,8 +18,7 @@ whitelist_externals = make
deps =
pytest==4.0
commands =
- py27: make PY_VERSION=2.7 BUILDARGS="--build-lib={envsitepackagesdir}"
- py36: make PY_VERSION=3.6 BUILDARGS="--build-lib={envsitepackagesdir}"
+ py{36,37,38}: make BUILDARGS="--build-lib={envsitepackagesdir}"
pytest {posargs}
[testenv:flake8]
--
2.25.4
3 years, 5 months
[sanlock] 02/02: tests: Test handling paths with colons
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit 7cc926179bff32f2830dc1f9ab0c2a297a47117b
Author: Nir Soffer <nirsof(a)gmail.com>
AuthorDate: Wed Apr 29 02:01:14 2020 +0300
tests: Test handling paths with colons
"sanlock direct dump" supports now escaped colons in path. Add a test to
verify this behaviour. Unfortunately, "sanlock direct init" does not
support that yet.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
tests/direct_test.py | 24 ++++++++++++++++++++++++
tests/util.py | 5 +++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/tests/direct_test.py b/tests/direct_test.py
index bc66526..a7ad014 100644
--- a/tests/direct_test.py
+++ b/tests/direct_test.py
@@ -10,6 +10,7 @@ Test sanlock direct options.
from __future__ import absolute_import
import io
+import os
import struct
from . import constants
@@ -113,3 +114,26 @@ def test_dump_resources_start_before(tmpdir):
['04194304', 'ls_name', 'res_4', '0000000000', '0000', '0000', '0'],
['05242880', 'ls_name', 'res_5', '0000000000', '0000', '0000', '0'],
]
+
+
+def test_path_with_colon(tmpdir):
+ path = str(tmpdir.mkdir("with:colon").join("resources"))
+ size = 8 * MiB
+ util.create_file(path, size)
+
+ # sanlock direct init does not support escaped colons in path.
+ dirname, filename = os.path.split(path)
+ res = "ls_name:res_0:%s:0M" % filename
+ util.sanlock("direct", "init", "-r", res, cwd=dirname)
+
+ # sanlock direct dump supports escaped colons in path.
+ escaped_path = path.replace(":", "\\:")
+ dump = "%s:0:8M" % escaped_path
+ out = util.sanlock("direct", "dump", dump)
+
+ lines = out.decode("utf-8").splitlines()
+ resources = [line.split() for line in lines]
+ assert resources == [
+ ['offset', 'lockspace', 'resource', 'timestamp', 'own', 'gen', 'lver'],
+ ['00000000', 'ls_name', 'res_0', '0000000000', '0000', '0000', '0'],
+ ]
diff --git a/tests/util.py b/tests/util.py
index 12f2702..df36ebb 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -82,14 +82,15 @@ def wait_for_daemon(timeout):
s.close()
-def sanlock(*args):
+def sanlock(*args, cwd=None):
"""
Run sanlock returning the process stdout, or raising
util.CommandError on failures.
"""
cmd = [SANLOCK]
cmd.extend(args)
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ p = subprocess.Popen(
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
out, err = p.communicate()
if p.returncode:
raise CommandError(cmd, p.returncode, out, err)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 5 months
[sanlock] 01/02: tests: Tests dumping lockspace and resources
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit 0a86809348038c4f50c81fcb059c56bd2c5b1386
Author: Nir Soffer <nirsof(a)gmail.com>
AuthorDate: Wed Apr 29 02:01:13 2020 +0300
tests: Tests dumping lockspace and resources
Add tests for dumping:
- empty lockspace
- resources with a hole
- start before first resource
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
tests/direct_test.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 65 insertions(+), 1 deletion(-)
diff --git a/tests/direct_test.py b/tests/direct_test.py
index 579f228..bc66526 100644
--- a/tests/direct_test.py
+++ b/tests/direct_test.py
@@ -34,7 +34,27 @@ def test_init_lockspace(tmpdir):
util.check_guard(str(path), size)
-def test_init_resource(tmpdir, sanlock_daemon):
+def test_dump_lockspace_empty(tmpdir):
+ path = tmpdir.join("lockspace")
+ size = MiB
+ util.create_file(str(path), size)
+
+ lockspace = "name:1:%s:0" % path
+ util.sanlock("direct", "init", "-s", lockspace)
+
+ dump = "%s:0:1M" % path
+ out = util.sanlock("direct", "dump", dump)
+
+ lines = out.decode("utf-8").splitlines()
+ spaces = [line.split() for line in lines]
+
+ # Empty lockspace has no hosts.
+ assert spaces == [
+ ['offset', 'lockspace', 'resource', 'timestamp', 'own', 'gen', 'lver']
+ ]
+
+
+def test_init_resource(tmpdir):
path = tmpdir.join("resources")
size = MiB
util.create_file(str(path), size)
@@ -49,3 +69,47 @@ def test_init_resource(tmpdir, sanlock_daemon):
# TODO: check more stuff here...
util.check_guard(str(path), size)
+
+
+def test_dump_resources(tmpdir):
+ path = tmpdir.join("resources")
+ size = 8 * MiB
+ util.create_file(str(path), size)
+
+ # Write 2 resources with a hole between them.
+ for i in [0, 2]:
+ res = "ls_name:res_%d:%s:%dM" % (i, path, i)
+ util.sanlock("direct", "init", "-r", res)
+
+ dump = "%s:0:8M" % path
+ out = util.sanlock("direct", "dump", dump)
+
+ lines = out.decode("utf-8").splitlines()
+ resources = [line.split() for line in lines]
+ assert resources == [
+ ['offset', 'lockspace', 'resource', 'timestamp', 'own', 'gen', 'lver'],
+ ['00000000', 'ls_name', 'res_0', '0000000000', '0000', '0000', '0'],
+ ['02097152', 'ls_name', 'res_2', '0000000000', '0000', '0000', '0'],
+ ]
+
+
+def test_dump_resources_start_before(tmpdir):
+ path = tmpdir.join("resources")
+ size = 8 * MiB
+ util.create_file(str(path), size)
+
+ # Write 2 resources at middle.
+ for i in [4, 5]:
+ res = "ls_name:res_%d:%s:%dM" % (i, path, i)
+ util.sanlock("direct", "init", "-r", res)
+
+ dump = "%s:2M:8M" % path
+ out = util.sanlock("direct", "dump", dump)
+
+ lines = out.decode("utf-8").splitlines()
+ resources = [line.split() for line in lines]
+ assert resources == [
+ ['offset', 'lockspace', 'resource', 'timestamp', 'own', 'gen', 'lver'],
+ ['04194304', 'ls_name', 'res_4', '0000000000', '0000', '0000', '0'],
+ ['05242880', 'ls_name', 'res_5', '0000000000', '0000', '0000', '0'],
+ ]
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 5 months
[PATCH 0/2] Improve sanlock direct tests
by Nir Soffer
Vdsm is going to use "sanlock direct dump". Improve testing to make sure we
don't introduce regressions in this area.
Nir Soffer (2):
tests: Tests dumping lockspace and resources
tests: Test handling paths with colons
tests/direct_test.py | 90 +++++++++++++++++++++++++++++++++++++++++++-
tests/util.py | 5 ++-
2 files changed, 92 insertions(+), 3 deletions(-)
--
2.25.4
3 years, 5 months
[sanlock] branch master updated: tox: Remove python 2 tests,
add python 3.7, 3.8 tests
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new 02c9191 tox: Remove python 2 tests, add python 3.7, 3.8 tests
02c9191 is described below
commit 02c9191a9a7b90156ca26b990535fb8ee7837074
Author: Nir Soffer <nirsof(a)gmail.com>
AuthorDate: Tue Apr 28 02:44:03 2020 +0300
tox: Remove python 2 tests, add python 3.7, 3.8 tests
Python 2 is dead for a while, and there is no point in running the tests
now. Python 3.7 and 3.8 are available and we want to test them on
travis.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
.travis.yml | 4 ++--
tox.ini | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 89fb52a..bea805d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,10 +3,10 @@ dist: xenial
language: python
python:
- - "2.7"
- "3.6"
- "3.7"
- - "3.8-dev"
+ - "3.8"
+ - "3.9-dev"
addons:
apt:
diff --git a/tox.ini b/tox.ini
index 4a28561..af8a6cc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,7 +4,7 @@
# and then run "tox" from this directory.
[tox]
-envlist = py27,py36,flake8
+envlist = py{36,37,38},flake8
skipsdist = True
skip_missing_interpreters = True
@@ -18,8 +18,7 @@ whitelist_externals = make
deps =
pytest==4.0
commands =
- py27: make PY_VERSION=2.7 BUILDARGS="--build-lib={envsitepackagesdir}"
- py36: make PY_VERSION=3.6 BUILDARGS="--build-lib={envsitepackagesdir}"
+ py{36,37,38}: make BUILDARGS="--build-lib={envsitepackagesdir}"
pytest {posargs}
[testenv:flake8]
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 5 months
[sanlock] branch master updated: sanlock: escapes in direct dump arg
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new b00b728 sanlock: escapes in direct dump arg
b00b728 is described below
commit b00b728d7fca96db9e64902e753d9f7890f198d4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 27 13:46:20 2020 -0500
sanlock: escapes in direct dump arg
If the path contains a colon, escape it with \\
so that :offset:length path suffix can be used.
---
src/direct.c | 42 ++++++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
diff --git a/src/direct.c b/src/direct.c
index c18848e..661c4e8 100644
--- a/src/direct.c
+++ b/src/direct.c
@@ -553,7 +553,7 @@ int test_id_bit(int host_id, char *bitmap);
int direct_dump(struct task *task, char *dump_path, int force_mode)
{
char *data, *bitmap;
- char *colon1, *colon2, *off_str = NULL, *size_str = NULL, *m;
+ char *colon1 = NULL, *colon2 = NULL, *off_str = NULL, *size_str = NULL, *m;
uint32_t magic;
struct rindex_header *rh_end;
struct rindex_header *rh;
@@ -581,17 +581,36 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
memset(&sd, 0, sizeof(struct sync_disk));
- /* /path[:<offset>[:<size>]] */
- colon1 = strchr(dump_path, ':');
- colon2 = strchr(colon1+1, ':');
+ /*
+ * /path[:<offset>[:<size>]]
+ *
+ * If path contains a colon, the user would escape it with \\, e.g.
+ * device named /dev/foo:32 using offset 0 and lenth 1M would be
+ * /dev/foo\\:32:0:1M
+ */
+
+ for (i = 0; i < strlen(dump_path); i++) {
+ if (dump_path[i] == '\\') {
+ i++;
+ continue;
+ }
+
+ if (dump_path[i] == ':') {
+ if (!colon1)
+ colon1 = &dump_path[i];
+ else if (!colon2)
+ colon2 = &dump_path[i];
+ }
+ }
+
if (colon1) {
+ *colon1 = '\0';
off_str = colon1 + 1;
- if (colon2)
- size_str = colon2 + 1;
- *colon1 = '\0';
- if (colon2)
+ if (colon2) {
*colon2 = '\0';
+ size_str = colon2 + 1;
+ }
if ((m = strchr(off_str, 'M'))) {
*m = '\0';
@@ -613,12 +632,15 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
if (start_offset % 1048576)
printf("WARNING: dump offset should be a multiple of 1048576 bytes.\n");
- strncpy(sd.path, dump_path, SANLK_PATH_LEN);
+ sanlock_path_import(sd.path, dump_path, sizeof(sd.path));
+
sd.fd = -1;
rv = open_disk(&sd);
- if (rv < 0)
+ if (rv < 0) {
+ printf("Device %s not found.\n", sd.path);
return -ENODEV;
+ }
if (com.sector_size)
sector_size = com.sector_size;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 5 months
[sanlock] branch master updated: sanlock: fix direct dump with
offset
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
The following commit(s) were added to refs/heads/master by this push:
new 807e74a sanlock: fix direct dump with offset
807e74a is described below
commit 807e74a10a118d0b744b067fee7c2a741f95bce1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 23 15:09:20 2020 -0500
sanlock: fix direct dump with offset
For direct dump <path>:<offset>:<size> the dump is meant
to continue reading/reporting for the entire range. If
the sector_size/align_size were not at <offset> the dump
would stop. Fix this by searching through the range for
sector_size/align_size before beginning the real dump.
Accept the M (MB) suffix on offset and size.
Fix the printed offset of structures so that it is always
relative to the start of the disk (it had been relative to
the <offset>.)
---
src/direct.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 62 insertions(+), 19 deletions(-)
diff --git a/src/direct.c b/src/direct.c
index 6b9b78a..c18848e 100644
--- a/src/direct.c
+++ b/src/direct.c
@@ -34,6 +34,10 @@
#include "timeouts.h"
#include "rindex.h"
+/*
+ * the caller sets sd.offset to the location from the start of disk (in bytes) where
+ * a data struct should be read and checked for sector/align sizes.
+ */
static int direct_read_leader_sizes(struct task *task, struct sync_disk *sd,
int *sector_size, int *align_size)
{
@@ -549,7 +553,7 @@ int test_id_bit(int host_id, char *bitmap);
int direct_dump(struct task *task, char *dump_path, int force_mode)
{
char *data, *bitmap;
- char *colon, *off_str;
+ char *colon1, *colon2, *off_str = NULL, *size_str = NULL, *m;
uint32_t magic;
struct rindex_header *rh_end;
struct rindex_header *rh;
@@ -567,8 +571,9 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
char sname[NAME_ID_SIZE+1];
char rname[NAME_ID_SIZE+1];
uint64_t sector_nr;
+ uint64_t start_offset = 0;
uint64_t dump_size = 0;
- uint64_t end_sector_nr;
+ uint64_t end_sector_nr = 0;
int sector_size = 0;
int align_size = 0;
int sector_count, datalen, max_hosts;
@@ -577,17 +582,37 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
memset(&sd, 0, sizeof(struct sync_disk));
/* /path[:<offset>[:<size>]] */
- colon = strstr(dump_path, ":");
- if (colon) {
- off_str = colon + 1;
- *colon = '\0';
- sd.offset = atoll(off_str);
+ colon1 = strchr(dump_path, ':');
+ colon2 = strchr(colon1+1, ':');
+ if (colon1) {
+ off_str = colon1 + 1;
+ if (colon2)
+ size_str = colon2 + 1;
+
+ *colon1 = '\0';
+ if (colon2)
+ *colon2 = '\0';
+
+ if ((m = strchr(off_str, 'M'))) {
+ *m = '\0';
+ start_offset = atoll(off_str) * 1024 * 1024;
+ } else {
+ start_offset = atoll(off_str);
+ }
- colon = strstr(off_str, ":");
- if (colon)
- dump_size = atoll(colon + 1);
+ if (size_str) {
+ if ((m = strchr(size_str, 'M'))) {
+ *m = '\0';
+ dump_size = atoll(size_str) * 1024 * 1024;
+ } else {
+ dump_size = atoll(size_str);
+ }
+ }
}
+ if (start_offset % 1048576)
+ printf("WARNING: dump offset should be a multiple of 1048576 bytes.\n");
+
strncpy(sd.path, dump_path, SANLK_PATH_LEN);
sd.fd = -1;
@@ -601,9 +626,25 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
align_size = com.align_size;
if (!sector_size || !align_size) {
- rv = direct_read_leader_sizes(task, &sd, §or_size, &align_size);
- if (rv < 0)
- return rv;
+ sd.offset = start_offset;
+ for (i = 0; i < 1024; i++) {
+ rv = direct_read_leader_sizes(task, &sd, §or_size, &align_size);
+ if (sector_size && align_size)
+ break;
+
+ /*
+ * search for a data structure that contains sector_size/align_size
+ * every 1MB, up to 1GB or dump_size.
+ */
+ sd.offset += 1048576;
+
+ if (dump_size && (sd.offset >= (start_offset + dump_size)))
+ break;
+ }
+ if (!sector_size || !align_size) {
+ printf("Cannot find sector_size and align_size, set with -A and -Z.\n");
+ goto out_close;
+ }
}
max_hosts = size_to_max_hosts(sector_size, align_size);
@@ -632,8 +673,10 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
printf("\n");
+ sd.offset = start_offset;
sector_nr = 0;
- end_sector_nr = dump_size / sector_size;
+ if (dump_size)
+ end_sector_nr = dump_size / sector_size;
while (end_sector_nr == 0 || sector_nr < end_sector_nr) {
memset(sname, 0, sizeof(rname));
@@ -667,7 +710,7 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
strncpy(rname, lr->resource_name, NAME_ID_SIZE);
printf("%08llu %36s %48s %010llu %04llu %04llu",
- (unsigned long long)((sector_nr + i) * sector_size),
+ (unsigned long long)(start_offset + ((sector_nr + i) * sector_size)),
sname, rname,
(unsigned long long)lr->timestamp,
(unsigned long long)lr->owner_id,
@@ -691,7 +734,7 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
strncpy(rname, lr->resource_name, NAME_ID_SIZE);
printf("%08llu %36s %48s %010llu %04llu %04llu %llu",
- (unsigned long long)(sector_nr * sector_size),
+ (unsigned long long)(start_offset + (sector_nr * sector_size)),
sname, rname,
(unsigned long long)lr->timestamp,
(unsigned long long)lr->owner_id,
@@ -699,7 +742,7 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
(unsigned long long)lr->lver);
if (force_mode) {
- struct request_record *rr_end = (struct request_record *)(data + sd.sector_size);
+ struct request_record *rr_end = (struct request_record *)(data + sector_size);
request_record_in(rr_end, &rr);
printf("/%llu/%u",
(unsigned long long)rr.lver, rr.force_mode);
@@ -742,7 +785,7 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
strncpy(sname, rh->lockspace_name, NAME_ID_SIZE);
printf("%08llu %36s rindex_header 0x%x %d %u %llu\n",
- (unsigned long long)(sector_nr * sector_size),
+ (unsigned long long)(start_offset + (sector_nr * sector_size)),
sname,
rh->flags, rh->sector_size, rh->max_resources,
(unsigned long long)rh->rx_offset);
@@ -765,7 +808,7 @@ int direct_dump(struct task *task, char *dump_path, int force_mode)
continue;
printf("%08llu %36s rentry %s %llu\n",
- (unsigned long long)((sector_nr * sector_size) + (i * sector_size) + (j * entry_size)),
+ (unsigned long long)(start_offset + ((sector_nr * sector_size) + (i * sector_size) + (j * entry_size))),
sname,
re->name, (unsigned long long)re->res_offset);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 5 months