Граф коммитов

11 Коммитов

Автор SHA1 Сообщение Дата
Devis Lucato 0ced724464 Add support for storing data in Azure Tables (#327) 2018-12-10 14:59:37 -08:00
Devis Lucato 8fa180f715
Reliability improvements
**Major:**
1. Backoff in case of d2c messaging throttling, stopping telemetry and twin operations
2. Improve perf reducing load on garbage collector and disposing IoT SDK resources
3. Improve device twin management, e.g. try to avoid twin writes when data is not changed, handle more error scenarios
4. Add "development" feature flag to enable/disable expensive runtime checks
5. Change partitions size from 1000 to 5000 devices to reduce the load on storage

**Minor:**
1. Backoff in case of device count throttling (e.g. when reaching 8000 devices in the free SKU)
2. Remove unused daily counter for telemetry
3. Improve perf reducing the number of no-op async tasks
4. Update IoT SDK and other dependencies
5. Clean up logging code, reimplement log filtering (removed in past PRs)
6. Print SDK version at startup
7. Add some scripts for development, see /scripts/development (create/delete simulation, start storage adapter)

**Bug fixes:**
1. Handle and recover from exceptions in the partitioning agent
2. Fix some swallowed errors/exceptions and unnecessary try/catch
3. Share script interpreter between methods and state to ensure device state consistency
4. Fix logged throughput in case of no traffic, i.e. show 0.0 msg/sec, and round value to 3 decimals
5. Fix logging from ConfigData
6. Change the dev endpoint used to delete simulations: don't delete devices (the endpoint was not working) - no user impact, dev only
2018-11-29 17:29:58 -08:00
Peter Felts 8f66a67290 Adding SimulationManager + tests (#263) 2018-10-05 14:39:33 -07:00
Devis Lucato 792fdfd345
Add agent for creating and partitioning devices (#251)
Add agent for creating and partitioning devices

1. Add a new agent to the solution, which will be responsible for creating
the devices in IoT hub and for partitioning the list of devices, so
that multiple VMs can each simulate a different set of devices.
The agent is not started yet because the new storage library is not
ready.
2. Refactor concurrency settings and add clustering settings
3. Temporary add retry logic to a couple of flaky tests
2018-09-12 15:37:56 -07:00
Devis Lucato c17ce82172
New logger & dependencies upgrade (#232)
* New logger, faster and easier to use
* Upgrade dependencies, just some maintenance and no breaking changes
* Code style cleanup
2018-08-12 15:36:40 -07:00
Devis Lucato 6f0d073713
Performance improvements (#223)
* Refactor code writing twin tags for better performance
* Refactor device properties code for better performance
* Refactor simulation runner for better performance
* Improve connections performance
* Reduce time to start simulation, by creating devices using the same conn string and fetching device from registry only if the authentication fails.
* Limit the number of pending threads attempting to deliver telemetry
* Change all stock device models to use AMQP
* Move SDK timeout setting and other hard coded magic numbers to config file
* Use default timeout value from SDK instead of hardcoding it
* Improve documentation in the configuration file
* Upgrade IoT SDK
* Improve logging in device client
* Reduce noise in the "Info" log level
* When building, remove "deleted files" left over from previous builds
* Improve error detection when creating devices with batch operations
* Recreate device client when the internal AMQP client is disposed (lib bug workaround)
* VS code config update
* Remove simulation version, not used anywhere
* Catch and log when a device model doesn't exist
* Log missing config settings
* Make sure the simulation object is not lost in case of errors while checking for simulation changes
* Limit async tests duration
* Remove IoT hub registry workaround
* Fix boolean conf values parsing
* Remove "en-us" from links in the comments
* Fix invalid parsing of environment variables
2018-07-17 16:37:58 -07:00
Hugh Xiong 59347ead63 Custom device model management (#199)
* New endpoint to CRUD custom device models, stored via storage adapter
* Note: stock models are read-only
* Some changes to internal classes used for device models, e.g. use Enum instead of Strings
* Fix incorrect exception used in the Simulations service class: when the ETag doesn't match use ResourceOutOfDateException, not ConflictingResourceException (no API change, same HTTP status code)
2018-05-22 17:24:57 -07:00
Jill Bender 0075b280c7 Add IsSimulated Tag when devices are created from list (#195)
* Simplify the device models, no methods and twins (#121)

* Remove unused models, scripts, methods, properties
* Upgrade to .NET Core 2.0
* Add some more logging
* Improve simulation runner startup to handle exceptions
* Update CI conf

* move docs, move wiki, new API specs, fix scripts for Windows Bash (#123)

* move docs, move wiki, new API specs, add copyright, fix for Windows Bash

* Disable twin read write by default and add config option to enable (#125)

* add config setting to turn of twin read/write
* add logic to only call twin reads/writes if enabled
* change twin read/write config value to an optional env var

* Allow to schedule a simulation, defining start and end time (#126)

* Support simulation duration and scheduling
* Fix the spelling of “ETag”
* Allow ETag=*
* adjust unit test precision to mitigate flaky test

* Upgrade Docker image to 2.0.3 (#132)

* Fix nullref exception

* Copy agent settings into web service

* Fix status endpoint

* Use S2 limits and increase async thread pool size

* Run a simulation against a hub provisioned by the user (#133)

* Add IoTHub with connstring to Api Model, pass "default" to use the configured hub
* Add private helpers to redact key from IotHubConnString
* Store non redacted entire connection string in a file
* Update API specs documentation

* Reduce the number of threads and improve overall performance (#137)

* Rewrite the simulation engine to use fewer threads
* Start sending telemetry as soon as possible
* Run simulation engine in the same process used for the web service
* Add workaround for registry manager becoming unresponsive
* Add more optional logging by device and by actor
* Use logging level and other logging settings from configuration

* New web service APIs (#138)

New web service APIs

* New API to support multiple scripts 
* New API to support custom sensors
* New API to support custom telemetry frequency
* New API to expose whether a hub is configured, i.e. provisioned and the connection string is in the config file
* Fix exception occurring when there is no connection string

* Simulation input validation (#140)

* Use custom frequency for telemetry and device state (#141)

* Apply the customized telemetry and state frequencies + fix bug for models with multiple messages
* Fix exception on bad request

* Improved Azure IotHub Connection String Validation  (#143)

* additional validation for iothub connection string

* check permissions with calls to registry manager instead of string comparison

* Refactor permissions validation into separate methods. Make sure test device created is deleted, create with a regognizable test name in case of error.

* remove await from Assert.ThrowsAsync

* added retry logic to delete test device

* Logging cleanup

* Internal scripts for increasing/decreasing/random (#146)

* Update travis CI config to use .NET core 2.0.3

* Fix log level parsing from the config, to be case insensitive

* Update simulation model parsing/serialization. Add script Params in the service layer

* Complete the device model override logic

* Add internal scripts

* Allow to override the initial state. Add “online” key where missing.

* Fix null reference exception in DeviceModelsGeneration (#147)

* Use env var to define log level (#150)

* Use env var to define log level
* Add env vars documentation ENVIRONMENT_VARIABLES.md

* bugfix: Etag mismatch now returns 409 Conflict instead of 400 Bad Request (#151)

* When available, return a URL to the metrics of the pre-provisioned hub (#153)

When available and when the simulation is running, return a URL to the metrics of the pre-provisioned hub. Also some changes to the /status endpoint

* Use PCS_LOG_LEVEL env var for log level, instead of LOG_LEVEL

* Create devices using batch operations (#154)

* When a simulation is deleted, delete also the devices
* When a simulation starts, create all the devices in batches

* Throw error on all-whitespace connection string & validate default hub (#155)

* Check for whitespace in custom connection string. Check that default IotHub exists and is valid.
* Update invalid connection string message
* fix log level for GetiotHubConnectionString()

* Map “Custom” device model id used by the UI to the internal ID

* Fix code style

* Fix Decrementing function

* Add system properties to the messages

* Remove old code used to detect simulation stop via cancellation token (#162)

* Remove old code used to detect simulation stop via cancellation token
* Rethrow timeout exceptions

* Fix for override stock device model with null value (#163)

* add null check for PUT payload properties

* add null check test

* update test arrangement

* uncomment UpdateTwinAsync

* add folder for DeviceTwinActor

* Fix exceptions when override stock device model (#164)

* Add null check for MessageSchema

* Add support classes for DeviceTwinActor to update twin -- uses empty methods

* remove Properties from DeviceStateActor class

* Add InternalDeviceState Class and ability to update twin via callback from javascript

* add placeholders for twin update logic for future pr

* remove eslint jsdoc updates and update javascriptinterpreter tests

* Add new thread for device properties updates

* return null for not implemented methods

* Add active device count for status API (#169)

* Register SimulationRunner as a singleton type
* Allow DeviceStatusActor report active status
* Add active device count to status API

* Add Unit Tests for Internal Device State

* Update existing tests with new InternalDeviceState class

* Update scripts with instructions on device property updates

* Fix errors with JS device scripts and readonly dictionary

* revert changes to DeviceTwin class

* Update log messages for readability with timestamp

* Rename logging methods for consistency

* Separate properties and state and remove unused lines

* update comments for twin update branch

* Revert UpdateTwinAsync signature in DeviceClient

* revert UpdateState and JSValueToDictionary to private

* update comment on restoreState in chiller js script

* Update InternalDevicePropertiesTest names

* set sending telemetry retry policy to No Retry (#175)

* Consolidated to SmartDictionary class

* remove DevicePropertiesActor, revert DeviceTwin, change terminology from sensors to state

* revert actors logger

* revert simulation runner

* revert simulation runner test

* revert deletion of UpdateReportedProperties.cs

* fix spacing in SimulationRunner

* fix spacing in device twin

* consolidate restore state javascript methods

* add properties to internal script method call

* variable/method naming, whitespace cleanup, add missing method in elevator state script

* Add Device Properties logic to internal simulation (#173)

* uncomment UpdateTwinAsync

* add folder for DeviceTwinActor

* Add support classes for DeviceTwinActor to update twin -- uses empty methods

* remove Properties from DeviceStateActor class

* Add InternalDeviceState Class and ability to update twin via callback from javascript

* add placeholders for twin update logic for future pr

* remove eslint jsdoc updates and update javascriptinterpreter tests

* Add new thread for device properties updates

* return null for not implemented methods

* Add Unit Tests for Internal Device State

* Update existing tests with new InternalDeviceState class

* Update scripts with instructions on device property updates

* Fix errors with JS device scripts and readonly dictionary

* revert changes to DeviceTwin class

* Update log messages for readability with timestamp

* Rename logging methods for consistency

* Separate properties and state and remove unused lines

* update comments for twin update branch

* Revert UpdateTwinAsync signature in DeviceClient

* revert UpdateState and JSValueToDictionary to private

* update comment on restoreState in chiller js script

* Update InternalDevicePropertiesTest names

* Consolidated to SmartDictionary class

* remove DevicePropertiesActor, revert DeviceTwin, change terminology from sensors to state

* revert actors logger

* revert simulation runner

* revert simulation runner test

* revert deletion of UpdateReportedProperties.cs

* fix spacing in SimulationRunner

* fix spacing in device twin

* consolidate restore state javascript methods

* add properties to internal script method call

* variable/method naming, whitespace cleanup, add missing method in elevator state script

* Revert "Add Device Properties logic to internal simulation (#173)"

This reverts commit 37a720d044.

* [Updated] Add DevicePropertiesActor and push reported properties updates to the IoT Hub (#181)

* Initial commit with placeholders for sending twin updates

* Add skeleton DevicePropertiesActor and integrate with SimulationRunner

* Add mock devicePropertiesActor for SimulationRunnerTest

* added Device Properties Actor Setup

* add device properties actor tests

* Add Device Properties logic to internal simulation (#173)

* uncomment UpdateTwinAsync

* add folder for DeviceTwinActor

* Add support classes for DeviceTwinActor to update twin -- uses empty methods

* remove Properties from DeviceStateActor class

* Add InternalDeviceState Class and ability to update twin via callback from javascript

* add placeholders for twin update logic for future pr

* remove eslint jsdoc updates and update javascriptinterpreter tests

* Add new thread for device properties updates

* return null for not implemented methods

* Add Unit Tests for Internal Device State

* Update existing tests with new InternalDeviceState class

* Update scripts with instructions on device property updates

* Fix errors with JS device scripts and readonly dictionary

* revert changes to DeviceTwin class

* Update log messages for readability with timestamp

* Rename logging methods for consistency

* Separate properties and state and remove unused lines

* update comments for twin update branch

* Revert UpdateTwinAsync signature in DeviceClient

* revert UpdateState and JSValueToDictionary to private

* update comment on restoreState in chiller js script

* Update InternalDevicePropertiesTest names

* Consolidated to SmartDictionary class

* remove DevicePropertiesActor, revert DeviceTwin, change terminology from sensors to state

* revert actors logger

* revert simulation runner

* revert simulation runner test

* revert deletion of UpdateReportedProperties.cs

* fix spacing in SimulationRunner

* fix spacing in device twin

* consolidate restore state javascript methods

* add properties to internal script method call

* variable/method naming, whitespace cleanup, add missing method in elevator state script

* Revert "Add Device Properties logic to internal simulation (#173)"

This reverts commit 37a720d044.

* Add State Machine for device properties updates

* Add Device Property Update Logic and Remove Unused Device Twin Model

* delete old commented out DeviceConnection/UpdateReportedProperties.cs

* Add tests for UpdateReportedProperties

* Add properties to device models & clean up UpdatePropertiesAsync

* remove unused usings

* remove unnecessary lock in JavascriptInterpreter

* Parvezp/add methods (#182)

* Initial commit with placeholders for sending twin updates

* Add skeleton DevicePropertiesActor and integrate with SimulationRunner

* Add mock devicePropertiesActor for SimulationRunnerTest

* added Device Properties Actor Setup

* add device properties actor tests

* Initial check-in for adding methods

* Updating the tabs

* Adding more log parameters

* Fixing build break
Sorting using

* Adding all the simulated devices,state and methods (#183)

* Initial commit with placeholders for sending twin updates

* Add skeleton DevicePropertiesActor and integrate with SimulationRunner

* Add mock devicePropertiesActor for SimulationRunnerTest

* added Device Properties Actor Setup

* add device properties actor tests

* Initial check-in for adding methods

* Updating the tabs

* Adding more log parameters

* Fixing build break
Sorting using

* * Adding all simulated devices
* Adding all of their state javascript files
* Adding all of the javascript  methods for those simulated devices

* Adding unit tests for the new files

* Addressing comments

* Removing extra space that i missed

* Update FirmwareUpdate method to use correct parameters in the callback from js to c# (#186)

* Feature/telemetry metrics (#170)

* Add simulation status reporting messages throughput and errors counters
* Do not retry sending telemetry in case of errors
* Change Azure SDK timeout to 10 seconds (default is 4 minutes)
* Improve SDK exceptions handling
* Fix rare exception due to contention on the `state` variable

* Change stock models to use AMQP (#189)

* Upgrade Azure IoT SDK: Devices 1.4.1 to 1.6.0 (#187)

Upgrade Azure IoT SDK: Devices Client 1.5.2 to 1.7.0
Upgrade test dependencies

* Register for Desired Property State Changes (#184)

Adds functionality for receiving notifications of Desired Property state changes from the IoT Hub. When the hub detects a state change it will send a notification via the DeviceClient.SetDesiredPropertyUpdateCallbackAsync registration. This change allows the simulation service to subscribe to the change notifications and update the internal simulation state to report the desired property to the hub when executed.

Changes:
* add callback for desired properties updates to Device Client
* add DevicePropertiesRequestTest
* add property for SupportedMethods

* Update DeviceConnectionActorTest with correct constructor for DeviceConnectionActor

* Update DEVICE_MODELS.md

* Add waiting state for properties update

* Update SetAll in SmartDictionar to set a new ConurrentDictionary

* Refactor properties actor

* Rename DeviceProperties.cs & methods, make callback private, update tests

* remove unused property from DevicePropertiesActor

* UpdateReportedPropertiesTest changes to reflect desired functionality

* Update DeviceConnectionActor state machine to tag simulated devices that were created via a list creation in Devices.cs

* Add Device Methods and Properties Functionality (#193)

* Add new state machine to manage changes to devices' "reported properties"
* Add callback to manage changes to devices's "desired properties"
* Add callbacks to manage method calls
* Refactor and improve how simulation scripts access state and properties

* move device tagging to DevicePropertiesActor and update tests

* Fix DevicePropertiesActor reference to twin failure count

* remove whitespace

* Fix merge conflicts between azure-iot-pcs-simulation and master (#196)

* Fix #122 + backport fix for flaky test (#128)

* Upgrade to .NET Core 2.0 and upgrade dependencies (#130)

* Upgrade to .NET Core 2.0 and upgrade dependencies
* Update comments and docs

* Change Docker base image to use .NET Core 2.0.3 (#131)

* Change Docker base image to use .NET Core 2.0.3

* use jessie

* Use absolute instead of relative links to wiki (#161)

Fix for:
https://github.com/Azure/device-simulation-dotnet/issues/39

The relative links don't resolve to the wiki page ending up in a 404. This update changes the URL links to be the full relative link to the documentation page.

* Remove squash (#166)

* Removing the squash flag

* Fixing extra space

* Use env vars in launchSettings.json (#168)

* Docker container excessively privileged running root user (#178)

* Add default non-root user 'pcsuser'
* Run service as 'pcsuser'

PBI[2211778]

* remove whitespace

* revert SimulationAgent.csproj changes

* Adjust whitespace in SimulationAgent.csproj

* remove newline

* Move FailedDeviceTwinUpdatesCount logic to SimulationRunner

* rename Tag to SetDeviceTag

* rename twin to device

* Clean up comments

* Upgrade travis.yml dotnet core version

* revert .Net core upgrade for travis

* Update .travis.yml

* Fix build

* fixing build...

* tag devices with ContinueWith

* fix typos
2018-04-19 11:16:27 -07:00
Jill Bender b211cb7805 Merge azure-iot-pcs-simulation into master (#197)
* Rewrite to use fewer threads and increase throughput
* Expose simulation metrics in the status endpoint
* When available, return a URL to the Azure Portal metrics of the pre-provisioned IoT Hub
* Allow to run a simulation against a custom IoT Hub, passing the connection string
* Allow to schedule a simulation, defining start and end time
* Improve security by running the service as a non-root user
* Support multiple behavior scripts in a device model
* Support custom device with custom sensors, behavior and frequency
* Allow to override the initial device state when creating a simulation
* When a simulation starts, create all the devices in batches
* When a simulation is deleted, delete also the devices
* Refactor timers to start sending telemetry as soon as possible
* Refactor and improve how simulation scripts access state and properties
* Change stock models to use AMQP (#189)
* Overall improvements to exceptions handling
* Disable SDK retry, and change timeout from default (4 minutes) to 10 seconds
* Do not retry sending telemetry on failure, skip message
* Use IoT Hub S2 SKU limits by default
* Upgrade to .NET Core 2.0.3
* Upgrade Azure IoT SDK: Devices 1.4.1 to 1.6.0, Devices Client 1.5.2 to 1.7.0
* Run simulation engine in the same process used for the web service
* Move docs, move wiki, new API specs, fix scripts for Windows Bash
* Fix the spelling of “ETag” and allow ETag=*
* Add internal scripts for increasing/decreasing/random telemetry
* Add env vars documentation ENVIRONMENT_VARIABLES.md
* Add more optional logging by device and by actor
* Use logging level and other logging settings from configuration
* Adjust unit test precision to mitigate flaky test
* Add system properties to telemetry messages
* Removing the squash flag from Docker scripts
* Use env vars in launchSettings.json
2018-04-12 17:42:46 -07:00
Devis Lucato 777187acbd
Fix #122 + backport fix for flaky test (#128) 2017-11-16 18:03:05 -08:00
Devis Lucato 0d37f32671 Limit registry and twin operations as per configuration (#78)
* New configuration settings for rate limiting
* Rate connections and messaging frequency
* Don’t read the twin on creation
*  reate GitHub issues tracking the TODO notes
* Change the timer to run only once and support scenarios where it is being disposed
* Pass the cancellation through where it can be used by IoT SDK
* Fix web service returning the wrong ETag when editing a simulation
* Remove all the timeouts incompatible with throttling (i.e. throttling will slow down operations and a timeout wouldn’t make sense)
* Improve the Actor stop logic to be resilient to errors and make all the required steps regardless of exceptions
* Use async/await where possible to avoid the use of .Wait() and .Result
* Log throughput in debug mode
2017-10-18 22:21:01 -07:00