Skip to content

Commit

Permalink
Merge #1447
Browse files Browse the repository at this point in the history
1447: ci: remove unnecessary cleanup on exit after error r=tiagolobocastro a=tiagolobocastro



Co-authored-by: Tiago Castro <[email protected]>
  • Loading branch information
mayastor-bors and tiagolobocastro committed Jul 19, 2023
2 parents df4a5fb + 9dbf289 commit ad04216
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 20 deletions.
9 changes: 5 additions & 4 deletions scripts/cargo-test.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/usr/bin/env bash

SCRIPTDIR=$(dirname "$0")
SCRIPTDIR="$(realpath "$(dirname "$0")")"

cleanup_handler() {
$SCRIPTDIR/clean-cargo-tests.sh || true
ERROR=$?
"$SCRIPTDIR"/clean-cargo-tests.sh || true
if [ $ERROR != 0 ]; then exit $ERROR; fi
}

trap cleanup_handler ERR INT QUIT TERM HUP EXIT

echo "running cargo-test..."
echo "rustc version:"
rustc --version

cleanup_handler
trap cleanup_handler INT QUIT TERM HUP EXIT

set -euxo pipefail
export PATH=$PATH:${HOME}/.cargo/bin
Expand Down
12 changes: 7 additions & 5 deletions scripts/grpc-test.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/usr/bin/env bash

SCRIPTDIR=$(dirname "$0")
trap cleanup_handler ERR INT QUIT TERM HUP EXIT
SCRIPTDIR="$(realpath "$(dirname "$0")")"

cleanup_handler() {
$SCRIPTDIR/clean-cargo-tests.sh || true
ERROR=$?
"$SCRIPTDIR"/clean-cargo-tests.sh || true
if [ $ERROR != 0 ]; then exit $ERROR; fi
}

cleanup_handler
trap cleanup_handler INT QUIT TERM HUP EXIT

set -euxo pipefail

export PATH="$PATH:${HOME}/.cargo/bin"
export npm_config_jobs=$(nproc)

cleanup_handler

cargo build --all
cd "$(dirname "$0")/../test/grpc"
npm install --legacy-peer-deps
Expand Down
6 changes: 4 additions & 2 deletions test/python/common/nvme.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ async def nvme_remote_discover(remote, uri):
raise ValueError("uri {} is not discovered".format(u.path[1:]))


def nvme_connect(uri):
def nvme_connect(uri, delay=10, tmo=600):
u = urlparse(uri)
port = u.port
host = u.hostname
nqn = u.path[1:]

command = "sudo nvme connect -t tcp -s {0} -a {1} -n {2}".format(port, host, nqn)
command = (
f"sudo nvme connect -t tcp -s {port} -a {host} -n {nqn} -c {delay} -l {tmo}"
)
subprocess.run(command, check=True, shell=True, capture_output=False)
time.sleep(1)
command = "sudo nvme list -v -o json"
Expand Down
6 changes: 4 additions & 2 deletions test/python/tests/nexus/test_multi_nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
import asyncio
import uuid as guid
import pytest_asyncio

NEXUS_COUNT = 15
DESTROY_COUNT = 7
Expand Down Expand Up @@ -114,18 +115,19 @@ def connect_devices(create_nexuses):
nvme_disconnect(nexus)


@pytest.fixture
@pytest_asyncio.fixture
async def mount_devices(connect_devices):
"Create and mount a filesystem on each nvmf connected device."
for dev in connect_devices:
await run_cmd_async(f"sudo mkfs.xfs {dev}")
await run_cmd_async(f"sudo mkfs.ext4 {dev}")
await run_cmd_async(f"sudo mkdir -p /mnt{dev}")
await run_cmd_async(f"sudo mount {dev} /mnt{dev}")

yield

for dev in connect_devices:
await run_cmd_async(f"sudo umount /mnt{dev}")
await run_cmd_async(f"sudo rm -rf /mnt/dev")


@pytest.mark.asyncio
Expand Down
2 changes: 1 addition & 1 deletion test/python/tests/nexus/test_nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def test_nexus_preempt_key(

# verify write error with nexus on ms3
uri = create_nexus_v2
dev = nvme_connect(uri)
dev = nvme_connect(uri, 1, 1)
job = "sudo dd if=/dev/urandom of={0} bs=512 count=1".format(dev)

try:
Expand Down
6 changes: 3 additions & 3 deletions test/python/tests/nexus_fault/test_nexus_fault.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ def _(mounted_nexus):
"""the initiator filesystem should not be shutdown."""
try:
# xfs_info should still be working as the fs is not shutdown
run_cmd(f"xfs_info {mounted_nexus}")
except:
pytest.fail(f"Filesystem on {mounted_nexus} should not be shutdown")
run_cmd(f"sudo xfs_info {mounted_nexus}")
except Exception as e:
pytest.fail(f"Filesystem on {mounted_nexus} should not be shutdown: {e}")


@pytest.fixture(scope="module")
Expand Down
6 changes: 4 additions & 2 deletions test/python/v1/nexus/test_multi_nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
import asyncio
import uuid as guid
import pytest_asyncio

NEXUS_COUNT = 15
DESTROY_COUNT = 7
Expand Down Expand Up @@ -139,18 +140,19 @@ def connect_devices(create_nexuses):
nvme_disconnect(nexus)


@pytest.fixture
@pytest_asyncio.fixture
async def mount_devices(connect_devices):
"Create and mount a filesystem on each nvmf connected device."
for dev in connect_devices:
await run_cmd_async(f"sudo mkfs.xfs {dev}")
await run_cmd_async(f"sudo mkfs.ext4 {dev}")
await run_cmd_async(f"sudo mkdir -p /mnt{dev}")
await run_cmd_async(f"sudo mount {dev} /mnt{dev}")

yield

for dev in connect_devices:
await run_cmd_async(f"sudo umount /mnt{dev}")
await run_cmd_async(f"sudo rm -rf /mnt/dev")


@pytest.mark.asyncio
Expand Down
2 changes: 1 addition & 1 deletion test/python/v1/nexus/test_nexus.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def test_nexus_preempt_key(

# verify write error with nexus on ms3
uri = create_nexus
dev = nvme_connect(uri)
dev = nvme_connect(uri, 1, 1)
job = "sudo dd if=/dev/urandom of={0} bs=512 count=1".format(dev)

try:
Expand Down

0 comments on commit ad04216

Please sign in to comment.