Verify the AMQP Connection idle timeout.
(self)
| 1217 | assert self.snd.session.connection.transport.remote_idle_timeout == 1.0 |
| 1218 | |
| 1219 | def testTimeout(self): |
| 1220 | """ |
| 1221 | Verify the AMQP Connection idle timeout. |
| 1222 | """ |
| 1223 | |
| 1224 | # snd will timeout the Connection if no frame is received within 1000 ticks |
| 1225 | self.snd, self.rcv = self.link("test-link", idle_timeout=[1.0,0]) |
| 1226 | self.c1 = self.snd.session.connection |
| 1227 | self.c2 = self.rcv.session.connection |
| 1228 | self.snd.open() |
| 1229 | self.rcv.open() |
| 1230 | self.pump() |
| 1231 | |
| 1232 | t_snd = self.snd.session.connection.transport |
| 1233 | t_rcv = self.rcv.session.connection.transport |
| 1234 | assert t_rcv.idle_timeout == 0.0 |
| 1235 | # proton advertises 1/2 the timeout (see spec) |
| 1236 | assert t_rcv.remote_idle_timeout == 0.5 |
| 1237 | assert t_snd.idle_timeout == 1.0 |
| 1238 | assert t_snd.remote_idle_timeout == 0.0 |
| 1239 | |
| 1240 | sndr_frames_in = t_snd.frames_input |
| 1241 | rcvr_frames_out = t_rcv.frames_output |
| 1242 | |
| 1243 | # at t+1msec, nothing should happen: |
| 1244 | clock = 0.001 |
| 1245 | assert t_snd.tick(clock) == 1.001, "deadline for remote timeout" |
| 1246 | assert t_rcv.tick(clock) == 0.251, "deadline to send keepalive" |
| 1247 | self.pump() |
| 1248 | assert sndr_frames_in == t_snd.frames_input, "unexpected received frame" |
| 1249 | |
| 1250 | # at one tick from expected idle frame send, nothing should happen: |
| 1251 | clock = 0.250 |
| 1252 | assert t_snd.tick(clock) == 1.001, "deadline for remote timeout" |
| 1253 | assert t_rcv.tick(clock) == 0.251, "deadline to send keepalive" |
| 1254 | self.pump() |
| 1255 | assert sndr_frames_in == t_snd.frames_input, "unexpected received frame" |
| 1256 | |
| 1257 | # this should cause rcvr to expire and send a keepalive |
| 1258 | clock = 0.251 |
| 1259 | assert t_snd.tick(clock) == 1.001, "deadline for remote timeout" |
| 1260 | assert t_rcv.tick(clock) == 0.501, "deadline to send keepalive" |
| 1261 | self.pump() |
| 1262 | sndr_frames_in += 1 |
| 1263 | rcvr_frames_out += 1 |
| 1264 | assert sndr_frames_in == t_snd.frames_input, "unexpected received frame" |
| 1265 | assert rcvr_frames_out == t_rcv.frames_output, "unexpected frame" |
| 1266 | |
| 1267 | # since a keepalive was received, sndr will rebase its clock against this tick: |
| 1268 | # and the receiver should not change its deadline |
| 1269 | clock = 0.498 |
| 1270 | assert t_snd.tick(clock) == 1.498, "deadline for remote timeout" |
| 1271 | assert t_rcv.tick(clock) == 0.501, "deadline to send keepalive" |
| 1272 | self.pump() |
| 1273 | assert sndr_frames_in == t_snd.frames_input, "unexpected received frame" |
| 1274 | |
| 1275 | # now expire sndr |
| 1276 | clock = 1.499 |