Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #297 from tmenjo/fix-sheep-p-z-V-options
sheep: Validate -p/--port, -z/--zone and -V/--vnodes values strictly
- Loading branch information
Showing
11 changed files
with
431 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
# Test sheep -p/--port | ||
|
||
. ./common | ||
|
||
err=0 | ||
|
||
function testStartPortSucceeded | ||
{ | ||
port="$1" | ||
mkdir -p "$STORE/0" | ||
if $SHEEP "$STORE/0" -p "$port" ; then | ||
sleep 1 # DO NOT use _wait_for_sheep | ||
if grep daemon "$STORE/0/sheep.log" >/dev/null 2>&1 ; then | ||
$DOG node list -p "$port" | ||
else | ||
err=1 | ||
fi | ||
else | ||
err=1 | ||
fi | ||
_cleanup | ||
} | ||
|
||
function testStartPortFailed | ||
{ | ||
port="$1" | ||
mkdir -p "$STORE/0" | ||
$SHEEP "$STORE/0" -p "$port" && err=1 | ||
_cleanup | ||
} | ||
|
||
testStartPortSucceeded 7000 | ||
testStartPortSucceeded 65535 # UINT16_MAX | ||
testStartPortFailed 0 | ||
testStartPortFailed 65536 # UINT16_MAX + 1 | ||
testStartPortFailed 65537 # UINT16_MAx + 2 | ||
testStartPortFailed 4294967297 # UINT32_MAX + 2 | ||
testStartPortFailed -1 | ||
testStartPortFailed a | ||
testStartPortFailed 42a | ||
testStartPortFailed + | ||
testStartPortFailed - | ||
|
||
exit $err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
QA output created by 108 | ||
Id Host:Port V-Nodes Zone | ||
0 127.0.0.1:7000 128 16777343 | ||
Id Host:Port V-Nodes Zone | ||
0 127.0.0.1:65535 128 16777343 | ||
Invalid port number '0' | ||
Invalid port number '65536' | ||
Invalid port number '65537' | ||
Invalid port number '4294967297' | ||
Invalid port number '-1' | ||
Invalid port number 'a' | ||
Invalid port number '42a' | ||
Invalid port number '+' | ||
Invalid port number '-' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
# Test sheep -z/--zone | ||
|
||
. ./common | ||
|
||
err=0 | ||
|
||
function testStartZoneSucceeded | ||
{ | ||
zone="$1" | ||
mkdir -p "$STORE/0" | ||
if $SHEEP "$STORE/0" -z "$zone" ; then | ||
_wait_for_sheep 1 | ||
if grep daemon "$STORE/0/sheep.log" >/dev/null 2>&1 ; then | ||
$DOG node list | ||
else | ||
err=1 | ||
fi | ||
else | ||
err=1 | ||
fi | ||
_cleanup | ||
} | ||
|
||
function testStartZoneFailed | ||
{ | ||
zone="$1" | ||
mkdir -p "$STORE/0" | ||
$SHEEP "$STORE/0" -z "$zone" && err=1 | ||
_cleanup | ||
} | ||
|
||
testStartZoneSucceeded 0 | ||
testStartZoneSucceeded 1 | ||
testStartZoneSucceeded 4294967295 # UINT32_MAX | ||
testStartZoneFailed 4294967296 # UINT32_MAX + 1 | ||
testStartZoneFailed 9223372036854775808 # INT64_MAX + 1 | ||
testStartZoneFailed -1 | ||
testStartZoneFailed a | ||
testStartZoneFailed 42a | ||
testStartZoneFailed + | ||
testStartZoneFailed - | ||
|
||
exit $err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
QA output created by 109 | ||
Id Host:Port V-Nodes Zone | ||
0 127.0.0.1:7000 128 0 | ||
Id Host:Port V-Nodes Zone | ||
0 127.0.0.1:7000 128 1 | ||
Id Host:Port V-Nodes Zone | ||
0 127.0.0.1:7000 128 4294967295 | ||
Invalid zone id '4294967296': must be an integer between 0 and 4294967295 | ||
Invalid zone id '9223372036854775808': must be an integer between 0 and 4294967295 | ||
Invalid zone id '-1': must be an integer between 0 and 4294967295 | ||
Invalid zone id 'a': must be an integer between 0 and 4294967295 | ||
Invalid zone id '42a': must be an integer between 0 and 4294967295 | ||
Invalid zone id '+': must be an integer between 0 and 4294967295 | ||
Invalid zone id '-': must be an integer between 0 and 4294967295 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Test sheep -V/--vnodes | ||
|
||
. ./common | ||
|
||
function testStartVnodesFailed | ||
{ | ||
( SHEEP_OPTIONS="-V $1" _start_sheep 0 ) && : | ||
_wait_for_sheep_stop 0 | ||
_cleanup | ||
} | ||
|
||
function testStartVnodesSucceeded | ||
{ | ||
SHEEP_OPTIONS="-V $1" _start_sheep 0 | ||
_wait_for_sheep 1 | ||
$DOG node list | ||
_cleanup | ||
} | ||
|
||
function testStartVnodesGatewayFailed | ||
{ | ||
( SHEEP_OPTIONS='-g -V 42' _start_sheep 0 ) && : | ||
_wait_for_sheep_stop 0 | ||
_cleanup | ||
} | ||
|
||
testStartVnodesSucceeded 1 | ||
testStartVnodesSucceeded 65535 # UINT16_MAX | ||
testStartVnodesFailed 0 | ||
testStartVnodesFailed 65536 # UINT16_MAX + 1 | ||
testStartVnodesFailed 65537 # UINT16_MAX + 2 | ||
testStartVnodesFailed 4294967297 # UINT32_MAX + 2 | ||
testStartVnodesFailed -1 | ||
testStartVnodesFailed a | ||
testStartVnodesFailed 42a | ||
testStartVnodesFailed + | ||
testStartVnodesFailed - | ||
testStartVnodesGatewayFailed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
QA output created by 110 | ||
Id Host:Port V-Nodes Zone | ||
0 127.0.0.1:7000 1 0 | ||
Id Host:Port V-Nodes Zone | ||
0 127.0.0.1:7000 65535 0 | ||
Invalid number of vnodes '0': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Invalid number of vnodes '65536': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Invalid number of vnodes '65537': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Invalid number of vnodes '4294967297': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Invalid number of vnodes '-1': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Invalid number of vnodes 'a': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Invalid number of vnodes '42a': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Invalid number of vnodes '+': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Invalid number of vnodes '-': must be an integer between 1 and 65535 | ||
cannot start sheep 0 | ||
Options '-g' and '-V' can not be both specified | ||
cannot start sheep 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,3 +115,6 @@ | |
105 auto quick vdi | ||
106 auto quick vdi | ||
107 auto quick dog | ||
108 auto quick | ||
109 auto quick | ||
110 auto quick |
Oops, something went wrong.