|
13 | 13 | # under the License.
|
14 | 14 |
|
15 | 15 | import copy
|
| 16 | +import datetime |
16 | 17 | import functools
|
17 | 18 | import re
|
| 19 | +import time |
18 | 20 | from unittest import mock
|
19 | 21 |
|
20 | 22 | import netaddr
|
@@ -1054,6 +1056,25 @@ def test_agent_show(self):
|
1054 | 1056 | for agent_id in self.agent_types.values():
|
1055 | 1057 | self.assertTrue(self.plugin.get_agent(self.context, agent_id))
|
1056 | 1058 |
|
| 1059 | + def test_agent_show_real_heartbeat_timestamp(self): |
| 1060 | + agent_id = self.agent_types[ovn_const.OVN_CONTROLLER_AGENT] |
| 1061 | + agent = self.plugin.get_agent(self.context, agent_id) |
| 1062 | + heartbeat_timestamp = agent['heartbeat_timestamp'] |
| 1063 | + if self.sb_api.is_table_present('Chassis_Private'): |
| 1064 | + chassis_ts = self.sb_api.db_get( |
| 1065 | + 'Chassis_Private', self.chassis, 'nb_cfg_timestamp' |
| 1066 | + ).execute(check_error=True) |
| 1067 | + updated_at = datetime.datetime.fromtimestamp( |
| 1068 | + int(chassis_ts / 1000), datetime.timezone.utc) |
| 1069 | + # if table Chassis_Private present, agent.updated_at is |
| 1070 | + # Chassis_Private.nb_cfg_timestamp |
| 1071 | + self.assertEqual(updated_at, heartbeat_timestamp) |
| 1072 | + time.sleep(1) |
| 1073 | + # if chassis is not updated, agent's heartbeat_timestamp shouldn't |
| 1074 | + # be updated. |
| 1075 | + n_agent = self.plugin.get_agent(self.context, agent['id']) |
| 1076 | + self.assertEqual(heartbeat_timestamp, n_agent['heartbeat_timestamp']) |
| 1077 | + |
1057 | 1078 | def test_agent_list(self):
|
1058 | 1079 | agent_ids = [a['id'] for a in self.plugin.get_agents(
|
1059 | 1080 | self.context, filters={'host': self.host})]
|
|
0 commit comments