diff options
author | Jhon Honce <jhonce@redhat.com> | 2018-07-27 15:09:07 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-05 11:06:18 +0000 |
commit | 47620961fe8eb9ec859b33bd0480a698e655af69 (patch) | |
tree | bf16c8cbed80701c54971a2b420066607c973536 /contrib/python/podman/test | |
parent | a1e3e542fff562d885354c55f04e0b7f5097a39b (diff) | |
download | podman-47620961fe8eb9ec859b33bd0480a698e655af69.tar.gz podman-47620961fe8eb9ec859b33bd0480a698e655af69.tar.bz2 podman-47620961fe8eb9ec859b33bd0480a698e655af69.zip |
Port to MacOS
* Refactor Tunnel to support selecting port for remote sshd
* Refactor ssh tunnel to support MacOS version of ssh
* Refactor Tunnel.close() to find and kill off zombie siblings
* Add psutil dependency
* Add logging setup, letting library produce debugging records
* Clean up Tunnel API
* Fix test_runner.sh to propagate returncode to caller
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Closes: #1199
Approved by: rhatdan
Diffstat (limited to 'contrib/python/podman/test')
-rw-r--r-- | contrib/python/podman/test/test_client.py | 2 | ||||
-rwxr-xr-x | contrib/python/podman/test/test_runner.sh | 25 | ||||
-rw-r--r-- | contrib/python/podman/test/test_system.py | 4 | ||||
-rw-r--r-- | contrib/python/podman/test/test_tunnel.py | 11 |
4 files changed, 25 insertions, 17 deletions
diff --git a/contrib/python/podman/test/test_client.py b/contrib/python/podman/test/test_client.py index 2abc60a24..d36cb1a43 100644 --- a/contrib/python/podman/test/test_client.py +++ b/contrib/python/podman/test/test_client.py @@ -28,7 +28,7 @@ class TestClient(unittest.TestCase): p = Client( uri='unix:/run/podman', interface='io.projectatomic.podman', - remote_uri='ssh://user@hostname/run/podmain/podman', + remote_uri='ssh://user@hostname/run/podman/podman', identity_file='~/.ssh/id_rsa') self.assertIsInstance(p._client, BaseClient) diff --git a/contrib/python/podman/test/test_runner.sh b/contrib/python/podman/test/test_runner.sh index b3d2ba15b..4771709ff 100755 --- a/contrib/python/podman/test/test_runner.sh +++ b/contrib/python/podman/test/test_runner.sh @@ -19,9 +19,9 @@ function usage { while getopts "vh" arg; do case $arg in - v ) VERBOSE='-v' ;; - h ) usage ; exit 0;; - \? ) usage ; exit 2;; + v ) VERBOSE='-v'; export LOG_LEVEL=debug ;; + h ) usage ; exit 0 ;; + \? ) usage ; exit 2 ;; esac done shift $((OPTIND -1)) @@ -113,29 +113,36 @@ PODMAN_ARGS="--storage-driver=vfs \ --cni-config-dir=$CNI_CONFIG_PATH \ " if [[ -n $VERBOSE ]]; then - PODMAN_ARGS="$PODMAN_ARGS --log-level=debug" + PODMAN_ARGS="$PODMAN_ARGS --log-level=$LOG_LEVEL" fi PODMAN="podman $PODMAN_ARGS" -# document what we're about to do... -$PODMAN --version +# Run podman in background without systemd for test purposes +cat >/tmp/test_podman.output <<-EOT +$($PODMAN --version) +$PODMAN varlink --timeout=0 ${PODMAN_HOST} +========================================== +EOT set -x -# Run podman in background without systemd for test purposes -$PODMAN varlink --timeout=0 ${PODMAN_HOST} >/tmp/test_runner.output 2>&1 & +$PODMAN varlink --timeout=0 ${PODMAN_HOST} >>/tmp/test_podman.output 2>&1 & if [[ -z $1 ]]; then export PYTHONPATH=. python3 -m unittest discover -s . $VERBOSE + RETURNCODE=$? else export PYTHONPATH=.:./test python3 -m unittest $1 $VERBOSE + RETURNCODE=$? fi set +x pkill -9 podman pkill -9 conmon -showlog /tmp/test_runner.output +showlog /tmp/test_podman.output showlog /tmp/alpine.log showlog /tmp/busybox.log + +exit $RETURNCODE diff --git a/contrib/python/podman/test/test_system.py b/contrib/python/podman/test/test_system.py index 3f6ca57a2..2b1342f8a 100644 --- a/contrib/python/podman/test/test_system.py +++ b/contrib/python/podman/test/test_system.py @@ -25,7 +25,7 @@ class TestSystem(unittest.TestCase): def test_remote_ping(self): host = urlparse(self.host) - remote_uri = 'ssh://root@localhost/{}'.format(host.path) + remote_uri = 'ssh://root@localhost{}'.format(host.path) local_uri = 'unix:{}/tunnel/podman.sock'.format(self.tmpdir) with podman.Client( @@ -33,7 +33,7 @@ class TestSystem(unittest.TestCase): remote_uri=remote_uri, identity_file=os.path.expanduser('~/.ssh/id_rsa'), ) as remote_client: - remote_client.system.ping() + self.assertTrue(remote_client.system.ping()) def test_versions(self): with podman.Client(self.host) as pclient: diff --git a/contrib/python/podman/test/test_tunnel.py b/contrib/python/podman/test/test_tunnel.py index 719a2f9a4..ed23fd905 100644 --- a/contrib/python/podman/test/test_tunnel.py +++ b/contrib/python/podman/test/test_tunnel.py @@ -4,7 +4,6 @@ import time import unittest from unittest.mock import MagicMock, patch -import podman from podman.libs.tunnel import Context, Portal, Tunnel @@ -60,20 +59,22 @@ class TestTunnel(unittest.TestCase): '/run/podman/socket', 'user', 'hostname', + None, '~/.ssh/id_rsa', ) - tunnel = Tunnel(context).bore('unix:/01') + tunnel = Tunnel(context).bore() cmd = [ 'ssh', - '-fNTq', + '-fNT', + '-q', '-L', '{}:{}'.format(context.local_socket, context.remote_socket), '-i', context.identity_file, - 'ssh://{}@{}'.format(context.username, context.hostname), + '{}@{}'.format(context.username, context.hostname), ] - mock_finalize.assert_called_once_with(tunnel, tunnel.close, 'unix:/01') + mock_finalize.assert_called_once_with(tunnel, tunnel.close) mock_exists.assert_called_once_with(context.local_socket) mock_Popen.assert_called_once_with(cmd, close_fds=True) |