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
This commit is contained in:
Rodolfo Alonso Hernandez
2026-04-06 13:56:01 +02:00
parent b031b7d9ab
commit 177a6b3460
2 changed files with 26 additions and 8 deletions
+20 -6
View File
@@ -46,13 +46,27 @@ _formatters = {
def _get_network_columns(item):
column_map = {
'is_admin_state_up': 'admin_state_up',
'is_alive': 'alive',
column_data_mapping = {
'admin_state_up': 'is_admin_state_up',
'agent_type': 'agent_type',
'alive': 'is_alive',
'availability_zone': 'availability_zone',
'binary': 'binary',
'configuration': 'configuration',
'created_at': 'created_at',
'description': 'description',
'ha_chassis_priority': 'ha_chassis_priority',
'ha_state': 'ha_state',
'host': 'host',
'id': 'id',
'last_heartbeat_at': 'last_heartbeat_at',
'resources_synced': 'resources_synced',
'started_at': 'started_at',
'topic': 'topic',
}
hidden_columns = ['location', 'name', 'tenant_id']
return utils.get_osc_show_columns_for_sdk_resource(
item, column_map, hidden_columns
return (
tuple(column_data_mapping.keys()),
tuple(column_data_mapping.values()),
)
@@ -541,8 +541,9 @@ class TestShowNetworkAgent(TestNetworkAgent):
'configuration',
'created_at',
'description',
'host',
'ha_chassis_priority',
'ha_state',
'host',
'id',
'last_heartbeat_at',
'resources_synced',
@@ -558,6 +559,9 @@ class TestShowNetworkAgent(TestNetworkAgent):
format_columns.DictColumn(_network_agent.configuration),
_network_agent.created_at,
_network_agent.description,
# NOTE(ralonsoh): `ha_chassis_priority` column is still not supported
# by the API. See LP#2103521.
None,
_network_agent.ha_state,
_network_agent.host,
_network_agent.id,
@@ -601,5 +605,5 @@ class TestShowNetworkAgent(TestNetworkAgent):
self.network_client.get_agent.assert_called_once_with(
self._network_agent.id
)
self.assertEqual(set(self.columns), set(columns))
self.assertCountEqual(self.columns, columns)
self.assertEqual(len(list(self.data)), len(list(data)))