Fix flaky test_create_deployment and test_create_service tests

They were failing because test_deploy.TestDeployCreateService wasn't
properly unmocking mocked create_object_from_definition. Anyhow tearDown
is evil, tearDown with testtools works badly, we should use addCleanup
instead and using fixtures is even better than that.

To reproduce bug and verify that this patch fixes it, add

    test_run_concurrency=echo 1

to .testr.conf, it'll run all tests in one process sequentially.

Tests were flaky because testr randomly splits list of tests across
processes (yay, test reprocudibility!) and sometimes
TestDeployCreateService wasn't run in the same process as failing tests.

Change-Id: I60beb43d5ab540e232f2f664212f86036d473cc6
This commit is contained in:
Yuriy Taraday 2016-09-03 09:47:52 +03:00 committed by Eric Lemoine
parent 9324199cb9
commit 4f9c75b4a4
2 changed files with 5 additions and 7 deletions

View File

@ -1,6 +1,7 @@
import filecmp
import os
import fixtures
import mock
from oslo_config import cfg
import yaml
@ -145,9 +146,9 @@ class TestDeploy(base.TestCase):
class TestDeployCreateService(base.TestCase):
def setUp(self):
super(TestDeployCreateService, self).setUp()
self._create_obj = mock.patch(
"fuel_ccp.kubernetes.create_object_from_definition")
self.create_obj = self._create_obj.start()
fixture = self.useFixture(fixtures.MockPatch(
"fuel_ccp.kubernetes.create_object_from_definition"))
self.create_obj = fixture.mock
def test_create_service_without_ports(self):
deploy._create_service({"name": "spam"}, {})
@ -219,10 +220,6 @@ spec:
deploy._create_service(service, defaults)
self.create_obj.assert_called_once_with(yaml.load(service_k8s_obj))
def teadDown(self):
super(TestDeployCreateService, self).teadDown()
self._create_obj.stop()
class TestDeployParseWorkflow(base.TestCase):
def test_parse_workflow(self):

View File

@ -5,6 +5,7 @@
hacking<0.11,>=0.10.0
coverage>=3.6
fixtures>=3.0.0 # Apache-2.0/BSD
python-subunit>=0.0.18
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
oslosphinx>=2.5.0 # Apache-2.0