The cloud says it worked. Did the device?¶
A command sent through a device's cloud comes back saying it worked, and many tests stop at that reply. Here one test sends the command through the cloud, then asks the device's own server and a web relay on the wire it powers, and returns one answer for the run. The last post built an instrument for a thermostat; this one checks a different device, controlled through its vendor's cloud.
Why the cloud's reply is where the test stops¶
Many connected products are controlled through their vendor's cloud. The app sends a command to the cloud, the cloud passes it to the device, and the cloud replies. For a test, that reply is often the only interface on offer, so it becomes the result: the command was accepted, the test passes.
The reply is what the software believes happened. Whether the device actually switched is usually checked by someone at the bench, watching a light or reaching for a meter. That happens once, and again after the next release if there's time.
That's a reasonable tradeoff when a release is due and the cloud isn't yours to change. But what the person at the bench saw is rarely written down anywhere a developer can find it, and the check doesn't run as often as the releases do.
Ask the device and the wire, not only the cloud¶
To know what happened, a test has to reach past the cloud: to the device itself, and to what the device switches.
On this bench, a Wi-Fi smart plug is the device under test. A power adapter is plugged into it, and a web relay watches the adapter's output on one of its inputs, so the web relay reads on whenever the plug is on.
In Knilb, a plan declares named roles, and every step targets a role, never a particular machine. This plan has two. plug is a small example service that reaches the plug through its vendor's cloud and also talks to the plug directly over the local network, so Knilb reaches the cloud through that service. supply_monitor is the web relay. Because each step names its role, the plan decides which of them answers each check. The example service is public, and the testbed model explains how roles keep the test apart from the bench.
On and off, checked three ways¶
Setup turns the plug off over the local network, and the web relay confirms there is no voltage on the wire.
Then the test sends "on" through the vendor's cloud, and the cloud confirms the plug switched. The next step asks the plug's own server over the local network, and it says on. The step after that asks the web relay, and it finds voltage on the wire. Then "off" goes through the cloud, and the same three witnesses agree it is off: the cloud, the plug's own server, and the wire.
The run takes about 30 seconds and is shown in real time. It covers one plug, one web relay, and one test, with the cloud reached through the example service.
One answer, and the path the command took¶
The run ends with one answer. Every step is in one list, in the order it ran, with what came back, from the cloud's reply to the voltage on the wire.
Each result freezes the deployment as it was cast, so it keeps the address behind each role. Reopened later, it still shows that the cloud was reached through the example service, and that the web relay answered every wire check. The cloud's reply sits next to what the plug and the wire reported for the same command.
Run it again after the next release¶
The same plan runs again against the same bench, with nobody watching the light. Each run leaves its own result, so after a firmware update or a change on the cloud side, the new result is there to compare with the last one.
The bench story shows the same method on a thermostat, with test equipment swapped, added, and built. How to test a connected product end to end lays out the method behind it, including test equipment on the physical outputs.
If your devices are controlled through a cloud, tell us what you're building, and we'll work through it with you as a design partner.