#!/bin/bash

group=$1
testName="CBS"
testSummary="two node mode configured correctly"

source ../get_test_values --group=$group


function test()
{
    local system=$1
    timeout 10 ssh -T root@$system <<EOF
           grep -q "two_node:.*1" /etc/corosync/corosync.conf 2>/dev/null;
EOF
    return $?
}

#
# TODO: correct filter for all cluster nodes in the use case.
#       currently we just take the first two as cluster nodes - that's a hack
#
read sys1 sys2 X <<< $allSystems
for system in $sys1 $sys2; do
    test $system; rc=$?
    logger -t $LandscapeUseCase -s "Test $testName for $group on node $system rc:  $rc"
    case $rc in 
        124 | 255 ) # test timeout - set N/A
             rm -f $STATUS_BASE_DIR/.status/${group}_${testName}_OK
             rm -f $STATUS_BASE_DIR/.status/${group}_${testName}_FAIL
             res="NA";
             ;;
        0  )
             touch $STATUS_BASE_DIR/.status/${group}_${testName}_OK
             rm -f $STATUS_BASE_DIR/.status/${group}_${testName}_FAIL
             # do not break, we need all clusternodes to be 'correct'
             ;;
        * )  rm -f $STATUS_BASE_DIR/.status/${group}_${testName}_OK
             touch $STATUS_BASE_DIR/.status/${group}_${testName}_FAIL
             ;;
    esac
done
