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

Add workflow to run tests on real hardware #2545

Merged
merged 13 commits into from
Oct 29, 2024
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
93 changes: 93 additions & 0 deletions .github/workflows/run-nightly-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
name: run-nightly-tests

on:
workflow_dispatch:
schedule:
- cron: '0 01 * * *'

jobs:
nightly-tests:
runs-on: nvme-nvm
steps:
- name: Output kernel version
run: |
uname -a
- name: Clean up test device
run: |
#BDEV0 is an environment variable of the self-hosted runner instance
#that contains a valid nvme ctrl name which is capable of the nvm
#command set.
CONTROLLER=$(echo /dev/${BDEV0} | sed 's/n[0-9]*$//')
sudo nvme delete-ns $CONTROLLER -n 0xffffffff
sudo nvme format $CONTROLLER -n 0xffffffff -l 0 -f
SIZE=$(sudo nvme id-ctrl $CONTROLLER --output-format=json | jq -r '{tnvmcap} | .[]' | awk '{print $1/512}')
sudo nvme create-ns -s $SIZE -c $SIZE -f 0 -d 0 --csi=0 $CONTROLLER
sudo nvme attach-ns $CONTROLLER -n 1 -c 0
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
meson gcc pkg-config git libjson-c-dev libssl-dev libkeyutils-dev \
libdbus-1-dev libpython3-dev pipx python3-dev swig xz-utils
igaw marked this conversation as resolved.
Show resolved Hide resolved
pipx ensurepath
sudo PIPX_BIN_DIR=/usr/local/bin pipx install nose2
sudo PIPX_BIN_DIR=/usr/local/bin pipx install flake8
sudo PIPX_BIN_DIR=/usr/local/bin pipx install mypy
sudo PIPX_BIN_DIR=/usr/local/bin pipx install autopep8
sudo PIPX_BIN_DIR=/usr/local/bin pipx install isort
- name: Build and install nvme-cli
run: |
scripts/build.sh -b release -c gcc
sudo meson install -C .build-ci
sudo ldconfig /usr/local/lib64
- name: Overwrite test config
run: |
CONTROLLER=$(echo /dev/${BDEV0} | sed 's/n[0-9]*$//')
cat > tests/config.json << EOF
{
"controller" : "$CONTROLLER",
"ns1": "/dev/${BDEV0}",
"log_dir": "tests/nvmetests/"
}
EOF
- name: Run on device tests
run: |
sudo nose2 --verbose --start-dir tests \
nvme_attach_detach_ns_test \
nvme_compare_test \
nvme_copy_test \
nvme_create_max_ns_test \
nvme_ctrl_reset_test \
nvme_dsm_test \
nvme_error_log_test \
nvme_flush_test \
nvme_format_test \
nvme_fw_log_test \
nvme_get_features_test \
nvme_get_lba_status_test \
nvme_id_ctrl_test \
nvme_id_ns_test \
nvme_lba_status_log_test \
nvme_read_write_test \
nvme_smart_log_test \
nvme_verify_test \
nvme_writeuncor_test \
nvme_writezeros_test
- name: Upload logs
uses: actions/upload-artifact@v4
if: always()
with:
name: logs files
path: |
./tests/nvmetests/**/*.log
- name: Clean up test device
if: always()
run: |
CONTROLLER=$(echo /dev/${BDEV0} | sed 's/n[0-9]*$//')
sudo nvme delete-ns $CONTROLLER -n 0xffffffff
sudo nvme format $CONTROLLER -n 0xffffffff -l 0 -f
SIZE=$(sudo nvme id-ctrl $CONTROLLER --output-format=json | jq -r '{tnvmcap} | .[]' | awk '{print $1/512}')
sudo nvme create-ns -s $SIZE -c $SIZE -f 0 -d 0 --csi=0 $CONTROLLER
sudo nvme attach-ns $CONTROLLER -n 1 -c 0
6 changes: 4 additions & 2 deletions tests/nvme_attach_detach_ns_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def setUp(self):
super().setUp()
self.dps = 0
self.flbas = 0
self.nsze = 0x1400000
self.ncap = 0x1400000
(ds, ms) = self.get_lba_format_size()
ncap = int(self.get_ncap() / (ds+ms))
self.nsze = ncap
self.ncap = ncap
self.setup_log_dir(self.__class__.__name__)
self.ctrl_id = self.get_ctrl_id()
self.delete_all_ns()
Expand Down
11 changes: 11 additions & 0 deletions tests/nvme_compare_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,20 @@ class TestNVMeCompareCmd(TestNVMeIO):
- test_log_dir : directory for logs, temp files.
"""

def compare_cmd_supported(self):
""" Wrapper for extracting optional NVM 'compare' command support
- Args:
- None
- Returns:
- True if 'compare' is supported, otherwise False
"""
return int(self.get_id_ctrl_field_value("oncs"), 16) & (1 << 0)

def setUp(self):
""" Pre Section for TestNVMeCompareCmd """
super().setUp()
if not self.compare_cmd_supported():
self.skipTest("because: Optional NVM Command 'Compare' (NVMCMPS) not supported")
self.data_size = 1024
self.start_block = 1023
self.setup_log_dir(self.__class__.__name__)
Expand Down
1 change: 1 addition & 0 deletions tests/nvme_copy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def setUp(self):
super().setUp()
print("\nSetting up test...")
self.ocfs = self.get_ocfs()
self.host_behavior_data = None
cross_namespace_copy = self.ocfs & 0xc
if cross_namespace_copy:
# get host behavior support data
Expand Down
13 changes: 9 additions & 4 deletions tests/nvme_create_max_ns_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def setUp(self):
self.flbas = 0
self.nsze = int(self.get_ncap() /
self.get_format() / self.get_max_ns())
# Make sure that we have enough capacity for each ns.
# Creating a ns might allocate more bits (NVMCAP) than specified by
# nsze and ncap.
self.nsze = int(self.nsze / 2)
self.ncap = self.nsze
self.setup_log_dir(self.__class__.__name__)
self.max_ns = self.get_max_ns()
Expand All @@ -75,11 +79,12 @@ def tearDown(self):
self.flbas,
self.dps), 0)
self.attach_ns(self.ctrl_id, self.default_nsid)
super.tearDown()
super().tearDown()

def test_attach_detach_ns(self):
""" Testcase main """
for nsid in range(1, self.max_ns):
print(f"##### Testing max_ns: {self.max_ns}")
for nsid in range(1, self.max_ns + 1):
print("##### Creating " + str(nsid))
err = self.create_and_validate_ns(nsid,
self.nsze,
Expand All @@ -90,9 +95,9 @@ def test_attach_detach_ns(self):
print("##### Attaching " + str(nsid))
self.assertEqual(self.attach_ns(self.ctrl_id, nsid), 0)
print("##### Running IOs in " + str(nsid))
self.run_ns_io(nsid, 0)
self.run_ns_io(nsid, 9, 1)

for nsid in range(1, self.max_ns):
for nsid in range(1, self.max_ns + 1):
print("##### Detaching " + str(nsid))
self.assertEqual(self.detach_ns(self.ctrl_id, nsid), 0)
print("#### Deleting " + str(nsid))
Expand Down
2 changes: 2 additions & 0 deletions tests/nvme_ctrl_reset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ def ctrl_reset(self):
def test_ctrl_reset(self):
""" Testcase main """
self.assertEqual(self.ctrl_reset(), 0)
# Check if sqs and cqs are setup again and I/O operations are possible
self.run_ns_io(self.default_nsid, 0, 10)
13 changes: 9 additions & 4 deletions tests/nvme_format_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- Delete Namespace.
"""

