Exemple #1
0
    async def test_regression_reconnect_send_event_different_timing(
        self, system_control, client, drop_mechanism, eventhub
    ):
        payloads = []
        send_futures = []

        limitations.only_run_test_for(client, ["pythonv2"])
        limitations.skip_if_no_system_control()

        logger("connecting")
        await client.connect2()

        logger("unplugging network")
        await system_control.disconnect_network(drop_mechanism)

        # start listening before we send
        await eventhub.connect()
        received_message_future = asyncio.ensure_future(
            eventhub.wait_for_next_event(client.device_id)
        )

        logger(
            "sending 2 messages before the client realizes the network was unplugged"
        )
        for _ in range(0, 2):
            telemetry_tests.ensure_send_telemetry_message(
                client=client, payloads=payloads, send_futures=send_futures
            )

        logger("wait for the client to realize the network was unplugged")
        await client.wait_for_connection_status_change("disconnected")

        logger("send 2 more messages")
        for _ in range(0, 2):
            telemetry_tests.ensure_send_telemetry_message(
                client=client, payloads=payloads, send_futures=send_futures
            )

        logger("reconnect the network")
        await system_control.reconnect_network()

        logger("waiting for all messages to send")
        await asyncio.gather(*send_futures)

        logger("waiting for events to arrive at eventhub")
        await telemetry_tests.wait_for_all_telemetry_messages_to_arrive(
            received_message_future=received_message_future,
            payloads=payloads,
            eventhub=eventhub,
            client=client,
        )
Exemple #2
0
    async def test_regression_disconnect_cancels_send_event(
        self, system_control, client, drop_mechanism
    ):
        payloads = []
        send_futures = []

        limitations.only_run_test_for(client, ["node", "pythonv2"])
        limitations.skip_if_no_system_control()

        logger("connecting")
        await client.connect2()

        logger("unplugging network")
        await system_control.disconnect_network(drop_mechanism)

        logger(
            "sending 2 messages before the client realizes the network was unplugged"
        )
        for _ in range(0, 2):
            telemetry_tests.ensure_send_telemetry_message(
                client=client, payloads=payloads, send_futures=send_futures
            )

        logger("wait for the client to realize the network was unplugged")
        await client.wait_for_connection_status_change("disconnected")

        logger("send 2 more messages")
        for _ in range(0, 2):
            telemetry_tests.ensure_send_telemetry_message(
                client=client, payloads=payloads, send_futures=send_futures
            )

        logger("forcing a disconnection")
        await client.disconnect2()

        logger("verifying that all of our sends failed")
        for send_future in send_futures:
            with pytest.raises(Exception):
                await send_future
        logger("all sends failed")