Skip to content
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

[CI] Add a test for successful OTA transfer #18344

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/darwin-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ jobs:
--target darwin-x64-chip-tool-darwin-${BUILD_VARIANT} \
--target darwin-x64-all-clusters-${BUILD_VARIANT} \
--target darwin-x64-lock-${BUILD_VARIANT} \
--target darwin-x64-ota-provider-${BUILD_VARIANT} \
--target darwin-x64-ota-requestor-${BUILD_VARIANT} \
--target darwin-x64-tv-app-${BUILD_VARIANT} \
build \
--copy-artifacts-to objdir-clone \
Expand All @@ -104,6 +106,8 @@ jobs:
--iterations 1 \
--all-clusters-app ./out/darwin-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
--lock-app ./out/darwin-x64-lock-${BUILD_VARIANT}/chip-lock-app \
--ota-provider-app ./out/darwin-x64-ota-provider-${BUILD_VARIANT}/chip-ota-provider-app \
--ota-requestor-app ./out/darwin-x64-ota-requestor-${BUILD_VARIANT}/chip-ota-requestor-app \
--tv-app ./out/darwin-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \
"
- name: Uploading core files
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ jobs:
--target linux-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT} \
--target linux-x64-all-clusters-${BUILD_VARIANT} \
--target linux-x64-lock-${BUILD_VARIANT} \
--target linux-x64-ota-provider-${BUILD_VARIANT} \
--target linux-x64-ota-requestor-${BUILD_VARIANT} \
--target linux-x64-tv-app-${BUILD_VARIANT} \
build \
--copy-artifacts-to objdir-clone \
Expand All @@ -97,6 +99,8 @@ jobs:
--iterations 1 \
--all-clusters-app ./out/linux-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
--lock-app ./out/linux-x64-lock-${BUILD_VARIANT}/chip-lock-app \
--ota-provider-app ./out/linux-x64-ota-provider-${BUILD_VARIANT}/chip-ota-provider-app \
--ota-requestor-app ./out/linux-x64-ota-requestor-${BUILD_VARIANT}/chip-ota-requestor-app \
--tv-app ./out/linux-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \
"
- name: Uploading core files
Expand Down Expand Up @@ -179,6 +183,8 @@ jobs:
--target darwin-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT} \
--target darwin-x64-all-clusters-${BUILD_VARIANT} \
--target darwin-x64-lock-${BUILD_VARIANT} \
--target darwin-x64-ota-provider-${BUILD_VARIANT} \
--target darwin-x64-ota-requestor-${BUILD_VARIANT} \
--target darwin-x64-tv-app-${BUILD_VARIANT} \
build \
--copy-artifacts-to objdir-clone \
Expand All @@ -194,6 +200,8 @@ jobs:
--iterations 1 \
--all-clusters-app ./out/darwin-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
--lock-app ./out/darwin-x64-lock-${BUILD_VARIANT}/chip-lock-app \
--ota-provider-app ./out/darwin-x64-ota-provider-${BUILD_VARIANT}/chip-ota-provider-app \
--ota-requestor-app ./out/darwin-x64-ota-requestor-${BUILD_VARIANT}/chip-ota-requestor-app \
--tv-app ./out/darwin-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \
"
- name: Uploading core files
Expand Down
2 changes: 2 additions & 0 deletions scripts/tests/chiptest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def AllTests(chip_tool: str):
target = TestTarget.TV
elif name.startswith('DL_'):
target = TestTarget.LOCK
elif name.startswith('OTA_'):
target = TestTarget.OTA
else:
target = TestTarget.ALL_CLUSTERS

Expand Down
13 changes: 12 additions & 1 deletion scripts/tests/chiptest/accessories.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def killAll(self):
def start(self, name, args):
accessory = self.__accessories[name]
if accessory:
# The args param comes directly from the sys.argv[1:] of Start.py and should contain a list of strings in
# The args param comes directly from the sys.argv[2:] of Start.py and should contain a list of strings in
carol-apple marked this conversation as resolved.
Show resolved Hide resolved
# key-value pair, e.g. [option1, value1, option2, value2, ...]
options = self.__createCommandLineOptions(args)
return accessory.start(options)
Expand Down Expand Up @@ -104,6 +104,14 @@ def waitForOperationalAdvertisement(self, name):
return accessory.waitForOperationalAdvertisement()
return False

