@@ -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