|
|
e3c68b |
From 04b824ebfcf80c648d5855f10bc30fde45fd62eb Mon Sep 17 00:00:00 2001
|
|
|
e3c68b |
From: Sunny Kumar <sunkumar@redhat.com>
|
|
|
e3c68b |
Date: Thu, 26 Mar 2020 10:46:16 +0000
|
|
|
e3c68b |
Subject: [PATCH 361/362] snap_scheduler: python3 compatibility and new test
|
|
|
e3c68b |
case
|
|
|
e3c68b |
MIME-Version: 1.0
|
|
|
e3c68b |
Content-Type: text/plain; charset=UTF-8
|
|
|
e3c68b |
Content-Transfer-Encoding: 8bit
|
|
|
e3c68b |
|
|
|
e3c68b |
Problem:
|
|
|
e3c68b |
"snap_scheduler.py init" command failing with the below traceback:
|
|
|
e3c68b |
|
|
|
e3c68b |
[root@dhcp43-104 ~]# snap_scheduler.py init
|
|
|
e3c68b |
Traceback (most recent call last):
|
|
|
e3c68b |
File "/usr/sbin/snap_scheduler.py", line 941, in <module>
|
|
|
e3c68b |
sys.exit(main(sys.argv[1:]))
|
|
|
e3c68b |
File "/usr/sbin/snap_scheduler.py", line 851, in main
|
|
|
e3c68b |
initLogger()
|
|
|
e3c68b |
File "/usr/sbin/snap_scheduler.py", line 153, in initLogger
|
|
|
e3c68b |
logfile = os.path.join(process.stdout.read()[:-1], SCRIPT_NAME + ".log")
|
|
|
e3c68b |
File "/usr/lib64/python3.6/posixpath.py", line 94, in join
|
|
|
e3c68b |
genericpath._check_arg_types('join', a, *p)
|
|
|
e3c68b |
File "/usr/lib64/python3.6/genericpath.py", line 151, in _check_arg_types
|
|
|
e3c68b |
raise TypeError("Can't mix strings and bytes in path components") from None
|
|
|
e3c68b |
TypeError: Can't mix strings and bytes in path components
|
|
|
e3c68b |
|
|
|
e3c68b |
Solution:
|
|
|
e3c68b |
|
|
|
e3c68b |
Added the 'universal_newlines' flag to Popen to support backward compatibility.
|
|
|
e3c68b |
|
|
|
e3c68b |
Added a basic test for snapshot scheduler.
|
|
|
e3c68b |
|
|
|
e3c68b |
Backport Of:
|
|
|
e3c68b |
|
|
|
e3c68b |
>Upstream Patch: https://review.gluster.org/#/c/glusterfs/+/24257/
|
|
|
e3c68b |
>Change-Id: I78e8fabd866fd96638747ecd21d292f5ca074a4e
|
|
|
e3c68b |
>Fixes: #1134
|
|
|
e3c68b |
>Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
|
|
|
e3c68b |
|
|
|
e3c68b |
BUG: 1817369
|
|
|
e3c68b |
Change-Id: I78e8fabd866fd96638747ecd21d292f5ca074a4e
|
|
|
e3c68b |
Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
|
|
|
e3c68b |
Reviewed-on: https://code.engineering.redhat.com/gerrit/196482
|
|
|
e3c68b |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
e3c68b |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
e3c68b |
---
|
|
|
e3c68b |
extras/snap_scheduler/snap_scheduler.py | 2 +-
|
|
|
e3c68b |
tests/basic/volume-snap-scheduler.t | 49 +++++++++++++++++++++++++++++++++
|
|
|
e3c68b |
2 files changed, 50 insertions(+), 1 deletion(-)
|
|
|
e3c68b |
create mode 100644 tests/basic/volume-snap-scheduler.t
|
|
|
e3c68b |
|
|
|
e3c68b |
diff --git a/extras/snap_scheduler/snap_scheduler.py b/extras/snap_scheduler/snap_scheduler.py
|
|
|
e3c68b |
index a66c5e3..5a29d41 100755
|
|
|
e3c68b |
--- a/extras/snap_scheduler/snap_scheduler.py
|
|
|
e3c68b |
+++ b/extras/snap_scheduler/snap_scheduler.py
|
|
|
e3c68b |
@@ -149,7 +149,7 @@ def initLogger():
|
|
|
e3c68b |
sh.setFormatter(formatter)
|
|
|
e3c68b |
|
|
|
e3c68b |
process = subprocess.Popen(["gluster", "--print-logdir"],
|
|
|
e3c68b |
- stdout=subprocess.PIPE)
|
|
|
e3c68b |
+ stdout=subprocess.PIPE, universal_newlines=True)
|
|
|
e3c68b |
logfile = os.path.join(process.stdout.read()[:-1], SCRIPT_NAME + ".log")
|
|
|
e3c68b |
|
|
|
e3c68b |
fh = logging.FileHandler(logfile)
|
|
|
e3c68b |
diff --git a/tests/basic/volume-snap-scheduler.t b/tests/basic/volume-snap-scheduler.t
|
|
|
e3c68b |
new file mode 100644
|
|
|
e3c68b |
index 0000000..a638c5c
|
|
|
e3c68b |
--- /dev/null
|
|
|
e3c68b |
+++ b/tests/basic/volume-snap-scheduler.t
|
|
|
e3c68b |
@@ -0,0 +1,49 @@
|
|
|
e3c68b |
+#!/bin/bash
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+. $(dirname $0)/../include.rc
|
|
|
e3c68b |
+. $(dirname $0)/../volume.rc
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+cleanup;
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST glusterd;
|
|
|
e3c68b |
+TEST pidof glusterd;
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${GMV0}{1,2,3,4};
|
|
|
e3c68b |
+TEST $CLI volume start $V0
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+## Create, start and mount meta_volume as
|
|
|
e3c68b |
+## snap_scheduler expects shared storage to be enabled.
|
|
|
e3c68b |
+## This test is very basic in nature not creating any snapshot
|
|
|
e3c68b |
+## and purpose is to validate snap scheduling commands.
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST $CLI volume create $META_VOL replica 3 $H0:$B0/${META_VOL}{1,2,3};
|
|
|
e3c68b |
+TEST $CLI volume start $META_VOL
|
|
|
e3c68b |
+TEST mkdir -p $META_MNT
|
|
|
e3c68b |
+TEST glusterfs -s $H0 --volfile-id $META_VOL $META_MNT
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+##function to check status
|
|
|
e3c68b |
+function check_status_scheduler()
|
|
|
e3c68b |
+{
|
|
|
e3c68b |
+ local key=$1
|
|
|
e3c68b |
+ snap_scheduler.py status | grep -F "$key" | wc -l
|
|
|
e3c68b |
+}
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+##Basic snap_scheduler command test init/enable/disable/list
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST snap_scheduler.py init
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST snap_scheduler.py enable
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+EXPECT 1 check_status_scheduler "Enabled"
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST snap_scheduler.py disable
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+EXPECT 1 check_status_scheduler "Disabled"
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST snap_scheduler.py list
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST $CLI volume stop $V0;
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+TEST $CLI volume delete $V0;
|
|
|
e3c68b |
+
|
|
|
e3c68b |
+cleanup;
|
|
|
e3c68b |
--
|
|
|
e3c68b |
1.8.3.1
|
|
|
e3c68b |
|