allow regression to run from pycharm by using sudo with passwd file. you also need to suid root zfs and zpool

This commit is contained in:
Edwin Eefting 2021-04-15 13:56:24 +02:00
parent db6523f3c0
commit a920744b1e
5 changed files with 6 additions and 6 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ __pycache__
python2.env python2.env
venv venv
.idea .idea
password.sh

View File

@ -1,6 +1,6 @@
colorama colorama
argparse argparse
coverage==4.5.4 coverage
python-coveralls python-coveralls
unittest2 unittest2
mock mock

View File

@ -58,7 +58,8 @@ def redirect_stderr(target):
def shelltest(cmd): def shelltest(cmd):
"""execute and print result as nice copypastable string for unit tests (adds extra newlines on top/bottom)""" """execute and print result as nice copypastable string for unit tests (adds extra newlines on top/bottom)"""
ret=(subprocess.check_output(cmd , shell=True).decode('utf-8'))
ret=(subprocess.check_output("SUDO_ASKPASS=./password.sh sudo -A "+cmd , shell=True).decode('utf-8'))
print("######### result of: {}".format(cmd)) print("######### result of: {}".format(cmd))
print(ret) print(ret)
print("#########") print("#########")

View File

@ -2,7 +2,6 @@ from basetest import *
import time import time
class TestZfsAutobackup(unittest2.TestCase): class TestZfsAutobackup(unittest2.TestCase):
def setUp(self): def setUp(self):
@ -696,8 +695,8 @@ test_target1
#test incremental #test incremental
with patch('time.strftime', return_value="20101111000000"): with patch('time.strftime', return_value="20101111000002"):
self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --verbose --test".split(" ")).run()) self.assertFalse(ZfsAutobackup("test test_target1 --no-progress --allow-empty --verbose --test".split(" ")).run())
r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS) r=shelltest("zfs list -H -o name -r -t all "+TEST_POOLS)
self.assertMultiLineEqual(r,""" self.assertMultiLineEqual(r,"""

View File

@ -42,7 +42,6 @@ class ThinnerRule:
if '' in matches: if '' in matches:
raise (Exception("Invalid schedule string: '{}'".format(rule_str))) raise (Exception("Invalid schedule string: '{}'".format(rule_str)))
print(matches)
period_amount = int(matches[0]) period_amount = int(matches[0])
period_unit = matches[1] period_unit = matches[1]
ttl_amount = int(matches[2]) ttl_amount = int(matches[2])