import math
import subprocess
import time

Expand All @@ -63,10 +64,14 @@ class TestNVMeFormatCmd(TestNVMe):
def setUp(self):
""" Pre Section for TestNVMeFormatCmd """
super().setUp()
self.dps = 0 # ns data protection settings
self.flbas = 0 # ns formattes logical block settings
self.nsze = 0x1400000 # ns size
self.ncap = 0x1400000 # ns capacity
self.dps = 0
self.flbas = 0
# Assuming run_ns_io with 4KiB * 10 writes.
# Calculating minimum required ncap for this workload
(ds, _) = self.get_lba_format_size()
ncap = int(math.ceil((4096*10)/ds))
self.ncap = ncap
self.nsze = ncap
igaw marked this conversation as resolved.
Show resolved Hide resolved
self.ctrl_id = self.get_ctrl_id()
self.lba_format_list = []
self.ms_list = []
Expand Down
2 changes: 2 additions & 0 deletions tests/nvme_get_features_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def get_mandatory_features(self, feature_id):
else:
get_feat_cmd = "nvme get-feature " + self.ctrl + \
" --feature-id=" + str(feature_id) + " -H"
if str(feature_id) == "0x05":
get_feat_cmd += f" --namespace-id={self.default_nsid}"
proc = subprocess.Popen(get_feat_cmd,
shell=True,
stdout=subprocess.PIPE,
Expand Down
7 changes: 4 additions & 3 deletions tests/nvme_get_lba_status_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ class TestNVMeGetLbaStatusCmd(TestNVMe):
def setUp(self):
""" Pre Section for TestNVMeGetLbaStatusCmd. """
super().setUp()
if not self.get_lba_status_supported():
self.skipTest("because: Optional Admin Command 'Get LBA Status' (OACS->GLSS) not supported")
self.start_lba = 0
self.block_count = 0
self.namespace = 1
self.max_dw = 1
self.action = 11
self.action = 0x11
self.range_len = 1
self.setup_log_dir(self.__class__.__name__)

Expand All @@ -51,7 +52,7 @@ def get_lba_status(self):
"""
err = 0
get_lba_status_cmd = "nvme get-lba-status " + self.ctrl + \
" --namespace-id=" + str(self.namespace) + \
" --namespace-id=" + str(self.ns1) + \
" --start-lba=" + str(self.start_lba) + \
" --max-dw=" + str(self.max_dw) + \
" --action=" + str(self.action) + \
Expand Down
2 changes: 2 additions & 0 deletions tests/nvme_lba_status_log_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class TestNVMeLbaStatLogCmd(TestNVMe):
def setUp(self):
""" Pre Section for TestNVMeLbaStatLogCmd. """
super().setUp()
if not self.get_lba_status_supported():
self.skipTest("because: Optional Admin Command 'Get LBA Status' (OACS->GLSS) not supported")
self.setup_log_dir(self.__class__.__name__)

def tearDown(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/nvme_smart_log_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ def test_smart_log(self):
""" Testcase main """
self.assertEqual(self.get_smart_log_ctrl(), 0)
smlp = self.supp_check_id_ctrl("lpa")
if smlp & 0x1 == True:
if smlp & 0x1:
self.assertEqual(self.get_smart_log_all_ns(), 0)
Loading
Loading