Skip to content

Testing with Simulator

In the Kelvin SDK there is a test tool to help you ingest data to the inputs and debug the outputs to test the performance of your Kelvin SmartApp™.

The Kelvin SDK test simulator tool is designed to allow testers to ingest messages from a random simulator for testing purposes. Here is the command:

kelvin app test simulator

Simulator Tool Overview

The test simulator tool supports a variety of options to customize its behavior. Below is a list of the available options:

Parameter Required Description Note
--config TEXT optional Path to the app.yaml Default: Current directory
--random / --counter optional Random values / Incremental values Default: Random values
--min FLOAT optional Minimum value Default: 0
--max FLOAT optional Maximum value Default: 100
--period FLOAT optional Publishing period in seconds Default: 5
--asset-count INTEGER optional Number of Assets (test-asset-N) Default: 1
--asset-parameter TEXT optional Sets Asset Parameter Can be used multiple times

Test your SmartApp

Info

In order to show how to use the simulator, we will use it with the Event Detection sample app.

  1. Run the Simulator Test Tool:

    kelvin app test simulator --counter --min 50 --max 60 --period 1 --asset-parameter temperature_max_threshold=55 --asset-parameter speed_decrease_set_point=1050 --asset-parameter closed_loop=true
    

    and you should see the following output:

    Publisher started.
    
  2. Open a NEW terminal window and run the SmartApp:

    python3 main.py
    

    and you should see the following output:

    Received Motor Temperature | Asset: test-asset-1 | Value: 55.0
    
    Received Motor Temperature | Asset: test-asset-1 | Value: 56.0
    
    Published Motor Speed SetPoint Control Change: 1050
    
    (...)
    
  3. Go to the Simulator Tool terminal and check the logs:

    Publisher started.
    Connected
    
    (...)
    
    Received Recommendation Message:
    RecommendationMsg(id=UUID('e5cc136a-5ae1-4014-a106-6699b6423e62'), type=KMessageTypeRecommendation('recommendation', ''), trace_id=None, source=None, timestamp=datetime.datetime(2024, 8, 9, 18, 10, 40, 231994, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600), 'WEST')), resource=KRNAsset(asset='test-asset-1'), payload=RecommendationPayload(source=None, resource=KRNAsset(asset='test-asset-1'), type='decrease_speed', description=None, confidence=None, expiration_date=None, actions=RecommendationActions(control_changes=[RecommendationControlChange(timeout=None, retries=None, expiration_date=datetime.datetime(2024, 8, 9, 18, 20, 40, 231843, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600), 'WEST')), payload=1000.0, from_value=None, state=None, resource=KRNAssetDataStream(asset='test-asset-1', data_stream='motor_speed_set_point'), control_change_id=None)]), metadata={}, state=None))
    (...)