Skip to content
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
4 changes: 2 additions & 2 deletions tools/nmdctl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if ((BASH_VERSINFO[0] < 4)); then
fi

# Our version
VERSION=1.22.0
VERSION=1.22.1

# Colors for pretty output
RED='\033[0;31m'
Expand Down Expand Up @@ -2636,7 +2636,7 @@ handle_check() {
fi
fi
# Check if some other sync operation is pending, and confirm with the user
if [[ "$mdresyncaction" != check* ]]; then
if [[ "${option^^}" != "RESUME" ]] && [[ "$mdresyncaction" != check* ]]; then
# If we're explicitly given an option for the pending sync operation, allow that operation to proceed
if [ -n "$1" ] && [[ "$mdresyncaction" == "${option,,}"* ]]; then
echo -e "${GREEN}Proceeding with explicitly requested operation: $friendly_action${NC}"
Expand Down
67 changes: 67 additions & 0 deletions tools/tests/test_nmdctl_basic.bats
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,73 @@ EOF
[[ "$output" =~ WARNING:\ Driver\ internal\ state ]]
}

@test "handle_check - RESUME resumes paused parity check" {
create_mock_nmdstat "STARTED" 0 0 0 "check P" 500000 1000000 0 0 > "$BATS_TMPDIR/mock_nmdstat_paused_check"

export PROC_NMDSTAT="$BATS_TMPDIR/mock_nmdstat_paused_check"
eval 'run_nmd_command() { echo "cmd: $*"; return 0; }'
run handle_check "RESUME"

echo "$status"
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" =~ "cmd: check RESUME" ]]
}

@test "handle_check - RESUME in unattended mode resumes paused parity check" {
create_mock_nmdstat "STARTED" 0 0 0 "check P" 500000 1000000 0 0 > "$BATS_TMPDIR/mock_nmdstat_paused_check_unattended"

export PROC_NMDSTAT="$BATS_TMPDIR/mock_nmdstat_paused_check_unattended"
export UNATTENDED=1
eval 'run_nmd_command() { echo "cmd: $*"; return 0; }'
run handle_check "RESUME"

echo "$status"
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" =~ "cmd: check RESUME" ]]
}

@test "handle_check - new check blocked in unattended mode with paused operation" {
create_mock_nmdstat "STARTED" 0 0 0 "check P" 500000 1000000 0 0 > "$BATS_TMPDIR/mock_nmdstat_paused_check_block"

export PROC_NMDSTAT="$BATS_TMPDIR/mock_nmdstat_paused_check_block"
export UNATTENDED=1
run handle_check

echo "$status"
echo "$output"
[ "$status" -eq 1 ]
[[ "$output" =~ "Cannot start new operation with a paused operation pending" ]]
}

@test "handle_check - RESUME blocked when no paused operation" {
# mdResync=0, mdResyncPos=0 means nothing paused
create_mock_nmdstat "STARTED" 0 0 0 "check P" 0 0 0 0 > "$BATS_TMPDIR/mock_nmdstat_no_paused"

export PROC_NMDSTAT="$BATS_TMPDIR/mock_nmdstat_no_paused"
run handle_check "RESUME"

echo "$status"
echo "$output"
[ "$status" -eq 1 ]
[[ "$output" =~ "No paused resync operation to resume" ]]
}

@test "handle_check - check blocked in unattended mode when recon is pending" {
# mdResync=0, mdResyncPos=0, mdResyncAction=recon means a recon is pending (not started)
create_mock_nmdstat "STARTED" 0 1 0 "recon P" 0 1000000 0 0 > "$BATS_TMPDIR/mock_nmdstat_recon_pending"

export PROC_NMDSTAT="$BATS_TMPDIR/mock_nmdstat_recon_pending"
export UNATTENDED=1
run handle_check

echo "$status"
echo "$output"
[ "$status" -eq 1 ]
[[ "$output" =~ "Cannot start parity check with another sync operation pending" ]]
}

@test "status parsing - Parity check with errors found" {
# Create mock with parity check that found errors
create_mock_nmdstat "STARTED" 0 0 0 "check P" 0 0 1 15 > "$BATS_TMPDIR/mock_nmdstat_parity_errors"
Expand Down
Loading