Skip to content

Commit 177a6b3

Browse files
committed
tests: Explicitly specify network agent fields for output
Rather than dynamically discovering columns from the SDK resource using get_osc_show_columns_for_sdk_resource, explicitly list the fields we want to display. This prevents new fields added to the SDK Agent resource from automatically appearing in the output and breaking cross-project tests. This patch is adding the field ``ha_chassis_priority``, related to the mentioned bug. This follows the same pattern applied to ports in change [1]. [1]https://review.opendev.org/c/openstack/python-openstackclient/+/894510 Related-Bug: #2103521 Signed-off-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com> Change-Id: Ie783a5431dbf61c4140333a76ee89714841ab1b6
1 parent b031b7d commit 177a6b3

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

openstackclient/network/v2/network_agent.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,27 @@ def human_readable(self):
4646

4747

4848
def _get_network_columns(item):
49-
column_map = {
50-
'is_admin_state_up': 'admin_state_up',
51-
'is_alive': 'alive',
49+
column_data_mapping = {
50+
'admin_state_up': 'is_admin_state_up',
51+
'agent_type': 'agent_type',
52+
'alive': 'is_alive',
53+
'availability_zone': 'availability_zone',
54+
'binary': 'binary',
55+
'configuration': 'configuration',
56+
'created_at': 'created_at',
57+
'description': 'description',
58+
'ha_chassis_priority': 'ha_chassis_priority',
59+
'ha_state': 'ha_state',
60+
'host': 'host',
61+
'id': 'id',
62+
'last_heartbeat_at': 'last_heartbeat_at',
63+
'resources_synced': 'resources_synced',
64+
'started_at': 'started_at',
65+
'topic': 'topic',
5266
}
53-
hidden_columns = ['location', 'name', 'tenant_id']
54-
return utils.get_osc_show_columns_for_sdk_resource(
55-
item, column_map, hidden_columns
67+
return (
68+
tuple(column_data_mapping.keys()),
69+
tuple(column_data_mapping.values()),
5670
)
5771

5872

openstackclient/tests/unit/network/v2/test_network_agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,9 @@ class TestShowNetworkAgent(TestNetworkAgent):
541541
'configuration',
542542
'created_at',
543543
'description',
544-
'host',
544+
'ha_chassis_priority',
545545
'ha_state',
546+
'host',
546547
'id',
547548
'last_heartbeat_at',
548549
'resources_synced',
@@ -558,6 +559,9 @@ class TestShowNetworkAgent(TestNetworkAgent):
558559
format_columns.DictColumn(_network_agent.configuration),
559560
_network_agent.created_at,
560561
_network_agent.description,
562+
# NOTE(ralonsoh): `ha_chassis_priority` column is still not supported
563+
# by the API. See LP#2103521.
564+
None,
561565
_network_agent.ha_state,
562566
_network_agent.host,
563567
_network_agent.id,
@@ -601,5 +605,5 @@ def test_show_all_options(self):
601605
self.network_client.get_agent.assert_called_once_with(
602606
self._network_agent.id
603607
)
604-
self.assertEqual(set(self.columns), set(columns))
608+
self.assertCountEqual(self.columns, columns)
605609
self.assertEqual(len(list(self.data)), len(list(data)))

0 commit comments

Comments
 (0)