Skip to content

Commit

Permalink
[BDX:DiagnosticLog] Update the server such that it supports multiple …
Browse files Browse the repository at this point in the history
…downloads in parallel
  • Loading branch information
vivien-apple committed Feb 2, 2024
1 parent 67504b1 commit e84e3fb
Show file tree
Hide file tree
Showing 9 changed files with 692 additions and 232 deletions.
285 changes: 285 additions & 0 deletions src/app/tests/suites/TestDiagnosticLogs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ config:
nodeId: 0x12344321
cluster: "Diagnostic Logs"
endpoint: 0
timeout: 120
end_user_support_log_file_path: "/tmp/end_user_support_log.txt"
end_user_support_log_file_content: "End User Support Log Content"
end_user_support_log_file_content_long:
Expand All @@ -31,6 +32,113 @@ config:
bdx_transfer_file_path: "/tmp/end_user_support_bdx_output.txt"
bdx_transfer_file_name: "end_user_support_bdx_output.txt"

bdx_transfer_file_path_1: "/tmp/bdx_log_output_1.txt"
bdx_transfer_file_name_1: "bdx_log_output_1.txt"
bdx_transfer_file_path_2: "/tmp/bdx_log_output_2.txt"
bdx_transfer_file_name_2: "bdx_log_output_2.txt"

long_log_file_content:
"This is a long log content...
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
.......................................................
......................................................."

tests:
#
# Set up the test by adding some destination log files for the target accessory:
Expand Down Expand Up @@ -658,3 +766,180 @@ tests:
values:
- name: "filePath"
value: bdx_transfer_file_path

#
# Validate that multiple BDX transfers can run in parallels.
#
- label: "Delete possible leftover from previous run"
cluster: "SystemCommands"
command: "DeleteFile"
arguments:
values:
- name: "filePath"
value: bdx_transfer_file_path_1

- label: "Delete possible leftover from previous run"
cluster: "SystemCommands"
command: "DeleteFile"
arguments:
values:
- name: "filePath"
value: bdx_transfer_file_path_2

- label: "Update End User Support logs with a long log"
cluster: "SystemCommands"
command: "CreateFile"
arguments:
values:
- name: "filePath"
value: end_user_support_log_file_path
- name: "fileContent"
value: long_log_file_content

- label: "Update Network Diagnostic logs with a long log"
cluster: "SystemCommands"
command: "CreateFile"
arguments:
values:
- name: "filePath"
value: network_diagnostics_log_file_path
- name: "fileContent"
value: long_log_file_content

- label: "Start a second accessory"
cluster: "SystemCommands"
command: "Start"
arguments:
values:
- name: "discriminator"
value: 50
- name: "port"
value: 5601
- name: "kvs"
value: "/tmp/chip_kvs_second"
- name: "endUserSupportLogPath"
value: end_user_support_log_file_path
- name: "networkDiagnosticsLogPath"
value: network_diagnostics_log_file_path
- name: "registerKey"
value: "default#2"

- label: "Commission second accessory from beta"
identity: "beta"
cluster: "CommissionerCommands"
command: "PairWithCode"
arguments:
values:
- name: "nodeId"
value: nodeId
- name: "payload"
value: "MT:-24J0IX4122-.548G00"

- label: "Wait for the second commissioned device to be retrieved for beta"
identity: "beta"
cluster: "DelayCommands"
command: "WaitForCommissionee"
arguments:
values:
- name: "nodeId"
value: nodeId

- label: "BDX: Request End User Support from the first accessory"
command: "RetrieveLogsRequest"
identity: "alpha"
arguments:
values:
- name: "Intent"
value: 1 # NetworkDiagnostics
- name: "RequestedProtocol"
value: 1 # BDX
- name: "TransferFileDesignator"
value: bdx_transfer_file_name_1
response:
values:
- name: "Status"
value: 0 # Success
- name: "LogContent"
value: ""

