100% found this document useful (1 vote)
276 views16 pages

Pynvme Introduction

Pynvme is a python extension module. Users can operate NVMe SSD intuitively by Python scripts. It is designed for NVMe SSD testing with performance considered. With third-party tools, e.g. emacs, pycharm and/or pytest, Pynvme is a convenient and professional NVMe device test solution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
100% found this document useful (1 vote)
276 views16 pages

Pynvme Introduction

Pynvme is a python extension module. Users can operate NVMe SSD intuitively by Python scripts. It is designed for NVMe SSD testing with performance considered. With third-party tools, e.g. emacs, pycharm and/or pytest, Pynvme is a convenient and professional NVMe device test solution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
You are on page 1/ 16

Pynvme:

test NVMe devices in Python


https://github.com/cranechu/pynvme
Pynvme
Pynvme is a python extension module. Users can operate NVMe
SSD intuitively by Python scripts. It is designed for NVMe SSD
testing with performance considered. With third-party tools, e.g.
emacs, pycharm and pytest, pynvme is a convenient and
professional NVMe device test solution.

<date/time> <footer> 2
Pynvme in Python IDLE

pynvme

SPDK

<date/time> <footer> 3
Pynvme is based on SPDK

<date/time> <footer> 4
Pynvme Architecture
Build python library with
Cython:
• setup.py
• driver.c
• driver.h
• cdriver.pxd
• driver_wrap.pyx
• Makefile
Python interface
(driver_wrap.pyx)

Test driver Python library


(driver.c) (nvme.so)

<date/time> <footer> 5
Pynvme Architecture
Organize test cases in
pytest:
• mvme.so
• pytest.ini
• conftest.py
• driver_test.py

Python interface Python test scripts


(driver_wrap.pyx) (driver_test.py)

Test driver Python library


(driver.c) (nvme.so)

Pytest fixtures
(conftest.py)

<date/time> <footer> 6
Why Python?
√ Many beautiful mature libraries
• pytest
• logging
• multiprocessing
• numpy
• matplotlib
• pydoc
• os, io, time, pytemperature, statistics, yaml, json, struct, ...

√ Friendly IDEs for developing, debugging, and testing


• Pycharm, emacs, vscode

√ CI: develop firmware softly

<date/time> <footer> 7
Pynvme CI Status

<date/time> <footer> 8
Config and Compile
− git clone https://github.com/cranechu/pynvme; cd pynvme
− git submodule update --init –recursive
− sudo ./spdk/scripts/pkgdep.sh
− sudo dnf install python3-pip -y
− sudo python3 -m pip install -r requirements.txt
− cd spdk; ./configure --without-isal; cd ..
− make spdk; make

− Fedora29 is recommended.
− find script examples in driver_test.py.
− find more => https://github.com/cranechu/pynvme

<date/time> <footer> 9
Test Scripts
pytest cases pytest fixtures
are started
with test_
fill buffer with
create qpair and
identify data
buffer for write
commands
callback functions
write data,
called when cmds
and then read
are completed
in the callback

<date/time> <footer> 10
IOWorker
define IO patterns
in ioworker's
parameter list

send IO in a
separated process

wait ioworkers till


finish, and collect
result data

<date/time> <footer> 11
Fixtures of Pynvme
• create/delete test objects. in conftest.py:
• nvme0
• nvme0n1
• pcie
• ...
• parametrize of tests
• @pytest.mark.parametrize("qcount", [1, 2, 4, 8, 15])
• @pytest.mark.parametrize("repeat", range(10))
• test control
• @pytest.mark.skip("nvme over tcp")

• doc: https://docs.pytest.org/en/latest/fixture.html

<date/time> <footer> 12
Test Files
import pytest

pytest collects test


import nvme files and cases
before execution

test functions

test file name

<date/time> <footer> 13
Pytest Execution
• '''The pytest framework makes it easy to write small tests, yet
scales to support complex functional testing for applications
and libraries.'''

• '''pytest fixtures offer dramatic improvements over the classic


xUnit style of setup/teardown functions'''

• pytest test_mod.py # run tests in a module


• pytest testing/ # run tests in a directory
• pytest test_mod.py::test_func # run a specific test case
• pytest test_mod.py -s # run tests without log capturing
• https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf
<date/time> <footer> 14
Pycharm: show case
Test
status

Test scripts

Test log

<date/time> <footer> 15
Welcome to use and contribute

<date/time> <footer> 16

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy