outposts: always save state, even without version

This commit is contained in:
Jens Langhammer 2020-10-14 12:15:40 +02:00
parent 327bb09dd4
commit 5556e9f8e7
2 changed files with 13 additions and 8 deletions

View File

@ -79,7 +79,9 @@ class TestProviderProxy(SeleniumTestCase):
# Wait until outpost healthcheck succeeds
healthcheck_retries = 0
while healthcheck_retries < 50:
if outpost.deployment_health:
if len(outpost.state) > 0:
state = outpost.state[0]
if state.last_seen:
break
healthcheck_retries += 1
sleep(0.5)
@ -152,10 +154,13 @@ class TestProviderProxyConnect(ChannelsLiveServerTestCase):
# Wait until outpost healthcheck succeeds
healthcheck_retries = 0
while healthcheck_retries < 50:
if outpost.deployment_health:
if len(outpost.state) > 0:
state = outpost.state[0]
if state.last_seen and state.version:
break
healthcheck_retries += 1
sleep(0.5)
self.assertIsNotNone(outpost.deployment_health)
self.assertEqual(outpost.deployment_version.get("version"), __version__)
state = outpost.state
self.assertTrue(len(state), 1)
self.assertEqual(state[0].version, __version__)

View File

@ -55,7 +55,7 @@ class OutpostConsumer(AuthJsonConsumer):
self.outpost = outpost.first()
OutpostState(
uid=self.channel_name, last_seen=datetime.now(), _outpost=self.outpost
).save(timeout=OUTPOST_HELLO_INTERVAL * 2)
).save(timeout=OUTPOST_HELLO_INTERVAL * 1.5)
LOGGER.debug("added channel to cache", channel_name=self.channel_name)
# pylint: disable=unused-argument
@ -72,9 +72,9 @@ class OutpostConsumer(AuthJsonConsumer):
)
if msg.instruction == WebsocketMessageInstruction.HELLO:
state.version = msg.args.get("version", None)
state.save(timeout=OUTPOST_HELLO_INTERVAL * 2)
elif msg.instruction == WebsocketMessageInstruction.ACK:
return
state.save(timeout=OUTPOST_HELLO_INTERVAL * 1.5)
response = WebsocketMessage(instruction=WebsocketMessageInstruction.ACK)
self.send_json(asdict(response))