SOLR-11749: Fix logic errors in some assert funcs

This commit is contained in:
Jason Gerlowski 2018-04-27 09:46:11 -04:00
parent e263ae30ed
commit 43c086a002
1 changed files with 16 additions and 12 deletions

View File

@ -14,13 +14,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
ASSERT_SUCCEEDED=1 ASSERT_SUCCESS=0
ASSERT_FAILURE=0 ASSERT_FAILURE=1
TEST_SUCCESS=0
TEST_FAILURE=1
function assert_cmd_succeeded() { function assert_cmd_succeeded() {
retval=$? retval=$?
if [[ $? -ne 0 ]]; then if [[ $retval -ne 0 ]]; then
echo "Expected command $1 to succeed, but exited with $retval" echo "Expected command $1 to succeed, but exited with $retval"
return $ASSERT_FAILURE return $ASSERT_FAILURE
fi fi
@ -31,7 +34,7 @@ function assert_cmd_succeeded() {
function assert_cmd_failed() { function assert_cmd_failed() {
retval=$? retval=$?
if [[ $? -eq 0 ]]; then if [[ $retval -eq 0 ]]; then
echo "Expected command $1 to fail, but exited with $retval" echo "Expected command $1 to fail, but exited with $retval"
return $ASSERT_FAILURE return $ASSERT_FAILURE
fi fi
@ -67,9 +70,9 @@ function assert_collection_exists() {
local coll_name=$1 local coll_name=$1
local coll_list=$(bin/solr zk ls /collections -z localhost:9983) local coll_list=$(bin/solr zk ls /collections -z localhost:9983)
for coll in "$coll_list"; for coll in $coll_list;
do do
if [[ $(echo $coll | tr -d " ") -eq $coll_name ]]; then if [[ $(echo $coll | tr -d " ") == $coll_name ]]; then
return $ASSERT_SUCCESS return $ASSERT_SUCCESS
fi fi
done done
@ -81,9 +84,10 @@ function assert_collection_exists() {
function assert_collection_doesnt_exist() { function assert_collection_doesnt_exist() {
local coll_name=$1 local coll_name=$1
local coll_list=$(bin/solr zk ls /collections -z localhost:9983) local coll_list=$(bin/solr zk ls /collections -z localhost:9983)
for coll in "$coll_list"; for coll in $coll_list;
do do
if [[ $(echo $coll | tr -d " ") -eq $coll_name ]]; then echo "Comparing $coll to $coll_name"
if [[ $(echo $coll | tr -d " ") == "$coll_name" ]]; then
echo "Expected not to find collection [$coll_name], but it exists" echo "Expected not to find collection [$coll_name], but it exists"
return $ASSERT_FAILURE return $ASSERT_FAILURE
fi fi
@ -96,9 +100,9 @@ function assert_config_exists() {
local config_name=$1 local config_name=$1
local config_list=$(bin/solr zk ls /configs -z localhost:9983) local config_list=$(bin/solr zk ls /configs -z localhost:9983)
for config in "$config_list"; for config in $config_list;
do do
if [[ $(echo $config | tr -d " ") -eq $config_name ]]; then if [[ $(echo $config | tr -d " ") == $config_name ]]; then
return $ASSERT_SUCCESS return $ASSERT_SUCCESS
fi fi
done done
@ -111,9 +115,9 @@ function assert_config_doesnt_exist() {
local config_name=$1 local config_name=$1
local config_list=$(bin/solr zk ls /configs -z localhost:9983) local config_list=$(bin/solr zk ls /configs -z localhost:9983)
for config in "$config_list"; for config in $config_list;
do do
if [[ $(echo $config | tr -d " ") -eq $config_name ]]; then if [[ $(echo $config | tr -d " ") == $config_name ]]; then
echo "Expected not to find config [$config_name], but it exists" echo "Expected not to find config [$config_name], but it exists"
return $ASSERT_FAILURE return $ASSERT_FAILURE
fi fi