Skip to content

Commit

Permalink
Update manager robot test (#140)
Browse files Browse the repository at this point in the history
* Update manager robot test

* Tune up tests

* Containers sequence changed

* Tuning UM test
  • Loading branch information
stlachev authored Sep 5, 2023
1 parent da42bec commit 1a0f39c
Show file tree
Hide file tree
Showing 6 changed files with 508 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ SDV Containers Exist
Verify Leda Containers
... sua
... databroker
... vum
... feedercan
... seatservice-example
... hvacservice-example
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# /********************************************************************************
# * Copyright (c) 2023 Contributors to the Eclipse Foundation
# *
# * See the NOTICE file(s) distributed with this work for additional
# * information regarding copyright ownership.
# *
# * This program and the accompanying materials are made available under the
# * terms of the Apache License 2.0 which is available at
# * https://www.apache.org/licenses/LICENSE-2.0
# *
# * SPDX-License-Identifier: Apache-2.0
# ********************************************************************************/

*** Settings ***
Documentation Update Manager ${leda.target}
Resource leda_keywords.resource

Library OperatingSystem
Library Process

Test Timeout 10 minutes

*** Variables ***

${sua_alive_regex} ([.\\s\\S]*)("self-update-agent")([\\s\\S.]*)
${topic_pub_currentstate} selfupdate/currentstate/get
${topic_sub_currentstate} selfupdate/currentstate
${get_state_filename} robot-resources/get_state.json

${topic_pub_desiredstate} vehicleupdate/desiredstate
${desired_state_no_containers_filename} robot-resources/desired-state-no-containers.json
${desired_state_filename} robot-resources/desired-state.json
@{containers} sua feedercan seatservice-example databroker hvacservice-example
@{any_state_containers} cloudconnector
@{stop_containers} seatservice-example databroker feedercan hvacservice-example

*** Test Cases ***

Check containers running
[Documentation] Check containers running
Wait Until Keyword Succeeds 5m 3s Verify SUA is alive ${broker.uri} ${broker.port} ${topic_pub_currentstate} ${topic_sub_currentstate} ${get_state_filename} ${sua_alive_regex}
${result}= Check containers status ${broker.uri} ${broker.port} Running @{containers}
Should Be Empty ${result} msg=Container(s) ${result} must be Running
${result}= Check containers status ${broker.uri} ${broker.port} Any @{any_state_containers}
Should Be Empty ${result} msg=Container(s) ${result} must persist

Stop containers
[Documentation] Stop containers
Publish command from file ${broker.uri} ${broker.port} ${topic_pub_desiredstate} ${desired_state_no_containers_filename}
${result}= Check containers status ${broker.uri} ${broker.port} Stopped @{stop_containers}
Should Be Empty ${result} msg=Container(s) ${result} must be Stopped

Bring all containers running
[Documentation] Bring all containers running
Publish command from file ${broker.uri} ${broker.port} ${topic_pub_desiredstate} ${desired_state_filename}
${result}= Check containers status ${broker.uri} ${broker.port} Running @{containers}
Should Be Empty ${result} msg=Container(s) ${result} must be Running
${result}= Check containers status ${broker.uri} ${broker.port} Any @{any_state_containers}
Should Be Empty ${result} msg=Container(s) ${result} must persist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Documentation This is a resource file, that can contain variables and keywor
... Keywords defined here can be used where this file is loaded.
Library MQTTLibrary
Library JSONLibrary
Library yaml
Library Collections
Library OperatingSystem
Expand All @@ -24,6 +25,7 @@ Library String

*** Variables ***
${leda.sshport} 2222
${json_query} $..payload[*].softwareNodes[?(@.id=='containers:{container}')].parameters[?(@.key=='status')].value

*** Keywords ***

Expand Down Expand Up @@ -58,6 +60,11 @@ Execute SUA command
${message}= Get File ${filename}
Publish Single topic=${topic_pub} payload=${message} hostname=${broker.uri} port=${broker.port}

Publish command from file
[Arguments] ${broker.uri} ${broker.port} ${topic_pub} ${filename}
${message}= Get File ${filename}
Publish Single topic=${topic_pub} payload=${message} hostname=${broker.uri} port=${broker.port}

Connect and Subscribe to Listen
[Arguments] ${broker.uri} ${broker.port} ${topic_sub} ${payload_regex} ${message_wait_timeout_seconds}
Connect ${broker.uri} ${broker.port}
Expand Down Expand Up @@ -119,3 +126,41 @@ Leda Execute
Log ${result.stdout}
Log ${result.stderr}
RETURN ${result}

Check containers status
[Documentation] Checks list of containers for status (Running, Stopped and Any)
[Arguments] ${broker.uri} ${broker.port} ${status} @{list}
Connect ${broker.uri} ${broker.port}
@{listNext} Create List @{list}
TRY
WHILE ${listNext} != @{EMPTY} limit=100
Publish command from file ${broker.uri} ${broker.port}
... containersupdate/currentstate/get
... robot-resources/update-state.json
@{messagelist}= Subscribe containersupdate/currentstate qos=1 timeout=50 limit=1
Length should be ${messagelist} 1
${json_string}= Get From List ${messagelist} 0
${message}= Convert String to JSON ${json_string}
@{listCurrent} Create List @{listNext}
FOR ${container} IN @{listCurrent}
${jq}= Format String ${json_query}
... container=${container}
${result}= Get Value From Json ${message} ${jq}
IF ${result} == @{EMPTY}
CONTINUE
END
Length should be ${result} 1
${result}= Get From List ${result} 0
IF '${result}' == '${status}'
Remove values from list ${listNext} ${container}
ELSE IF '${status}' == 'Any'
Remove values from list ${listNext} ${container}
END
END
Unsubscribe containersupdate/currentstate
END
EXCEPT WHILE loop was aborted type=start
Log The loop did not finish within the limit.
END
Disconnect
RETURN ${listNext}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"activityId": "activity-id-no-containers",
"payload": {
"domains": [{
"id": "containers",
"config": [],
"components": [

]
}]
}
}
Loading

0 comments on commit 1a0f39c

Please sign in to comment.