Skip to content

Commit

Permalink
Add boot test for LenovoX1
Browse files Browse the repository at this point in the history
Signed-off-by: Mariia Azbeleva <[email protected]>
  • Loading branch information
azbeleva committed Dec 13, 2023
1 parent f35dc53 commit 8a406ee
Show file tree
Hide file tree
Showing 10 changed files with 2,584 additions and 25 deletions.
7 changes: 6 additions & 1 deletion Jenkinsfiles/hw_test_set
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pipeline {
deviceName = 'OrinNX1'
} else if (params.device == "riscv"){
deviceName = 'Polarfire1'
} else if (params.device == "lenovo-x1"){
deviceName = 'LenovoX1-1'
}
} else if ("${params.label}" == "tc-agent03"){
if (params.device == "orin-agx"){
Expand All @@ -52,6 +54,8 @@ pipeline {
deviceName = 'OrinNX2'
} else if (params.device == "riscv"){
deviceName = 'Polarfire1'
} else if (params.device == "lenovo-x1"){
deviceName = 'LenovoX1-1'
}
}
echo "DEVICE: ${deviceName}"
Expand Down Expand Up @@ -144,7 +148,8 @@ pipeline {
parameters: [
[$class: 'StringParameterValue', name: 'RF_SUITE', value: "${bootSuite}"],
[$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"],
[$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"]
[$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"],
[$class: 'StringParameterValue', name: 'INCLD_TAG', value: "bootAND${params.device}"]
]
)

Expand Down
12 changes: 7 additions & 5 deletions Robot-Framework/config/variables.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ Library OperatingSystem

*** Variables ***

${BUILD_ID} ${EMPTY}
${BUILD_ID} ${EMPTY}
${SWITCH_TOKEN} ${EMPTY}
${SWITCH_SECRET} ${EMPTY}


*** Keywords ***
Expand All @@ -24,10 +26,10 @@ Set Variables
Set Global Variable ${NETVM_NAME} net-vm
Set Global Variable ${NETVM_SERVICE} microvm@${NETVM_NAME}.service
Set Global Variable ${NETVM_IP} 192.168.101.1
Set Global Variable ${GUI_VM} gui-vm.ghaf
Set Global Variable ${CHROMIUM_VM} chromium-vm.ghaf
Set Global Variable ${GALA_VM} gala-vm.ghaf
Set Global Variable ${ZATHURA_VM} zathura-vm.ghaf
Set Global Variable ${GUI_VM} gui-vm.ghaf # 192.168.100.2
Set Global Variable ${CHROMIUM_VM} chromium-vm.ghaf # 192.168.100.4
Set Global Variable ${GALA_VM} gala-vm.ghaf # 192.168.100.3
Set Global Variable ${ZATHURA_VM} zathura-vm.ghaf # 192.168.100.5

IF $BUILD_ID != '${EMPTY}'
${config}= Read Config ../config/${BUILD_ID}.json
Expand Down
64 changes: 64 additions & 0 deletions Robot-Framework/lib/SwitchbotLibrary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import time
import hmac
import hashlib
import base64
import requests
import uuid

class SwitchbotLibrary:
def __init__(self, token, secret):
self.token = token
self.secret = secret
self.base_url = 'https://api.switch-bot.com/v1.1/devices'
self.signature, self.timestamp, self.nonce = self.generate_signature()
self.device_id = ''

def generate_signature(self):
nonce = str(uuid.uuid4())
timestamp = int(round(time.time() * 1000))
message = f'{self.token}{timestamp}{nonce}'.encode('utf-8')
secret_enc = self.secret.encode('utf-8')
signature = base64.b64encode(hmac.new(secret_enc, msg=message, digestmod=hashlib.sha256).digest()).decode('utf-8')
return signature, timestamp, nonce

def get_devices(self):
headers = {
'Authorization': self.token,
'sign': self.signature,
'nonce': self.nonce,
't': str(self.timestamp),
'Content-Type': 'application/json',
}
response = requests.get(self.base_url, headers=headers)
print(response.json())
return response.json()

def get_device_id(self, device_name):
devices_data = self.get_devices()
if 'body' in devices_data and 'deviceList' in devices_data['body']:
for device in devices_data['body']['deviceList']:
if device['deviceName'] == device_name:
return device['deviceId']
return None

def send_command(self, command):
headers = {
'Authorization': self.token,
'sign': self.signature,
'nonce': self.nonce,
't': str(self.timestamp),
'Content-Type': 'application/json',
}
url = f'{self.base_url}/{self.device_id}/commands'
response = requests.post(url, headers=headers, json=command)
print(response.json())
assert response.json()['message'] == 'success'

def press_button(self, device_name):
self.device_id = self.get_device_id(device_name)
command = {
"command": "press",
"parameter": "default",
"commandType": "command"
}
return self.send_command(command)
2 changes: 1 addition & 1 deletion Robot-Framework/test-suites/bat-tests/apps.robot
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Start Firefox

Start Chromium on LenovoX1
[Documentation] Start Chromium in dedicated VM and verify process started
[Tags] bat SP-T97 lenovoX1
[Tags] bat SP-T97 lenovo-x1
[Setup] Connect to netvm
Connect to guivm
Start Chromium
Expand Down
10 changes: 5 additions & 5 deletions Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ ${netvm_ssh} ${EMPTY}

Verify NetVM is started
[Documentation] Verify that NetVM is active and running
[Tags] bat SP-T49 nuc orin-agx orin-nx lenovoX1
[Tags] bat SP-T49 nuc orin-agx orin-nx lenovo-x1
[Setup] Connect to ghaf host
Verify service status service=${netvm_service}
Check Network Availability ${netvm_ip} expected_result=True range=5
[Teardown] Close All Connections

Wifi passthrought into NetVM
[Documentation] Verify that wifi works inside netvm
[Tags] bat SP-T50 nuc orin-agx lenovoX1
[Tags] bat SP-T50 nuc orin-agx lenovo-x1
... test:retry(1)
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm AND
Expand All @@ -47,14 +47,14 @@ Wifi passthrought into NetVM

NetVM stops and starts successfully
[Documentation] Verify that NetVM stops properly and starts after that
[Tags] bat SP-T52 nuc orin-agx orin-nx lenovoX1
[Tags] bat SP-T52 nuc orin-agx orin-nx lenovo-x1
[Setup] Connect to ghaf host
Restart NetVM
[Teardown] Run Keywords Start NetVM if dead AND Close All Connections

NetVM is wiped after restarting
[Documentation] Verify that created file will be removed after restarting VM
[Tags] bat SP-T53 nuc orin-agx orin-nx lenovoX1
[Tags] bat SP-T53 nuc orin-agx orin-nx lenovo-x1
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm
Switch Connection ${netvm_ssh}
Expand All @@ -71,7 +71,7 @@ NetVM is wiped after restarting

Verify wpa_supplicant.service is running
[Documentation] Verify that wpa_supplicant.service exists and is running
[Tags] bat SP-T82 nuc orin-agx lenovoX1
[Tags] bat SP-T82 nuc orin-agx lenovo-x1
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm
Switch Connection ${netvm_ssh}
Expand Down
4 changes: 2 additions & 2 deletions Robot-Framework/test-suites/bat-tests/others.robot
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ Resource ../../resources/ssh_keywords.resource
Test ghaf version format
[Documentation] Test getting Ghaf version and verify its format:
... Expected format: major.minor.yyyymmdd.commit_hash
[Tags] bat SP-T59 nuc orin-agx orin-nx riscv lenovoX1
[Tags] bat SP-T59 nuc orin-agx orin-nx riscv lenovo-x1
[Setup] Connect
Verify Ghaf Version Format
[Teardown] Close All Connections

Test nixos version format
[Documentation] Test getting Nixos version and verify its format:
... Expected format: major.minor.yyyymmdd.commit_hash (name)
[Tags] bat SP-T60 nuc orin-agx orin-nx riscv lenovoX1
[Tags] bat SP-T60 nuc orin-agx orin-nx riscv lenovo-x1
[Setup] Connect
Verify Nixos Version Format
[Teardown] Close All Connections
Expand Down
32 changes: 29 additions & 3 deletions Robot-Framework/test-suites/boot-test/boot_test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Documentation Testing target device booting up.
Force Tags ssh_boot_test
Library ../../lib/PlugLibrary/PlugLibrary.py ${PLUG_TYPE}
Library ../../lib/SwitchbotLibrary.py ${SWITCH_TOKEN} ${SWITCH_SECRET}
Resource ../../resources/serial_keywords.resource
Resource ../../resources/ssh_keywords.resource
Resource ../../config/variables.robot
Expand All @@ -19,7 +20,7 @@ ${IS_AVAILABLE} False

Verify booting after restart by power
[Documentation] Restart device by power and verify init service is running
[Tags] boot plug
[Tags] boot plug nuc orin-agx orin-nx riscv
Reboot Device
Check If Device Is Up
IF ${IS_AVAILABLE} == False
Expand All @@ -35,6 +36,22 @@ Verify booting after restart by power
END
[Teardown] Teardown

Verify booting LenovoX1
[Documentation] Restart LenovoX1 by power and verify init service is running
[Tags] boot plug lenovo-x1
Reboot LenovoX1
Check If Device Is Up
IF ${IS_AVAILABLE} == False
FAIL The device did not start
ELSE
Log To Console The device started
END

Connect
Verify service status service=init.scope

[Teardown] Teardown


*** Keywords ***

Expand Down Expand Up @@ -82,10 +99,19 @@ Check If Device Is Up
END

Reboot Device
[Arguments] ${delay}=5
[Documentation] Turn off power of devicee, wait for given amount of seconds and turn on the power
[Arguments] ${delay}=5
[Documentation] Turn off power of device, wait for given amount of seconds and turn on the power
Log To Console ${\n}Turning device off...
Turn Plug Off
Sleep ${delay}
Log To Console Turning device on...
Turn Plug On

Reboot LenovoX1
[Arguments] ${delay}=20
[Documentation] Turn off the laptop by pressing power button for 10 sec turn on by short pressing power button
Log To Console ${\n}Turning device off...
Press Button ${DEVICE}-OFF
Sleep ${delay}
Log To Console Turning device on...
Press Button ${DEVICE}-ON
4 changes: 2 additions & 2 deletions Robot-Framework/test-suites/performance-tests/network.robot
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Suite Teardown Close All Connections

TCP speed test
[Documentation] Measure RX and TX speed for TCP
[Tags] tcp SP-T91 nuc orin-agx orin-nx riscv lenovoX1
[Tags] tcp SP-T91 nuc orin-agx orin-nx riscv lenovo-x1
Run iperf server on DUT
&{tcp_speed} Run TCP test
Save Speed Data ${TEST NAME} ${tcp_speed}
Expand All @@ -27,7 +27,7 @@ TCP speed test

UDP speed test
[Documentation] Measure RX and TX speed for UDP
[Tags] udp SP-T92 nuc orin-agx orin-nx riscv lenovoX1
[Tags] udp SP-T92 nuc orin-agx orin-nx riscv lenovo-x1
Run iperf server on DUT
&{udp_speed} Run UDP test
Save Speed Data ${TEST NAME} ${udp_speed}
Expand Down
12 changes: 6 additions & 6 deletions Robot-Framework/test-suites/performance-tests/performance.robot
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ CPU One thread test
[Documentation] Run a CPU benchmark using Sysbench with a duration of 10 seconds and a SINGLE thread.
... The benchmark records to csv CPU events per second, events per thread, and latency data.
... Create visual plots to represent these metrics comparing to previous tests.
[Tags] cpu SP-T67-1 nuc orin-agx orin-nx lenovoX1
[Tags] cpu SP-T67-1 nuc orin-agx orin-nx lenovo-x1
${output} Execute Command sysbench cpu --time=10 --threads=1 --cpu-max-prime=20000 run
Log ${output}
&{cpu_data} Parse Cpu Results ${output}
Expand All @@ -29,7 +29,7 @@ CPU multimple threads test
[Documentation] Run a CPU benchmark using Sysbench with a duration of 10 seconds and MULTIPLE threads.
... The benchmark records to csv CPU events per second, events per thread, and latency data.
... Create visual plots to represent these metrics comparing to previous tests.
[Tags] cpu SP-T67-2 nuc orin-agx orin-nx lenovoX1
[Tags] cpu SP-T67-2 nuc orin-agx orin-nx lenovo-x1
${output} Execute Command sysbench cpu --time=10 --threads=${threads_number} --cpu-max-prime=20000 run
Log ${output}
&{cpu_data} Parse Cpu Results ${output}
Expand All @@ -41,7 +41,7 @@ Memory Read One thread test
... The benchmark records Operations Per Second, Data Transfer Speed, Average Events per Thread,
... and Latency for READ operations.
... Create visual plots to represent these metrics comparing to previous tests.
[Tags] cpu SP-T67-3 nuc orin-agx orin-nx lenovoX1
[Tags] cpu SP-T67-3 nuc orin-agx orin-nx lenovo-x1
${output} Execute Command sysbench memory --time=60 --memory-oper=read --threads=1 run
Log ${output}
&{cpu_data} Parse Memory Results ${output}
Expand All @@ -53,7 +53,7 @@ Memory Write One thread test
... The benchmark records Operations Per Second, Data Transfer Speed, Average Events per Thread,
... and Latency for WRITE operations.
... Create visual plots to represent these metrics comparing to previous tests.
[Tags] cpu SP-T67-4 nuc orin-agx orin-nx lenovoX1
[Tags] cpu SP-T67-4 nuc orin-agx orin-nx lenovo-x1
${output} Execute Command sysbench memory --time=60 --memory-oper=write --threads=1 run
Log ${output}
&{cpu_data} Parse Memory Results ${output}
Expand All @@ -65,7 +65,7 @@ Memory Read multimple threads test
... The benchmark records Operations Per Second, Data Transfer Speed, Average Events per Thread,
... and Latency for READ operations.
... Create visual plots to represent these metrics comparing to previous tests.
[Tags] cpu SP-T67-5 nuc orin-agx orin-nx lenovoX1
[Tags] cpu SP-T67-5 nuc orin-agx orin-nx lenovo-x1
${output} Execute Command sysbench memory --time=60 --memory-oper=read --threads=${threads_number} run
Log ${output}
&{cpu_data} Parse Memory Results ${output}
Expand All @@ -77,7 +77,7 @@ Memory Write multimple threads test
... The benchmark records Operations Per Second, Data Transfer Speed, Average Events per Thread,
... and Latency for WRITE operations.
... Create visual plots to represent these metrics comparing to previous tests.
[Tags] cpu SP-T67-6 nuc orin-agx orin-nx lenovoX1
[Tags] cpu SP-T67-6 nuc orin-agx orin-nx lenovo-x1
${output} Execute Command sysbench memory --time=60 --memory-oper=write --threads=${threads_number} run
Log ${output}
&{cpu_data} Parse Memory Results ${output}
Expand Down
Loading

0 comments on commit 8a406ee

Please sign in to comment.