- label: "BDX: Request End User Support from the second accessory"
command: "RetrieveLogsRequest"
identity: "beta"
arguments:
values:
- name: "Intent"
value: 1 # NetworkDiagnostics
- name: "RequestedProtocol"
value: 1 # BDX
- name: "TransferFileDesignator"
value: bdx_transfer_file_name_2
response:
values:
- name: "Status"
value: 0 # Success
- name: "LogContent"
value: ""

- label:
"BDX: Wait for 'Diagnostic logs transfer: Success' message from the
first accessory"
cluster: "DelayCommands"
command: "WaitForMessage"
arguments:
values:
- name: "registerKey"
value: "default"
- name: "message"
value: "Diagnostic logs transfer: Success"

- label:
"BDX: Wait for 'Diagnostic logs transfer: Success' message from the
second accessory"
cluster: "DelayCommands"
command: "WaitForMessage"
arguments:
values:
- name: "registerKey"
value: "default#2"
- name: "message"
value: "Diagnostic logs transfer: Success"

- label:
"Compare the content the original log and the file that has been
created as the result of the BDX transfer"
cluster: "SystemCommands"
command: "CompareFiles"
arguments:
values:
- name: "file1"
value: end_user_support_log_file_path
- name: "file2"
value: bdx_transfer_file_path_1

- label:
"Compare the content the original log and the file that has been
created as the result of the BDX transfer"
cluster: "SystemCommands"
command: "CompareFiles"
arguments:
values:
- name: "file1"
value: network_diagnostics_log_file_path
- name: "file2"
value: bdx_transfer_file_path_2

- label: "Delete the result of the previous run"
cluster: "SystemCommands"
command: "DeleteFile"
arguments:
values:
- name: "filePath"
value: bdx_transfer_file_path_1

- label: "Delete the result of the previous run"
cluster: "SystemCommands"
command: "DeleteFile"
arguments:
values:
- name: "filePath"
value: bdx_transfer_file_path_2
2 changes: 1 addition & 1 deletion src/controller/CHIPDeviceControllerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ CHIP_ERROR DeviceControllerFactory::InitSystemState(FactoryInitParams params)
ReturnErrorOnFailure(stateParams.exchangeMgr->Init(stateParams.sessionMgr));
ReturnErrorOnFailure(stateParams.messageCounterManager->Init(stateParams.exchangeMgr));
ReturnErrorOnFailure(stateParams.unsolicitedStatusHandler->Init(stateParams.exchangeMgr));
ReturnErrorOnFailure(stateParams.bdxTransferServer->ListenForSendInit(stateParams.systemLayer, stateParams.exchangeMgr));
ReturnErrorOnFailure(stateParams.bdxTransferServer->Init(stateParams.systemLayer, stateParams.exchangeMgr));

InitDataModelHandler();

Expand Down
11 changes: 11 additions & 0 deletions src/lib/core/CHIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,17 @@ extern const char CHIP_NON_PRODUCTION_MARKER[];
#define CHIP_CONFIG_ENABLE_BDX_LOG_TRANSFER 0
#endif

/**
* @def CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS
*
* @brief
* Maximum number of simultaneously active bdx log transfers.
*
*/
#ifndef CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS
#define CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS 5
#endif // CHIP_CONFIG_MAX_BDX_LOG_TRANSFERS

/**
* @}
*/
3 changes: 3 additions & 0 deletions src/protocols/bdx/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ static_library("bdx") {
sources = [
"BdxMessages.cpp",
"BdxMessages.h",
"BdxTransferDiagnosticLog.cpp",
"BdxTransferDiagnosticLog.h",
"BdxTransferDiagnosticLogPool.h",
"BdxTransferProxy.h",
"BdxTransferProxyDiagnosticLog.cpp",
"BdxTransferProxyDiagnosticLog.h",
Expand Down
Loading

0 comments on commit e84e3fb

Please sign in to comment.