Skip to content

Commit

Permalink
Merge pull request #2618 from reubenmiller/test-use-random-service-names
Browse files Browse the repository at this point in the history
test: use random service name in tests to avoid side effects from concurrent runs
  • Loading branch information
reubenmiller authored Jan 24, 2024
2 parents 6e5e373 + bb0de9e commit d68f8dc
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,36 +244,39 @@ Nested child devices support sending event

# Nested child device services
Nested child device service support sending simple measurements
${nested_child}= Get Random Name
${nested_child}= Get Random Name
${service_name}= Get Random Name
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}//' '{"@type":"child-device","@parent":"device/${CHILD_SN}//","@id":"${nested_child}"}'
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}/service/nested_ms_service' '{"@type":"service","@parent":"device/${nested_child}//","@id":"nested_ms_service"}'
Execute Command tedge mqtt pub te/device/${nested_child}/service/nested_ms_service/m/m_type '{ "temperature": 30.1 }'
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}/service/${service_name}' '{"@type":"service","@parent":"device/${nested_child}//","@id":"${service_name}"}'
Execute Command tedge mqtt pub te/device/${nested_child}/service/${service_name}/m/m_type '{ "temperature": 30.1 }'
Cumulocity.Device Should Exist ${nested_child}
Cumulocity.Should Have Services name=nested_ms_service min_count=1 max_count=1
Cumulocity.Device Should Exist nested_ms_service
Cumulocity.Should Have Services name=${service_name} min_count=1 max_count=1
Cumulocity.Device Should Exist ${service_name}
${measurements}= Device Should Have Measurements minimum=1 maximum=1
Should Be Equal ${measurements[0]["type"]} m_type
Should Be Equal As Numbers ${measurements[0]["temperature"]["temperature"]["value"]} 30.1
Log ${measurements}

Nested child device service support sending events
${nested_child}= Get Random Name
${nested_child}= Get Random Name
${service_name}= Get Random Name
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}//' '{"@type":"child-device","@parent":"device/${CHILD_SN}//","@id":"${nested_child}"}'
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}/service/nested_event_service' '{"@type":"service","@parent":"device/${nested_child}//","@id":"nested_event_service"}'
Execute Command tedge mqtt pub te/device/${nested_child}/service/nested_event_service/e/e_type '{ "text": "nested device service started" }'
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}/service/${service_name}' '{"@type":"service","@parent":"device/${nested_child}//","@id":"${service_name}"}'
Execute Command tedge mqtt pub te/device/${nested_child}/service/${service_name}/e/e_type '{ "text": "nested device service started" }'
Cumulocity.Device Should Exist ${nested_child}
Cumulocity.Should Have Services name=nested_event_service min_count=1 max_count=1
Cumulocity.Device Should Exist nested_event_service
Cumulocity.Should Have Services name=${service_name} min_count=1 max_count=1
Cumulocity.Device Should Exist ${service_name}
Device Should Have Event/s expected_text=nested device service started type=e_type minimum=1 maximum=1

Nested child device service support sending alarm
${nested_child}= Get Random Name
${service_name}= Get Random Name
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}//' '{"@type":"child-device","@parent":"device/${CHILD_SN}//","@id":"${nested_child}"}'
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}/service/nested_alarm_service' '{"@type":"service","@parent":"device/${nested_child}//","@id":"nested_alarm_service"}'
Execute Command tedge mqtt pub te/device/${nested_child}/service/nested_alarm_service/a/test_alarm '{ "severity":"critical","text":"temperature alarm" }'
Execute Command tedge mqtt pub --retain 'te/device/${nested_child}/service/${service_name}' '{"@type":"service","@parent":"device/${nested_child}//","@id":"${service_name}"}'
Execute Command tedge mqtt pub te/device/${nested_child}/service/${service_name}/a/test_alarm '{ "severity":"critical","text":"temperature alarm" }'
Cumulocity.Device Should Exist ${nested_child}
Cumulocity.Should Have Services name=nested_alarm_service min_count=1 max_count=1
Cumulocity.Device Should Exist nested_alarm_service
Cumulocity.Should Have Services name=${service_name} min_count=1 max_count=1
Cumulocity.Device Should Exist ${service_name}
${alarm}= Device Should Have Alarm/s type=test_alarm expected_text=temperature alarm severity=CRITICAL minimum=1 maximum=1
Log ${alarm}

Expand Down

1 comment on commit d68f8dc

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
381 0 3 381 100 50m13.815s

Please sign in to comment.