mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-06-15 02:22:06 +03:00
close open filehandles. more tests
This commit is contained in:
parent
2305fdf033
commit
138c913e58
@ -1,3 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import random
|
import random
|
||||||
|
|
||||||
@ -9,6 +11,8 @@ from pprint import *
|
|||||||
from bin.zfs_autobackup import *
|
from bin.zfs_autobackup import *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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(cmd , shell=True).decode('utf-8'))
|
||||||
|
@ -435,12 +435,16 @@ class ExecuteNode(Logger):
|
|||||||
if p.poll()!=None and ((not isinstance(input, subprocess.Popen)) or input.poll()!=None) and eof_count==len(selectors):
|
if p.poll()!=None and ((not isinstance(input, subprocess.Popen)) or input.poll()!=None) and eof_count==len(selectors):
|
||||||
break
|
break
|
||||||
|
|
||||||
|
p.stderr.close()
|
||||||
|
p.stdout.close()
|
||||||
|
|
||||||
if self.debug_output:
|
if self.debug_output:
|
||||||
self.debug("EXIT > {}".format(p.returncode))
|
self.debug("EXIT > {}".format(p.returncode))
|
||||||
|
|
||||||
#handle piped process error output and exit codes
|
#handle piped process error output and exit codes
|
||||||
if isinstance(input, subprocess.Popen):
|
if isinstance(input, subprocess.Popen):
|
||||||
|
input.stderr.close()
|
||||||
|
input.stdout.close()
|
||||||
|
|
||||||
if self.debug_output:
|
if self.debug_output:
|
||||||
self.debug("EXIT |> {}".format(input.returncode))
|
self.debug("EXIT |> {}".format(input.returncode))
|
||||||
@ -450,7 +454,6 @@ class ExecuteNode(Logger):
|
|||||||
if valid_exitcodes and p.returncode not in valid_exitcodes:
|
if valid_exitcodes and p.returncode not in valid_exitcodes:
|
||||||
raise(subprocess.CalledProcessError(p.returncode, encoded_cmd))
|
raise(subprocess.CalledProcessError(p.returncode, encoded_cmd))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if return_stderr:
|
if return_stderr:
|
||||||
return ( output_lines, error_lines )
|
return ( output_lines, error_lines )
|
||||||
|
@ -9,7 +9,7 @@ fi
|
|||||||
source $VIRTUAL_ENV/bin/activate || true
|
source $VIRTUAL_ENV/bin/activate || true
|
||||||
|
|
||||||
# test needs ssh access to localhost for testing
|
# test needs ssh access to localhost for testing
|
||||||
if ! [ -t /root/.ssh/id_rsa ]; then
|
if ! [ -e /root/.ssh/id_rsa ]; then
|
||||||
ssh-keygen -t rsa -f /root/.ssh/id_rsa -P '' || exit 1
|
ssh-keygen -t rsa -f /root/.ssh/id_rsa -P '' || exit 1
|
||||||
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys || exit 1
|
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys || exit 1
|
||||||
ssh -oStrictHostKeyChecking=no localhost true || exit 1
|
ssh -oStrictHostKeyChecking=no localhost true || exit 1
|
||||||
@ -22,7 +22,9 @@ echo
|
|||||||
coverage report
|
coverage report
|
||||||
|
|
||||||
#this does automatic travis CI/https://coveralls.io/ intergration:
|
#this does automatic travis CI/https://coveralls.io/ intergration:
|
||||||
echo "Submitting to coveralls.io:"
|
if which coveralls > /dev/null; then
|
||||||
coveralls
|
echo "Submitting to coveralls.io:"
|
||||||
|
coveralls
|
||||||
|
fi
|
||||||
|
|
||||||
exit $EXIT
|
exit $EXIT
|
||||||
|
11
test_zfsautobackup.py
Normal file
11
test_zfsautobackup.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from basetest import *
|
||||||
|
|
||||||
|
|
||||||
|
class TestZfsAutobackup(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
prepare_zpools()
|
||||||
|
return super().setUp()
|
||||||
|
|
||||||
|
def test_defaults(self):
|
||||||
|
self.assertFalse(ZfsAutobackup("test test_target1".split(" ")).run())
|
Loading…
x
Reference in New Issue
Block a user