Skip to content

Commit

Permalink
Merge pull request #271 from gaonkar18y/for307-func-tests-stack_trace…
Browse files Browse the repository at this point in the history
…-config

Add functional test cases for stack_trace config
  • Loading branch information
indraneeldey authored Sep 13, 2019
2 parents 00445d2 + 75aeb42 commit 0727d9d
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test-functional/NightlyTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,32 @@ main() {
testFailCount=`expr $testFailCount + 1`
fi

echo
testCount=`expr $testCount + 1`
echo "$testCount) testStackTraceConfig"
testStackTraceConfig; ret=$?
if [ $ret -eq 0 ]; then
echo "$STATUS_PASS_STR"
testPassCount=`expr $testPassCount + 1`
else
echo "$STATUS_FAIL_STR"
result=1
testFailCount=`expr $testFailCount + 1`
fi

echo
testCount=`expr $testCount + 1`
echo "$testCount) testStackTraceFalseConfig"
testStackTraceFalseConfig; ret=$?
if [ $ret -eq 0 ]; then
echo "$STATUS_PASS_STR"
testPassCount=`expr $testPassCount + 1`
else
echo "$STATUS_FAIL_STR"
result=1
testFailCount=`expr $testFailCount + 1`
fi

echo
testCount=`expr $testCount + 1`
echo "$testCount) testRevokedAPIKey"
Expand Down
79 changes: 79 additions & 0 deletions test-functional/testEMG.sh
Original file line number Diff line number Diff line change
Expand Up @@ -797,5 +797,84 @@ testTraceEventLog() {
logError "Failed to find event trace log"
fi

return $result
}

testStackTraceConfig() {

local result=0
local logFilename=''

logInfo "Check if stack_trace config is working correctly"

# Clear the logs of previous tests
logFilename=$(cat edgemicro.logs | grep "logging to" | cut -d ' ' -f7)
cat /dev/null > $logFilename

if [ ! -f $EMG_CONFIG_FILE ];
then
result=1
logError "Failed to locate EMG configure file $EMG_CONFIG_FILE"
return $result
fi

#
node setYamlVars ${EMG_CONFIG_FILE} 'edgemicro.logging.level' 'error' 'edgemicro.logging.stack_trace' true > tmp_emg_file.yaml
cp tmp_emg_file.yaml ${EMG_CONFIG_FILE}

reloadMicrogatewayNow


apiKey=$(getDeveloperApiKey ${DEVELOPER_NAME} ${DEVELOPER_APP_NAME})

curl -q -s http://localhost:8000/v1/invalidproxyFortesting -H "x-api-key: $apiKey" -D headers.txt > /dev/null 2>&1 ; ret=$?

sleep 5

logfiledata=$(cat $logFilename | grep -a "Error:" | cut -d ' ' -f1)
if [[ $logfiledata != *"Error:"* ]]; then
result=1
logError "Failed to find trace log when stack_trace is true"
fi

return $result
}

testStackTraceFalseConfig() {

local result=0
local logFilename=''

logInfo "Check if stack_trace config is working correctly"

# Clear the logs of previous tests
logFilename=$(cat edgemicro.logs | grep "logging to" | cut -d ' ' -f7)
cat /dev/null > $logFilename

if [ ! -f $EMG_CONFIG_FILE ];
then
result=1
logError "Failed to locate EMG configure file $EMG_CONFIG_FILE"
return $result
fi

#
node setYamlVars ${EMG_CONFIG_FILE} 'edgemicro.logging.level' 'error' 'edgemicro.logging.stack_trace' false > tmp_emg_file.yaml
cp tmp_emg_file.yaml ${EMG_CONFIG_FILE}

reloadMicrogatewayNow

apiKey=$(getDeveloperApiKey ${DEVELOPER_NAME} ${DEVELOPER_APP_NAME})

curl -q -s http://localhost:8000/v1/invalidproxyFortesting -H "x-api-key: $apiKey" -D headers.txt > /dev/null 2>&1 ; ret=$?

sleep 5

logfiledata=$(cat $logFilename | grep -a "Error:" | cut -d ' ' -f1)
if [[ $logfiledata == *"Error:"* ]]; then
result=1
logError "Found trace log when stack_trace is false"
fi

return $result
}

0 comments on commit 0727d9d

Please sign in to comment.