Esempio n. 1
0
    async def do_test_get_twin(self, *, client, registry, count, time_limit):
        await client.enable_twin()

        for i in range(0, count):
            if time_limit.is_test_done():
                return

            logger("get_twin {}/{}".format(i + 1, count))
            twin_sent = sample_content.make_desired_props()

            await patch_desired_props(registry, client, twin_sent)

            while True:
                twin_received = await client.get_twin()

                logger("twin sent:    " + str(twin_sent))
                logger("twin received:" + str(twin_received))
                if twin_sent["desired"]["foo"] == twin_received["desired"][
                        "foo"]:
                    break
                else:
                    logger(
                        "Twin does not match.  Sleeping for 2 seconds and retrying."
                    )
                    await asyncio.sleep(2)
Esempio n. 2
0
    async def patch_desired(self, *, client, registry, mistakes=1):
        twin_sent = sample_content.make_desired_props()
        logger("Patching desired properties to {}".format(twin_sent))

        patch_future = asyncio.ensure_future(
            wait_for_desired_properties_patch(client=client,
                                              expected_twin=twin_sent,
                                              mistakes=mistakes))
        await asyncio.sleep(1)  # wait for async call to take effect

        await patch_desired_props(registry, client, twin_sent)

        await patch_future  # raises if patch not received
Esempio n. 3
0
    async def test_twin_desired_props_patch(self, client, registry):

        await client.enable_twin()

        for i in range(1, 4):
            twin_sent = sample_content.make_desired_props()

            logger("start waiting for patch {}".format(i))
            patch_future = asyncio.ensure_future(
                wait_for_desired_properties_patch(client=client,
                                                  expected_twin=twin_sent))
            await asyncio.sleep(3)  # wait for async call to take effect

            logger("sending patch {}".format(i))
            await patch_desired_props(registry, client, twin_sent)
            logger("patch {} sent".format(i))

            await patch_future  # raises if patch not received
            logger("patch {} received".format(i))
Esempio n. 4
0
    async def test_twin_desired_props_5_times(self, client, registry):
        await client.enable_twin()

        for _ in range(0, 5):
            twin_sent = sample_content.make_desired_props()

            await patch_desired_props(registry, client, twin_sent)

            while True:
                twin_received = await client.get_twin()

                logger("twin sent:    " + str(twin_sent))
                logger("twin received:" + str(twin_received))
                if twin_sent["desired"]["foo"] == twin_received["desired"][
                        "foo"]:
                    break
                else:
                    logger(
                        "Twin does not match.  Sleeping for 5 seconds and retrying."
                    )
                    await asyncio.sleep(5)
Esempio n. 5
0
    async def test_twin_desired_props(self, client, registry):
        twin_sent = sample_content.make_desired_props()

        await patch_desired_props(registry, client, twin_sent)

        # BKTODO: Node needs this sleep to pass MQTT against edgeHub
        await asyncio.sleep(5)
        await client.enable_twin()

        while True:
            twin_received = await client.get_twin()

            logger("twin sent:    " + str(twin_sent))
            logger("twin received:" + str(twin_received))
            if twin_sent["desired"]["foo"] == twin_received["desired"]["foo"]:
                # test passed
                return
            else:
                logger(
                    "Twin does not match.  Sleeping for 5 seconds and retrying."
                )
                await asyncio.sleep(5)