def waitForMessage(self, name, message):
accessory = self.__accessories[name]
if accessory:
# The message param comes directly from the sys.argv[2:] of WaitForMessage.py and should contain a list of strings that
# comprise the entire message to wait for
return accessory.waitForMessage(' '.join(message))
return False

def __startXMLRPCServer(self):
self.server = SimpleXMLRPCServer((IP, PORT))

Expand All @@ -117,6 +125,9 @@ def __startXMLRPCServer(self):
self.server.register_function(
self.waitForOperationalAdvertisement,
'waitForOperationalAdvertisement')
self.server.register_function(
self.waitForMessage,
'waitForMessage')

self.server_thread = threading.Thread(target=self.server.serve_forever)
self.server_thread.start()
Expand Down
2 changes: 2 additions & 0 deletions scripts/tests/chiptest/linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,7 @@ def PathsWithNetworkNamespaces(paths: ApplicationPaths) -> ApplicationPaths:
chip_tool='ip netns exec tool'.split() + paths.chip_tool,
all_clusters_app='ip netns exec app'.split() + paths.all_clusters_app,
lock_app='ip netns exec app'.split() + paths.lock_app,
ota_provider_app='ip netns exec app'.split() + paths.ota_provider_app,
ota_requestor_app='ip netns exec app'.split() + paths.ota_requestor_app,
tv_app='ip netns exec app'.split() + paths.tv_app,
)
11 changes: 10 additions & 1 deletion scripts/tests/chiptest/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def waitForOperationalAdvertisement(self):
self.process, self.outpipe)
return True

def waitForMessage(self, message):
self.__waitFor(message, self.process, self.outpipe)
return True

def kill(self):
if self.process:
self.process.kill()
Expand Down Expand Up @@ -154,17 +158,20 @@ class TestTarget(Enum):
ALL_CLUSTERS = auto()
TV = auto()
LOCK = auto()
OTA = auto()


@dataclass
class ApplicationPaths:
chip_tool: typing.List[str]
all_clusters_app: typing.List[str]
lock_app: typing.List[str]
ota_provider_app: typing.List[str]
ota_requestor_app: typing.List[str]
tv_app: typing.List[str]

def items(self):
return [self.chip_tool, self.all_clusters_app, self.lock_app, self.tv_app]
return [self.chip_tool, self.all_clusters_app, self.lock_app, self.ota_provider_app, self.ota_requestor_app, self.tv_app]


@dataclass
Expand Down Expand Up @@ -225,6 +232,8 @@ def Run(self, runner, apps_register, paths: ApplicationPaths, pics_file: str):
target_app = paths.tv_app
elif self.target == TestTarget.LOCK:
target_app = paths.lock_app
elif self.target == TestTarget.OTA:
target_app = paths.ota_requestor_app
else:
raise Exception("Unknown test target - "
"don't know which application to run")
Expand Down
16 changes: 15 additions & 1 deletion scripts/tests/run_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ def cmd_list(context):
@click.option(
'--lock-app',
help='what lock app to use')
@click.option(
'--ota-provider-app',
help='what ota provider app to use')
@click.option(
'--ota-requestor-app',
help='what ota requestor app to use')
@click.option(
'--tv-app',
help='what tv app to use')
Expand All @@ -180,7 +186,7 @@ def cmd_list(context):
default="src/app/tests/suites/certification/ci-pics-values",
help='PICS file to use for test runs.')
@click.pass_context
def cmd_run(context, iterations, all_clusters_app, lock_app, tv_app, pics_file):
def cmd_run(context, iterations, all_clusters_app, lock_app, ota_provider_app, ota_requestor_app, tv_app, pics_file):
runner = chiptest.runner.Runner()

if all_clusters_app is None:
Expand All @@ -189,6 +195,12 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, tv_app, pics_file):
if lock_app is None:
lock_app = FindBinaryPath('chip-lock-app')

if ota_provider_app is None:
ota_provider_app = FindBinaryPath('chip-ota-provider-app')

if ota_requestor_app is None:
ota_requestor_app = FindBinaryPath('chip-ota-requestor-app')

if tv_app is None:
tv_app = FindBinaryPath('chip-tv-app')

Expand All @@ -197,6 +209,8 @@ def cmd_run(context, iterations, all_clusters_app, lock_app, tv_app, pics_file):
chip_tool=[context.obj.chip_tool],
all_clusters_app=[all_clusters_app],
lock_app=[lock_app],
ota_provider_app=[ota_provider_app],
ota_requestor_app=[ota_requestor_app],
tv_app=[tv_app]
)

