Use PostgreSQL setup provided by OpenStack Infra
Since commit Id65b7e106d62be92467c18bcb93c9d5da716242f we do not need to setup PostgreSQL for tests. Now OpenStack Infra provides ready to use PostgreSQL installation as well as MySQL. This commit stops running setup code and unblocks gate tests on OpenStack CI. Also, it fixes random failures of test_force_redeploy_changes. The test used to consume fake threads, and to check status of created task. That status might be different and depends on progress of fake threads (it might be pending, running or even ready). That commit removes usage of fake threads and improves its quality by checking not only task status, but actualy deployment data. Also, it fixes test_assign_given_vips_for_net_groups. The motivation behind that all-in-one commit is that it's almost impossible to fix CI due to random test failures. It's the only choice to get it work. Closes-Bug: #1554038 Change-Id: I074a2cb4f0e6647c605c8e4449a5beca0c6e9bbc
This commit is contained in:
parent
fe8164f38d
commit
73dcf257d1
|
@ -1825,10 +1825,16 @@ class TestHandlers(BaseIntegrationTest):
|
|||
supertask = self.env.launch_deployment()
|
||||
self.env.wait_ready(supertask, timeout=60)
|
||||
|
||||
@fake_tasks()
|
||||
def test_force_redeploy_changes(self):
|
||||
@patch('nailgun.task.manager.rpc.cast')
|
||||
def test_force_redeploy_changes(self, mcast):
|
||||
self.env.create(
|
||||
nodes_kwargs=[{'name': '', 'pending_addition': True}]
|
||||
nodes_kwargs=[
|
||||
{'status': consts.NODE_STATUSES.ready},
|
||||
{'status': consts.NODE_STATUSES.ready},
|
||||
],
|
||||
cluster_kwargs={
|
||||
'status': consts.CLUSTER_STATUSES.operational
|
||||
},
|
||||
)
|
||||
|
||||
def _send_request(handler):
|
||||
|
@ -1841,10 +1847,6 @@ class TestHandlers(BaseIntegrationTest):
|
|||
expect_errors=True
|
||||
)
|
||||
|
||||
# Initial deployment
|
||||
task = self.env.launch_deployment()
|
||||
self.env.wait_ready(task, timeout=60)
|
||||
|
||||
# Trying to redeploy on cluster in the operational state
|
||||
resp = _send_request('ClusterChangesHandler')
|
||||
self.assertEqual(resp.status_code, 400)
|
||||
|
@ -1853,7 +1855,18 @@ class TestHandlers(BaseIntegrationTest):
|
|||
# Trying to force redeploy on cluster in the operational state
|
||||
resp = _send_request('ClusterChangesForceRedeployHandler')
|
||||
self.assertEqual(resp.status_code, 202)
|
||||
|
||||
# Test task is created
|
||||
self.assertEqual(resp.json_body.get('name'),
|
||||
consts.TASK_NAMES.deploy)
|
||||
self.assertEqual(resp.json_body.get('status'),
|
||||
consts.TASK_STATUSES.pending)
|
||||
|
||||
# Test message is sent
|
||||
args, _ = mcast.call_args_list[0]
|
||||
deployment_info = args[1][0]['args']['deployment_info']
|
||||
|
||||
self.assertItemsEqual(
|
||||
[node.uid for node in self.env.nodes],
|
||||
[node['uid'] for node in deployment_info]
|
||||
)
|
||||
|
|
|
@ -629,14 +629,6 @@ class TestNetworkManager(BaseIntegrationTest):
|
|||
self.assertEqual(vips_to_create, vips)
|
||||
|
||||
def test_assign_given_vips_for_net_groups(self):
|
||||
vips_to_create = {
|
||||
consts.NETWORKS.management: {
|
||||
consts.NETWORK_VIP_NAMES_V6_1.haproxy: '192.168.0.1',
|
||||
},
|
||||
consts.NETWORKS.public: {
|
||||
consts.NETWORK_VIP_NAMES_V6_1.haproxy: '172.16.0.2',
|
||||
},
|
||||
}
|
||||
vips_to_assign = {
|
||||
consts.NETWORKS.management: {
|
||||
consts.NETWORK_VIP_NAMES_V6_1.haproxy: '192.168.0.1',
|
||||
|
@ -648,7 +640,6 @@ class TestNetworkManager(BaseIntegrationTest):
|
|||
},
|
||||
}
|
||||
cluster = self.env.create_cluster(api=False)
|
||||
self.env.create_ip_addrs_by_rules(cluster, vips_to_create)
|
||||
self.env.network_manager.assign_given_vips_for_net_groups(
|
||||
cluster, vips_to_assign)
|
||||
vips = self.env.network_manager.get_assigned_vips(cluster)
|
||||
|
|
|
@ -674,21 +674,30 @@ class TestTaskManagers(BaseIntegrationTest):
|
|||
manager_ = manager.ApplyChangesTaskManager(cluster_db.id)
|
||||
self.assertRaises(errors.WrongNodeStatus, manager_.execute)
|
||||
|
||||
@fake_tasks()
|
||||
def test_force_deploy_changes(self):
|
||||
@mock.patch('nailgun.task.manager.rpc.cast')
|
||||
def test_force_deploy_changes(self, mcast):
|
||||
self.env.create(
|
||||
nodes_kwargs=[
|
||||
{"status": NODE_STATUSES.ready}
|
||||
]
|
||||
{'status': NODE_STATUSES.ready},
|
||||
{'status': NODE_STATUSES.ready},
|
||||
],
|
||||
cluster_kwargs={
|
||||
'status': consts.CLUSTER_STATUSES.operational
|
||||
},
|
||||
)
|
||||
cluster_db = self.env.clusters[0]
|
||||
objects.Cluster.clear_pending_changes(cluster_db)
|
||||
manager_ = manager.ApplyChangesForceTaskManager(cluster_db.id)
|
||||
supertask = manager_.execute()
|
||||
self.assertEqual(supertask.name, TASK_NAMES.deploy)
|
||||
self.assertIn(supertask.status, (TASK_STATUSES.pending,
|
||||
TASK_STATUSES.running,
|
||||
TASK_STATUSES.ready))
|
||||
self.assertIn(supertask.status, TASK_STATUSES.pending)
|
||||
|
||||
args, _ = mcast.call_args_list[0]
|
||||
deployment_info = args[1][0]['args']['deployment_info']
|
||||
self.assertItemsEqual(
|
||||
[node.uid for node in self.env.nodes],
|
||||
[node['uid'] for node in deployment_info]
|
||||
)
|
||||
|
||||
@fake_tasks()
|
||||
@mock.patch('nailgun.task.manager.tasks.DeletionTask.execute')
|
||||
|
|
1
tox.ini
1
tox.ini
|
@ -44,7 +44,6 @@ passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
|
|||
deps = -r{toxinidir}/nailgun/test-requirements.txt
|
||||
commands =
|
||||
bash -c "{[base]TOOLS}/env.sh prepare_nailgun_env"
|
||||
bash -c "{[base]TOOLS}/env.sh prepare_nailgun_database"
|
||||
py.test -vv --cleandb --junit-xml {toxinidir}/nailgun/nailgun.xml -m 'not performance' -n 4 {posargs:nailgun/test}
|
||||
py.test -vv --junit-xml {toxinidir}/nailgun/extensions.xml {posargs:nailgun/extensions}
|
||||
|
||||
|
|
Loading…
Reference in New Issue