Skip to content

Commit 0727d9d

Browse files
authored
Merge pull request #271 from gaonkar18y/for307-func-tests-stack_trace-config
Add functional test cases for stack_trace config
2 parents 00445d2 + 75aeb42 commit 0727d9d

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

test-functional/NightlyTests.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,32 @@ main() {
521521
testFailCount=`expr $testFailCount + 1`
522522
fi
523523

524+
echo
525+
testCount=`expr $testCount + 1`
526+
echo "$testCount) testStackTraceConfig"
527+
testStackTraceConfig; ret=$?
528+
if [ $ret -eq 0 ]; then
529+
echo "$STATUS_PASS_STR"
530+
testPassCount=`expr $testPassCount + 1`
531+
else
532+
echo "$STATUS_FAIL_STR"
533+
result=1
534+
testFailCount=`expr $testFailCount + 1`
535+
fi
536+
537+
echo
538+
testCount=`expr $testCount + 1`
539+
echo "$testCount) testStackTraceFalseConfig"
540+
testStackTraceFalseConfig; ret=$?
541+
if [ $ret -eq 0 ]; then
542+
echo "$STATUS_PASS_STR"
543+
testPassCount=`expr $testPassCount + 1`
544+
else
545+
echo "$STATUS_FAIL_STR"
546+
result=1
547+
testFailCount=`expr $testFailCount + 1`
548+
fi
549+
524550
echo
525551
testCount=`expr $testCount + 1`
526552
echo "$testCount) testRevokedAPIKey"

test-functional/testEMG.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,5 +797,84 @@ testTraceEventLog() {
797797
logError "Failed to find event trace log"
798798
fi
799799

800+
return $result
801+
}
802+
803+
testStackTraceConfig() {
804+
805+
local result=0
806+
local logFilename=''
807+
808+
logInfo "Check if stack_trace config is working correctly"
809+
810+
# Clear the logs of previous tests
811+
logFilename=$(cat edgemicro.logs | grep "logging to" | cut -d ' ' -f7)
812+
cat /dev/null > $logFilename
813+
814+
if [ ! -f $EMG_CONFIG_FILE ];
815+
then
816+
result=1
817+
logError "Failed to locate EMG configure file $EMG_CONFIG_FILE"
818+
return $result
819+
fi
820+
821+
#
822+
node setYamlVars ${EMG_CONFIG_FILE} 'edgemicro.logging.level' 'error' 'edgemicro.logging.stack_trace' true > tmp_emg_file.yaml
823+
cp tmp_emg_file.yaml ${EMG_CONFIG_FILE}
824+
825+
reloadMicrogatewayNow
826+
827+
828+
apiKey=$(getDeveloperApiKey ${DEVELOPER_NAME} ${DEVELOPER_APP_NAME})
829+
830+
curl -q -s http://localhost:8000/v1/invalidproxyFortesting -H "x-api-key: $apiKey" -D headers.txt > /dev/null 2>&1 ; ret=$?
831+
832+
sleep 5
833+
834+
logfiledata=$(cat $logFilename | grep -a "Error:" | cut -d ' ' -f1)
835+
if [[ $logfiledata != *"Error:"* ]]; then
836+
result=1
837+
logError "Failed to find trace log when stack_trace is true"
838+
fi
839+
840+
return $result
841+
}
842+
843+
testStackTraceFalseConfig() {
844+
845+
local result=0
846+
local logFilename=''
847+
848+
logInfo "Check if stack_trace config is working correctly"
849+
850+
# Clear the logs of previous tests
851+
logFilename=$(cat edgemicro.logs | grep "logging to" | cut -d ' ' -f7)
852+
cat /dev/null > $logFilename
853+
854+
if [ ! -f $EMG_CONFIG_FILE ];
855+
then
856+
result=1
857+
logError "Failed to locate EMG configure file $EMG_CONFIG_FILE"
858+
return $result
859+
fi
860+
861+
#
862+
node setYamlVars ${EMG_CONFIG_FILE} 'edgemicro.logging.level' 'error' 'edgemicro.logging.stack_trace' false > tmp_emg_file.yaml
863+
cp tmp_emg_file.yaml ${EMG_CONFIG_FILE}
864+
865+
reloadMicrogatewayNow
866+
867+
apiKey=$(getDeveloperApiKey ${DEVELOPER_NAME} ${DEVELOPER_APP_NAME})
868+
869+
curl -q -s http://localhost:8000/v1/invalidproxyFortesting -H "x-api-key: $apiKey" -D headers.txt > /dev/null 2>&1 ; ret=$?
870+
871+
sleep 5
872+
873+
logfiledata=$(cat $logFilename | grep -a "Error:" | cut -d ' ' -f1)
874+
if [[ $logfiledata == *"Error:"* ]]; then
875+
result=1
876+
logError "Found trace log when stack_trace is false"
877+
fi
878+
800879
return $result
801880
}

0 commit comments

Comments
 (0)