Expand Down
177 changes: 177 additions & 0 deletions src/app/tests/suites/OTA_SuccessfulTransfer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
# Copyright (c) 2022 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Test OTA Software Update Successful Transfer

config:
endpoint: 0
requestorNodeId:
type: NODE_ID
defaultValue: 0x12344321
providerNodeId:
type: NODE_ID
defaultValue: 0xC0FFEE
providerPayload:
type: CHAR_STRING
defaultValue: "MT:-24J0IX4122-.548G00" # This value needs to be generated
carol-apple marked this conversation as resolved.
Show resolved Hide resolved
providerDiscriminator:
type: INT16U
defaultValue: 50
providerPort:
type: INT16U
defaultValue: 5560
providerKvs:
type: CHAR_STRING
defaultValue: "/tmp/chip_kvs_provider"
otaImageFilePath:
type: CHAR_STRING
defaultValue: "/tmp/otaImage"
rawImageFilePath:
type: CHAR_STRING
defaultValue: "/tmp/rawImage"
rawImageContent:
type: CHAR_STRING
defaultValue: "Have a hootenanny!"
downloadImageFilePath:
type: CHAR_STRING
defaultValue: "/tmp/downloadedImage"
tcarmelveilleux marked this conversation as resolved.
Show resolved Hide resolved

tests:
- label: "Create OTA image"
cluster: "SystemCommands"
command: "CreateOtaImage"
arguments:
values:
- name: "otaImageFilePath"
value: otaImageFilePath
- name: "rawImageFilePath"
value: rawImageFilePath
- name: "rawImageContent"
value: rawImageContent

- label: "Start the provider with an image"
cluster: "SystemCommands"
command: "Start"
arguments:
values:
- name: "registerKey"
value: "chip-ota-provider-app"
- name: "discriminator"
value: providerDiscriminator
- name: "port"
value: providerPort
- name: "kvs"
value: providerKvs
- name: "filepath"
value: otaImageFilePath

- label: "Commission the provider from alpha"
identity: "alpha"
cluster: "CommissionerCommands"
command: "PairWithQRCode"
arguments:
values:
- name: "nodeId"
value: providerNodeId
- name: "payload"
value: providerPayload

- label: "Wait for the commissioned provider to be retrieved for alpha"
identity: "alpha"
cluster: "DelayCommands"
command: "WaitForCommissionee"
arguments:
values:
- name: "nodeId"
value: providerNodeId

- label: "Install ACL for QueryImage"
cluster: "Access Control"
command: "writeAttribute"
attribute: "ACL"
arguments:
value: [
# Grant administer privilege to the default controller node ID 112233
{
FabricIndex: 1,
Privilege: 5,
AuthMode: 2,
Subjects: [112233],
Targets: null,
},
# Grant operate privileges to all nodes for the OTA Provider cluster on every endpoint
{
FabricIndex: 1,
Privilege: 3,
AuthMode: 2,
Subjects: null,
Targets: null,
[{ Cluster: 41, Endpoint: null, DeviceType: null }],
},
]

- label: "Stop the requestor"
carol-apple marked this conversation as resolved.
Show resolved Hide resolved
cluster: "SystemCommands"
command: "Stop"

- label: "Start the requestor with an OTA download path"
cluster: "SystemCommands"
command: "Start"
arguments:
values:
- name: "otaDownloadPath"
value: downloadImageFilePath

- label: "Wait for the commissioned requestor to be retrieved for alpha"
identity: "alpha"
cluster: "DelayCommands"
command: "WaitForCommissionee"
arguments:
values:
- name: "nodeId"
value: requestorNodeId

- label: "Send an announce OTA provider command to the requestor"
cluster: "OTA Software Update Requestor"
command: "AnnounceOtaProvider"
arguments:
values:
- name: "providerNodeId"
value: providerNodeId
- name: "vendorId"
value: 0
- name: "announcementReason"
value: 0
carol-apple marked this conversation as resolved.
Show resolved Hide resolved
- name: "endpoint"
value: endpoint

- label: "Wait for transfer complete message"
carol-apple marked this conversation as resolved.
Show resolved Hide resolved
cluster: "DelayCommands"
command: "WaitForMessage"
arguments:
values:
- name: "registerKey"
value: "default"
- name: "message"
value: "OTA image downloaded"

- label: "Compare original file to downloaded file"
cluster: "SystemCommands"
command: "CompareFiles"
arguments:
values:
- name: "file1"
value: rawImageFilePath
- name: "file2"
value: downloadImageFilePath
Loading