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

Adding missing tests for c8y-log-manager and fixing a bug that causes mqtt actor termination #2161

Merged
merged 2 commits into from
Aug 21, 2023
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
6 changes: 5 additions & 1 deletion crates/extensions/c8y_log_manager/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ impl LogManagerActor {
let error_message = format!("Handling of operation failed with {}", error);
let failed_msg = LogfileRequest::failed(error_message)?;
self.mqtt_publisher.send(failed_msg).await?;
Err(error)
error!(
"Handling of operation for log type {} failed with: {}",
smartrest_request.log_type, error
);
Ok(())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
files = [{ type = "example", path = "/var/log/example/example.log" }]
4 changes: 4 additions & 0 deletions tests/RobotFramework/tests/cumulocity/log/example.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
first line
second line
third line
another sentence
45 changes: 45 additions & 0 deletions tests/RobotFramework/tests/cumulocity/log/log_operation.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
*** Settings ***
Resource ../../../resources/common.resource
Library Cumulocity
Library DateTime
Library ThinEdgeIO

Suite Setup Custom Setup
Test Setup Test Setup
Test Teardown Get Logs

Test Tags theme:c8y theme:log


*** Test Cases ***
Successful log operation
${end_timestamp}= get current date result_format=%Y-%m-%dT%H:%M:%S+0000
${operation}= Cumulocity.Create Operation
... description=Log file request
... fragments={"c8y_LogfileRequest":{"dateFrom":"1970-01-01T00:00:00+0000","dateTo":"${end_timestamp}","logFile":"example","searchText":"first","maximumLines":10}}
${operation}= Operation Should Be SUCCESSFUL ${operation} timeout=120

Request with non-existing log type
${end_timestamp}= get current date result_format=%Y-%m-%dT%H:%M:%S+0000
${operation}= Cumulocity.Create Operation
... description=Log file request
... fragments={"c8y_LogfileRequest":{"dateFrom":"1970-01-01T00:00:00+0000","dateTo":"${end_timestamp}","logFile":"example1","searchText":"first","maximumLines":10}}
Operation Should Be FAILED
... ${operation}
... failure_reason=.*No such file or directory for log type: example1
... timeout=120


*** Keywords ***
Test Setup
ThinEdgeIO.Transfer To Device ${CURDIR}/c8y-log-plugin.toml /etc/tedge/c8y/c8y-log-plugin.toml
ThinEdgeIO.Transfer To Device ${CURDIR}/example.log /var/log/example/
Execute Command chown root:root /etc/tedge/c8y/c8y-log-plugin.toml /var/log/example/example.log
ThinEdgeIO.Restart Service c8y-log-plugin
ThinEdgeIO.Service Health Status Should Be Up c8y-log-plugin
ThinEdgeIO.Service Health Status Should Be Up tedge-mapper-c8y

Custom Setup
${DEVICE_SN}= Setup
Set Suite Variable $DEVICE_SN
Device Should Exist ${DEVICE_SN}