-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(samples): Add invoke method sample and Query tests. #14252
Conversation
vinagesh
commented
Aug 14, 2020
•
edited
Loading
edited
- Added query e2e tests
- Added samples for invoking methods on device and module
- Renamed some methods to have async
- Added configureAwait wherever missing
- Generated recorded files for old and new tests
- Added a cleanup for samples in case of errors
sdk/iot/Azure.Iot.Hub.Service/samples/IotHubClientSamples/DeviceIdentityLifecycleSamples.cs
Outdated
Show resolved
Hide resolved
ed103a6
to
8d37544
Compare
|
||
try | ||
{ | ||
AsyncPageable<TwinData> asyncPageableResponse = hubClient.Devices.GetTwinsAsync(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where I felt having a list on Device Identities might have been helpful. Maybe something to revisit. If not the overloaded method, we can have some custom implementation to get all device identities. If there is a one-liner to do this already and i'm missing it, let me know.
deviceTwins.Add(twin); | ||
} | ||
|
||
foreach (TwinData twin in deviceTwins) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic assumes all devices have a twin. Let me know if that is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently i'm doing
- List all twins
- Get device Ids from there
- Get every device identity using the id
- Delete every device identity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is not a better way to do this, we should discuss how we can expose List all device identities. Customers might have a similar scenario too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a way around Step 1, 2 and 3 ; but instead of calling Step 4 in a for-each loop, we could also use the bulk API.
I remember people being unhappy about this in the track 1 client, so we could probably expose an API that combines 1, 2 and 3 and returns the result?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be careful in adding functionality that extends beyond the REST API. I'm not saying we don't, but let's treat that decision with care and thoroughly discuss it.
a9ac987
to
1d26254
Compare
1d26254
to
91a4f43
Compare
89a6b75
to
49072be
Compare
@@ -98,6 +98,8 @@ public async Task CreateDeviceIdentitiesAsync(IEnumerable<DeviceIdentity> device | |||
} | |||
catch (Exception ex) | |||
{ | |||
// Try to cleanup before exiting with fatal error. | |||
await CleanupHelper.DeleteAllDevicesInHubAsync(IoTHubServiceClient); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to ensure we cleanup all devices created in the hub even if there was a fatal error.
@@ -49,6 +50,20 @@ public static async Task Main(string[] args) | |||
|
|||
var bulkDeviceIdentityLifecycleSamples = new BulkDeviceIdentityLifecycleSamples(hubClient); | |||
await bulkDeviceIdentityLifecycleSamples.RunSampleAsync(); | |||
|
|||
var bulkModuledentityLifecycleSamples = new BulkModuleIdentityLifecycleSamples(hubClient); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had forgotten to include this in my previous PR
@@ -73,7 +73,7 @@ public async Task DevicesClient_IdentityLifecycle() | |||
} | |||
finally | |||
{ | |||
await Cleanup(client, device); | |||
await CleanupAsync(client, device).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to end with Async
49072be
to
627fb9a
Compare
sdk/iot/Azure.Iot.Hub.Service/samples/IotHubClientSamples/MehodInvocationSamples.cs
Outdated
Show resolved
Hide resolved
sdk/iot/Azure.Iot.Hub.Service/samples/IotHubClientSamples/MehodInvocationSamples.cs
Show resolved
Hide resolved
sdk/iot/Azure.Iot.Hub.Service/samples/IotHubClientSamples/MehodInvocationSamples.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few notes that I'll leave to your judgement, but otherwise looks good
627fb9a
to
5aad910
Compare