Skip to content

Commit

Permalink
Try #1771:
Browse files Browse the repository at this point in the history
  • Loading branch information
mayastor-bors committed Nov 26, 2024
2 parents 2825e5e + 5b1f0d9 commit 987098b
Show file tree
Hide file tree
Showing 10 changed files with 534 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion doc/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ cargo build --release
```
**Want to run or hack on Mayastor?** _You need more configuration!_ See
[running][doc-running], then [testing][doc-testing].
[running][doc-run], then [testing][doc-test].
Whilst the nix develop will allow you to build mayastor exactly as the image build, it might not have all the necessary
components required for testing.
Expand Down
29 changes: 28 additions & 1 deletion doc/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ Mayastor's unit tests, integration tests, and documentation tests via the conven
Mayastor uses [spdk][spdk] which is quite senistive to threading. This means tests need to run one at a time:

```bash
cargo test -- --test-threads 1
cd io-engine
RUST_LOG=TRACE cargo test -- --test-threads 1 --nocapture
```

## Testing your own SPDK version
To test your custom SPDK version please refere to the [spdk-rs documentation](https://github.com/openebs/spdk-rs/blob/develop/README.md#custom-spdk)

## Running the end-to-end test suite

Mayastor does more complete, end-to-end testing testing with [`mocha`][mocha]. It requires some extra setup.
Expand All @@ -55,6 +59,29 @@ Then, to run the tests:
./node_modules/mocha/bin/mocha test_csi.js
```

## Using PCIe NVMe devices in cargo tests while developing

When developing new features, testing those with real PCIe devices in the process might come in handy.
In order to do so, the PCIe device first needs to be bound to the vfio driver:

```bash
sudo PCI_ALLOWED="<PCI-ADDRESS>" ./spdk-rs/spdk/scripts/setup.sh
```

The bdev name in the cargo test case can then follow the PCIe URI pattern:

```rust
static BDEVNAME1: &str = "pcie:///<PCI-ADDRESS>";
```

After testing the device may be rebound to the NVMe driver:

```bash
sudo PCI_ALLOWED="<PCI-ADDRESS>" ./spdk-rs/spdk/scripts/setup.sh reset
```

Please do not submit pull requests with active cargo test cases that require PCIe devices to be present.

[spdk]: https://spdk.io/
[doc-run]: ./run.md
[mocha]: https://mochajs.org/
Expand Down
2 changes: 2 additions & 0 deletions io-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ extended-tests = [] # Extended I/O engine tests: not intended for daily runs.
fault-injection = [] # Enables fault injection code.
nexus-io-tracing = [] # Enables nexus I/O tracing code.
spdk-async-qpair-connect = [] # Enables async qpair connection.
nvme-pci-tests = []

[[bin]]
name = "io-engine"
Expand Down Expand Up @@ -77,6 +78,7 @@ merge = "0.1.0"
nix = { version = "0.29.0", default-features = false, features = ["hostname", "net", "socket", "ioctl"] }
once_cell = "1.20.2"
parking_lot = "0.12.3"
percent-encoding = "2.3.1"
pin-utils = "0.1.0"
prost = "0.13.3"
prost-derive = "0.13.3"
Expand Down
2 changes: 2 additions & 0 deletions io-engine/src/bdev/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub(crate) mod uri {
use crate::{
bdev::{
aio,
ftl,
loopback,
lvs,
malloc,
Expand All @@ -64,6 +65,7 @@ pub(crate) mod uri {
"bdev" | "loopback" => {
Ok(Box::new(loopback::Loopback::try_from(&url)?))
}
"ftl" => Ok(Box::new(ftl::Ftl::try_from(&url)?)),
"malloc" => Ok(Box::new(malloc::Malloc::try_from(&url)?)),
"null" => Ok(Box::new(null_bdev::Null::try_from(&url)?)),
// keeping nvmf scheme so existing tests(if any, setting this
Expand Down
Loading

0 comments on commit 987098b

Please sign in to comment.