[lxc-devel] [pylxd/master] Remove broken migration tests and fix cert discovery
ajkavanagh on Github
lxc-bot at linuxcontainers.org
Thu Dec 20 16:16:21 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 686 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181220/02ce824b/attachment.bin>
-------------- next part --------------
From 8b1c42041904876c2b05872e52b1377f45bf36cb Mon Sep 17 00:00:00 2001
From: Alex Kavanagh <alex.kavanagh at canonical.com>
Date: Thu, 20 Dec 2018 16:11:37 +0000
Subject: [PATCH] Remove broken migration tests and fix cert discovery
The migration tests merged as part of the migration code (commit
ad07da988082249dfbffc27f02b422a93c19e765) are basically broken; the
actual code is fine / this commit removes those tests (skips) so that CI
can continue.
The second part is improving the cert discovery for the client which is
broken if 'lxd.migrate' is issued on a bionic machine. This tightens
the discovery.
---
integration/test_containers.py | 5 +++++
pylxd/client.py | 14 +++++++++-----
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/integration/test_containers.py b/integration/test_containers.py
index 0bf1a5a4..e00adf86 100644
--- a/integration/test_containers.py
+++ b/integration/test_containers.py
@@ -11,6 +11,8 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
+import unittest
+
from pylxd import exceptions
from integration.testing import IntegrationTestCase
@@ -208,6 +210,7 @@ def test_publish(self):
# This test is commented because CRIU does NOT work
# in LXD inside LXD
+ @unittest.skip("This test is broken as it assumes particular network")
def test_migrate_running(self):
"""A running container is migrated."""
from pylxd.client import Client
@@ -231,6 +234,7 @@ def test_migrate_running(self):
self.assertEqual(client2,
an_migrated_container.client)
+ @unittest.skip("This test is broken as it assumes particular network")
def test_migrate_local_client(self):
"""Raise ValueError, cannot migrate from local connection"""
from pylxd.client import Client
@@ -243,6 +247,7 @@ def test_migrate_local_client(self):
self.assertRaises(ValueError,
self.container.migrate, client2)
+ @unittest.skip("This test is broken as it assumes particular network")
def test_migrate_stopped(self):
"""A stopped container is migrated."""
from pylxd.client import Client
diff --git a/pylxd/client.py b/pylxd/client.py
index c1edf401..1aea09e1 100644
--- a/pylxd/client.py
+++ b/pylxd/client.py
@@ -31,17 +31,21 @@
requests_unixsocket.monkeypatch()
LXD_PATH = '.config/lxc/'
-SNAP_ROOT = '~/snap/lxd/current/'
-APT_ROOT = '~/'
-if os.path.exists(os.path.expanduser(SNAP_ROOT)): # pragma: no cover
+SNAP_ROOT = os.path.expanduser('~/snap/lxd/current/')
+APT_ROOT = os.path.expanduser('~/')
+CERT_FILE_NAME = 'client.crt'
+KEY_FILE_NAME = 'client.key'
+# check that the cert file and key file exist at the appopriate path
+if os.path.exists(os.path.join(
+ SNAP_ROOT, LXD_PATH, CERT_FILE_NAME)): # pragma: no cover
CERTS_PATH = os.path.join(SNAP_ROOT, LXD_PATH) # pragma: no cover
else: # pragma: no cover
CERTS_PATH = os.path.join(APT_ROOT, LXD_PATH) # pragma: no cover
Cert = namedtuple('Cert', ['cert', 'key']) # pragma: no cover
DEFAULT_CERTS = Cert(
- cert=os.path.expanduser(os.path.join(CERTS_PATH, 'client.crt')),
- key=os.path.expanduser(os.path.join(CERTS_PATH, 'client.key'))
+ cert=os.path.expanduser(os.path.join(CERTS_PATH, CERT_FILE_NAME)),
+ key=os.path.expanduser(os.path.join(CERTS_PATH, KEY_FILE_NAME))
) # pragma: no cover
More information about the lxc-devel
mailing list