From 10a107552c88197bcc61479cd366e7238d20a347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maarit=20H=C3=A4rk=C3=B6nen?= Date: Wed, 18 Sep 2024 11:52:44 +0300 Subject: [PATCH] SP-T172 Check logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maarit Härkönen --- Robot-Framework/config/variables.robot | 2 + .../resources/connection_keywords.resource | 33 ++++++++++++ .../test-suites/bat-tests/netvm.robot | 28 +---------- .../logging-tests/check_logs.robot | 50 +++++++++++++++++++ 4 files changed, 86 insertions(+), 27 deletions(-) create mode 100644 Robot-Framework/resources/connection_keywords.resource create mode 100644 Robot-Framework/test-suites/logging-tests/check_logs.robot diff --git a/Robot-Framework/config/variables.robot b/Robot-Framework/config/variables.robot index 5ca0ad4..78ee733 100644 --- a/Robot-Framework/config/variables.robot +++ b/Robot-Framework/config/variables.robot @@ -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 diff --git a/Robot-Framework/resources/connection_keywords.resource b/Robot-Framework/resources/connection_keywords.resource new file mode 100644 index 0000000..8553e2c --- /dev/null +++ b/Robot-Framework/resources/connection_keywords.resource @@ -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} diff --git a/Robot-Framework/test-suites/bat-tests/netvm.robot b/Robot-Framework/test-suites/bat-tests/netvm.robot index aaaa362..027215a 100644 --- a/Robot-Framework/test-suites/bat-tests/netvm.robot +++ b/Robot-Framework/test-suites/bat-tests/netvm.robot @@ -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 @@ -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. diff --git a/Robot-Framework/test-suites/logging-tests/check_logs.robot b/Robot-Framework/test-suites/logging-tests/check_logs.robot new file mode 100644 index 0000000..f493606 --- /dev/null +++ b/Robot-Framework/test-suites/logging-tests/check_logs.robot @@ -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