The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/pylxd/pull/68
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Fix integration test suite.
From 70fb32b4502f838917e0d635c223b647a54dd2e6 Mon Sep 17 00:00:00 2001 From: Chuck Short <chuck.sh...@canonical.com> Date: Sun, 6 Mar 2016 16:11:04 -0500 Subject: [PATCH 1/6] Fix marhsalling error when integration tests LXD was expecting a string rather than an integer Signed-off-by: Chuck Short <chuck.sh...@canonical.com> --- integration/test_containers.py | 2 +- integration/testing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index d72d4fb..97f186d 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -40,7 +40,7 @@ def test_create(self): """Creates and returns a new container.""" config = { 'name': 'an-container', - 'architecture': 2, + 'architecture': 'x86_64', 'profiles': ['default'], 'ephemeral': True, 'config': {'limits.cpu': '2'}, diff --git a/integration/testing.py b/integration/testing.py index e6e3cfe..20d40dd 100644 --- a/integration/testing.py +++ b/integration/testing.py @@ -37,7 +37,7 @@ def create_container(self): name = self.generate_object_name() machine = { 'name': name, - 'architecture': 2, + 'architecture': 'x86_64', 'profiles': ['default'], 'ephemeral': False, 'config': {'limits.cpu': '2'}, From 0c7de6271d24e973f3614d77ee48b96c9b2885df Mon Sep 17 00:00:00 2001 From: Chuck Short <chuck.sh...@canonical.com> Date: Sun, 6 Mar 2016 16:12:54 -0500 Subject: [PATCH 2/6] Delete container after test Delete the container after checking container name. Signed-off-by: Chuck Short <chuck.sh...@canonical.com> --- integration/test_containers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index 97f186d..5b4ee02 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -20,11 +20,12 @@ class TestContainers(IntegrationTestCase): def test_get(self): """A container is fetched by name.""" name = self.create_container() - self.addCleanup(self.delete_container, name) container = self.client.containers.get(name) self.assertEqual(name, container.name) + self.addCleanup(self.delete_container, name) + def test_all(self): """A list of all containers is returned.""" From c6b5ddca87a639cb8f3d31da657e06524a5eedc8 Mon Sep 17 00:00:00 2001 From: Chuck Short <chuck.sh...@canonical.com> Date: Sun, 6 Mar 2016 16:15:14 -0500 Subject: [PATCH 3/6] Fix test_create Create an image to use when running test_create integration test. Signed-off-by: Chuck Short <chuck.sh...@canonical.com> --- integration/test_containers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index 5b4ee02..e3ef3e3 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -39,6 +39,7 @@ def test_all(self): def test_create(self): """Creates and returns a new container.""" + fingerprint, alias = self.create_image() config = { 'name': 'an-container', 'architecture': 'x86_64', @@ -46,13 +47,13 @@ def test_create(self): 'ephemeral': True, 'config': {'limits.cpu': '2'}, 'source': {'type': 'image', - 'alias': 'busybox'}, + 'alias': alias}, } - self.addCleanup(self.delete_container, config['name']) - container = self.client.containers.create(config, wait=True) self.assertEqual(config['name'], container.name) + self.addCleanup(self.delete_container, config['name']) + self.addCleanup(self.delete_image, fingerprint) class TestContainer(IntegrationTestCase): From ffa997d7b2e3c84dd39f8b97d20477fd4c1ec1e3 Mon Sep 17 00:00:00 2001 From: Chuck Short <chuck.sh...@canonical.com> Date: Sun, 6 Mar 2016 16:17:06 -0500 Subject: [PATCH 4/6] Move test_delete Move to the last test so that it will delete the container. Signed-off-by: Chuck Short <chuck.sh...@canonical.com> --- integration/test_containers.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index e3ef3e3..0538d34 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -86,13 +86,6 @@ def test_rename(self): container = self.client.containers.get(name) self.assertEqual(name, container.name) - def test_delete(self): - """The container is deleted.""" - self.container.delete(wait=True) - - self.assertRaises( - NameError, self.client.containers.get, self.container.name) - def test_start_stop(self): """The container is started and then stopped.""" # NOTE: rockstar (15 Feb 2016) - I don't care for the @@ -147,3 +140,10 @@ def test_execute(self): self.addCleanup(self.container.stop, wait=True) self.container.execute('ls /') + + def test_delete(self): + """The container is delete.""" + self.container.delete(wait=True) + + self.assertRaises( + NameError, self.client.containers.get, self.container.name) From a44fee8f446d1b27b0445e03adddadf2b7ec4a67 Mon Sep 17 00:00:00 2001 From: Chuck Short <chuck.sh...@canonical.com> Date: Sun, 6 Mar 2016 16:18:59 -0500 Subject: [PATCH 5/6] Fix integration test Signed-off-by: Chuck Short <chuck.sh...@canonical.com> --- integration/test_containers.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/test_containers.py b/integration/test_containers.py index 0538d34..83e93a1 100644 --- a/integration/test_containers.py +++ b/integration/test_containers.py @@ -93,15 +93,15 @@ def test_start_stop(self): # to test what we need. self.container.start(wait=True) - self.assertEqual('Running', self.container.status['status']) + self.assertEqual('Running', self.container.status) container = self.client.containers.get(self.container.name) - self.assertEqual('Running', container.status['status']) + self.assertEqual('Running', container.status) self.container.stop(wait=True) - self.assertEqual('Stopped', self.container.status['status']) + self.assertEqual('Stopped', self.container.status) container = self.client.containers.get(self.container.name) - self.assertEqual('Stopped', container.status['status']) + self.assertEqual('Stopped', container.status) def test_snapshot(self): """A container snapshot is made, renamed, and deleted.""" From a7dae2ec218d23730373eecd40123e6382d47fa5 Mon Sep 17 00:00:00 2001 From: Chuck Short <chuck.sh...@canonical.com> Date: Sun, 6 Mar 2016 17:07:00 -0500 Subject: [PATCH 6/6] Fix exception assertion KeyError rather than NameError since the profile doesnt exist. Signed-off-by: Chuck Short <chuck.sh...@canonical.com> --- integration/test_profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test_profiles.py b/integration/test_profiles.py index f5f1e00..35edc85 100644 --- a/integration/test_profiles.py +++ b/integration/test_profiles.py @@ -84,4 +84,4 @@ def test_delete(self): self.profile.delete() self.assertRaises( - NameError, self.client.profiles.get, self.profile.name) + KeyError, self.client.profiles.get, self.profile.name)
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel