Skip to content

Commit 1a65137

Browse files
feat(tests): add python tests for lvm volume
- add python tests for replica operations backed by lvm Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com> Co-authored-by: Akhil Mohan <akhil.mohan@mayadata.io> Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
1 parent 7ed2df1 commit 1a65137

File tree

10 files changed

+272
-15
lines changed

10 files changed

+272
-15
lines changed

io-engine/src/bin/io-engine-client/main.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use byte_unit::Byte;
22
use snafu::{Backtrace, Snafu};
3+
use strum::ParseError;
34
use tonic::transport::Channel;
45

56
use io_engine_api::v0::{
@@ -23,6 +24,11 @@ pub enum ClientError {
2324
source: tonic::Status,
2425
backtrace: Backtrace,
2526
},
27+
#[snafu(display("gRPC status: {}", source))]
28+
GrpcParseStatus {
29+
source: ParseError,
30+
backtrace: Backtrace,
31+
},
2632
#[snafu(display("Context building error: {}", source))]
2733
ContextCreate {
2834
source: context::Error,

io-engine/src/bin/io-engine-client/v1/replica_cli.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
context::{Context, OutputFormat},
44
parse_size,
55
ClientError,
6+
GrpcParseStatus,
67
GrpcStatus,
78
};
89
use byte_unit::Byte;
@@ -345,11 +346,11 @@ async fn replica_list(
345346
matches: &ArgMatches,
346347
) -> crate::Result<()> {
347348
let pooltype = matches
348-
.get_one::<String>("type")
349+
.get_many::<String>("type")
350+
.unwrap_or_default()
349351
.map(|s| pool_cli::PoolType::from_str(s.as_str()))
350-
.transpose()
351-
.map_err(|e| Status::invalid_argument(e.to_string()))
352-
.context(GrpcStatus)?;
352+
.collect::<Result<Vec<_>, _>>()
353+
.context(GrpcParseStatus)?;
353354
let pooltypes = pooltype
354355
.into_iter()
355356
.map(|t| v1_rpc::pool::PoolType::from(t) as i32)

io-engine/src/grpc/v1/replica.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ impl ReplicaRpc for ReplicaService {
254254

255255
let mut replicas = vec![];
256256

257-
if args.pooltypes.iter().any(|t| *t == PoolType::Lvs as i32) {
257+
if args.pooltypes.is_empty()
258+
|| args.pooltypes.iter().any(|t| *t == PoolType::Lvs as i32)
259+
{
258260
replicas.extend(Self::list_lvs_replicas().await?);
259261
}
260262
if args.pooltypes.iter().any(|t| *t == PoolType::Lvm as i32) {

scripts/pytest-tests.sh

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function run_tests()
4747
(
4848
set -x
4949
report=$(echo "${name}-xunit-report.xml" | tr '/' '-')
50-
python -m pytest --tc-file='test_config.ini' --docker-compose="$name" "$name" --junit-xml="$ROOTDIR/$report"
50+
python -m pytest --tc-file='test_config.ini' --docker-compose="$name" "$name" --junit-xml="$ROOTDIR/$report" $TEST_ARGS
5151
)
5252
elif [ -f "$name" ] || [ -f "${name%::*}" ]
5353
then
@@ -56,7 +56,7 @@ function run_tests()
5656
base=$(dirname "$name")
5757
( cd "$base"; docker-compose down 2>/dev/null || true )
5858
report=$(echo "$base/${name%.py}-xunit-report.xml" | tr '/' '-')
59-
python -m pytest --tc-file='test_config.ini' --docker-compose="$base" "$name" --junit-xml="$ROOTDIR/$report"
59+
python -m pytest --tc-file='test_config.ini' --docker-compose="$base" "$name" --junit-xml="$ROOTDIR/$report" $TEST_ARGS
6060
)
6161
fi
6262
done
@@ -71,6 +71,7 @@ fi
7171
pushd "$SRCDIR/test/python" >/dev/null && source ./venv/bin/activate && popd >/dev/null
7272

7373
TEST_LIST=
74+
TEST_ARGS=
7475
while [ "$#" -gt 0 ]; do
7576
case "$1" in
7677
--clean-all)
@@ -87,6 +88,8 @@ while [ "$#" -gt 0 ]; do
8788
param="$1"
8889
if [ -d "$real_1" ] || [ -f "$real_1" ] || [ -f "${real_1%::*}" ]; then
8990
param="$real_1"
91+
else
92+
TEST_ARGS="${TEST_ARGS:-}$1"
9093
fi
9194
TEST_LIST="$TEST_LIST \n$param"
9295
;;

test/python/v1/pool/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
- NEXUS_NVMF_RESV_ENABLE=1
1414
- PATH=${LLVM_SYMBOLIZER_DIR:-}:${LVM_BINS:-}
1515
- ASAN_OPTIONS=detect_leaks=0
16-
- LVM_ENABLE=1
16+
- LVM=true
1717
command: ${SRCDIR}/${IO_ENGINE_DIR}/io-engine -g 0.0.0.0 -l 1,2 -r /tmp/ms0.sock
1818
networks:
1919
mayastor_net:

test/python/v1/pool/test_bdd_lvm.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def create(name, disks, pooltype):
105105
def find_pool(get_mayastor_instance):
106106
def find(name):
107107
for pool in get_mayastor_instance.pool_rpc.ListPools(
108-
pb.ListPoolOptions()
108+
pb.ListPoolOptions()
109109
).pools:
110110
if pool.name == name:
111111
return pool
@@ -121,14 +121,14 @@ def get_lvm_feature(get_mayastor_instance, get_mayastor_info):
121121

122122
@then("the instance shall report if it supports the LVM feature")
123123
def the_instance_shall_report_if_it_supports_the_lvm_feature(
124-
get_mayastor_instance, get_mayastor_info, get_lvm_feature
124+
get_mayastor_instance, get_mayastor_info, get_lvm_feature
125125
):
126126
assert get_lvm_feature
127127

128128

129129
@when("the user creates a pool specifying a URI representing an loop disk")
130130
def the_user_creates_a_pool_specifying_a_uri_representing_an_loop_disk(
131-
get_mayastor_instance, volgrp_with_losetup_disk, create_pool
131+
get_mayastor_instance, volgrp_with_losetup_disk, create_pool
132132
):
133133
create_pool(f"{volgrp_with_losetup_disk}", [pytest.disk], pb.Lvm)
134134

@@ -140,7 +140,9 @@ def the_lvm_pool_should_be_created(find_pool):
140140

141141
@when("the user destroys a pool specifying type as lvm")
142142
def the_user_destroys_a_pool_specifying_type_as_lvm(get_mayastor_instance):
143-
get_mayastor_instance.pool_rpc.DestroyPool(pb.DestroyPoolRequest(name="lvmpool", pooltype=pb.Lvm))
143+
get_mayastor_instance.pool_rpc.DestroyPool(
144+
pb.DestroyPoolRequest(name="lvmpool", pooltype=pb.Lvm)
145+
)
144146

145147

146148
@then("the lvm pool should be removed")

test/python/v1/pool/test_bdd_pool.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ def pool_creation_should_fail(find_pool):
298298

299299
@then("the pool create command should fail")
300300
def the_pool_create_command_should_fail(create_pool_that_already_exists):
301-
assert create_pool_that_already_exists.value.code() == grpc.StatusCode.ALREADY_EXISTS
301+
assert (
302+
create_pool_that_already_exists.value.code() == grpc.StatusCode.ALREADY_EXISTS
303+
)
302304

303305

304306
@then("the pool destroy command should fail")

test/python/v1/replica/docker-compose.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ services:
1111
- MY_POD_IP=10.0.0.2
1212
- NEXUS_NVMF_ANA_ENABLE=1
1313
- NEXUS_NVMF_RESV_ENABLE=1
14-
- PATH=${LLVM_SYMBOLIZER_DIR:-}
14+
- PATH=${LLVM_SYMBOLIZER_DIR:-}:${LVM_BINS:-}
1515
- ASAN_OPTIONS=detect_leaks=0
16-
command: ${SRCDIR}/${IO_ENGINE_DIR}/io-engine -g 0.0.0.0 -l 1 -r /tmp/ms0.sock
16+
- LVM=true
17+
- RUST_LOG=debug
18+
command: ${SRCDIR}/${IO_ENGINE_DIR}/io-engine -g 0.0.0.0 -l 1 -r /tmp/ms0.sock --reactor-freeze-detection
1719
networks:
1820
mayastor_net:
1921
ipv4_address: 10.0.0.2
@@ -32,6 +34,14 @@ services:
3234
- /dev/hugepages:/dev/hugepages
3335
- /tmp:/tmp
3436
- /var/tmp:/var/tmp
37+
- /dev:/dev
38+
- /run/udev:/run/udev
39+
privileged: true
40+
devices:
41+
- /dev/loop0
42+
- /dev/loop1
43+
- /dev/loop2
44+
ipc: "host"
3545
networks:
3646
mayastor_net:
3747
name: mayastor_net
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Feature: LVM replica support
2+
3+
Background:
4+
Given a mayastor instance "ms0"
5+
And an LVM VG backed pool called "lvmpool"
6+
7+
Scenario: Creating an lvm volume on an imported lvm volume group
8+
When a user calls the createreplica on pool "lvmpool"
9+
Then an lv should be created on the lvmpool
10+
11+
Scenario: Destroying a replica backed by lvm pool
12+
Given an LVM backed replica
13+
When a user calls destroy replica
14+
Then the replica gets destroyed
15+
16+
Scenario: Listing replicas from either an LVS or LVM pool
17+
Given an LVS pool with a replica
18+
And an LVM backed replica
19+
When a user calls list replicas
20+
Then all replicas should be listed

0 commit comments

Comments
 (0)