Skip to content

Commit

Permalink
SP-T172 Check logs
Browse files Browse the repository at this point in the history
Signed-off-by: Maarit Härkönen <[email protected]>
  • Loading branch information
maaharko committed Nov 15, 2024
1 parent 22baec0 commit 10a1075
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Robot-Framework/config/variables.robot
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Set Variables
Set Global Variable ${COMMS_VM} comms-vm
Set Global Variable ${APPFLOWY_VM} appflowy-vm
Set Global Variable ${BUSINESS_VM} business-vm
Set Global Variable ${ADMIN_VM} admin-vm
Set Global Variable @{VMS} ${GUI_VM} ${CHROMIUM_VM} ${GALA_VM} ${ZATHURA_VM} ${COMMS_VM} ${BUSINESS_VM} ${ADMIN_VM}

IF $BUILD_ID != '${EMPTY}'
${config}= Read Config ../config/${BUILD_ID}.json
Expand Down
33 changes: 33 additions & 0 deletions Robot-Framework/resources/connection_keywords.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2022-2024 Technology Innovation Institute (TII)
# SPDX-License-Identifier: Apache-2.0

*** Settings ***
Resource ../config/variables.robot


*** Keywords ***
Configure wifi
[Arguments] ${netvm_ssh} ${SSID} ${passw}
Switch Connection ${netvm_ssh}
Log To Console Configuring Wifi
Set Log Level NONE
Execute Command nmcli dev wifi connect ${SSID} password ${passw} sudo=True sudo_password=${PASSWORD}
Set Log Level INFO

Remove Wifi configuration
[Arguments] ${SSID}
Switch Connection ${netvm_ssh}
Log To Console Removing Wifi configuration
Execute Command nmcli connection delete id ${SSID}

Turn OFF WiFi
[Arguments] ${SSID}
Switch Connection ${netvm_ssh}
Log To Console Turning off Wifi
Execute Command nmcli con down id ${SSID} sudo=True sudo_password=${PASSWORD}

Turn ON WiFi
[Arguments] ${SSID}
Switch Connection ${netvm_ssh}
Log To Console Turning on Wifi
Execute Command nmcli con up id ${SSID} sudo=True sudo_password=${PASSWORD}
28 changes: 1 addition & 27 deletions Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Documentation Testing Network VM
Force Tags netvm
Resource ../../resources/ssh_keywords.resource
Resource ../../resources/virtualization_keywords.resource
Resource ../../resources/connection_keywords.resource
Resource ../../config/variables.robot
Suite Teardown Close All Connections

Expand Down Expand Up @@ -94,33 +95,6 @@ Restart NetVM
Start NetVM
Check if ssh is ready on netvm

Configure wifi
[Arguments] ${netvm_ssh} ${SSID} ${passw}
Switch Connection ${netvm_ssh}
Log To Console Configuring Wifi
Set Log Level NONE
Execute Command nmcli dev wifi connect ${SSID} password ${passw} sudo=True sudo_password=${PASSWORD}
Set Log Level INFO

Remove Wifi configuration
[Arguments] ${SSID}
Switch Connection ${netvm_ssh}
Log To Console Removing Wifi configuration
Execute Command nmcli connection delete id ${SSID}

Turn OFF WiFi
[Arguments] ${SSID}
Switch Connection ${netvm_ssh}
Log To Console Turning off Wifi
Execute Command nmcli con down id ${SSID} sudo=True sudo_password=${PASSWORD}

Turn ON WiFi
[Arguments] ${SSID}
Switch Connection ${netvm_ssh}
Log To Console Turning on Wifi
Execute Command nmcli con up id ${SSID} sudo=True sudo_password=${PASSWORD}


Stop NetVM
[Documentation] Ensure that NetVM is started, stop it and check the status.
... Pre-condition: requires active ssh connection to ghaf host.
Expand Down
50 changes: 50 additions & 0 deletions Robot-Framework/test-suites/logging-tests/check_logs.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: 2022-2024 Technology Innovation Institute (TII)
# SPDX-License-Identifier: Apache-2.0

*** Settings ***
Documentation Testing logging
Force Tags logging lenovo-x1
Resource ../../config/variables.robot
Resource ../../resources/ssh_keywords.resource
Resource ../../resources/connection_keywords.resource
Library DateTime
Suite Setup Set Variables ${DEVICE}
Suite Teardown Close All Connections


*** Variables ***
${NETVM_SSH} ${EMPTY}
${GRAFANA_LOGS} https://loki.ghaflogs.vedenemo.dev


*** Test Cases ***
Check Grafana logs
[Documentation] Check that all virtual machines are sending logs to Grafana
[Tags] SP-T172
[Setup] Connect to netvm
[Teardown] Remove Wifi configuration ${TEST_WIFI_SSID}
Configure wifi ${NETVM_SSH} ${TEST_WIFI_SSID} ${TEST_WIFI_PSWD}
Check Internet Connection
Connect to ghaf host
${mac} Execute Command cat /var/lib/private/alloy/MACAddress sudo=True sudo_password=${PASSWORD}
${date} DateTime.Get Current Date result_format=%Y-%m-%d
Wait Until Keyword Succeeds 60s 2s Check Logs Are available ${date} ${mac}


*** Keywords ***
Check Internet Connection
[Documentation] Check that DUT is able to connect to internet
${output} Execute Command ping -c1 google.com
Should Contain ${output} 1 received

Check Logs Are available
[Documentation] Check that virtual machine's logs are available in Grafana
[Arguments] ${date} ${mac}
FOR ${vm} IN @{VMS}
Set Log Level NONE
${out} Run logcli query --addr="${GRAFANA_LOGS}" --password="${PASSWORD}" --username="${LOGIN}" '{systemdJournalLogs="${mac}", nodename="${vm}"}'
Set Log Level INFO
Log ${out}
Run Keyword And Continue On Failure Should Contain ${out} ${date}
Run Keyword And Continue On Failure Should Not Contain ${out} Query failed
END

0 comments on commit 10a1075

Please sign in to comment.