* Fixes the issue with fn test and adds relevant test cases, fixes #650 * Checking log size for invalid function * Testing the invalid function logs a few time beforr quitting * Disabling the test for now, linked to issue #653
This commit is contained in:
+1
-1
@@ -43,7 +43,7 @@ func printPodLogs(c *cli.Context) error {
|
||||
fatal("Need --name argument.")
|
||||
}
|
||||
|
||||
queryURL, err := url.Parse(c.GlobalString("server"))
|
||||
queryURL, err := url.Parse(getServerUrl())
|
||||
checkErr(err, "parse the base URL")
|
||||
queryURL.Path = fmt.Sprintf("/proxy/logs/%s", fnName)
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// This file has an error on purpose; async is replaced with aasync
|
||||
module.exports = aasync function(context) {
|
||||
return {
|
||||
status: 200,
|
||||
body: "Hello, Fission!\n"
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = async function (context) {
|
||||
return {
|
||||
status: 200,
|
||||
body: "Hello, Fission!\n"
|
||||
};
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
#test:disabled
|
||||
# Disabled because CI Fails for invalid function https://github.com/fission/fission/issues/653
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
env=nodejs-$(date +%N)
|
||||
valid_fn_name=hello-$(date +%N)
|
||||
invalid_fn_name=errhello-$(date +%N)
|
||||
|
||||
function cleanup {
|
||||
log "Cleaning up"
|
||||
fission env delete --name $env
|
||||
fission fn delete --name $valid_fn_name
|
||||
fission fn delete --name $invalid_fn_name
|
||||
}
|
||||
|
||||
log "Creating env $env"
|
||||
fission env create --name $env --image fission/node-env
|
||||
trap cleanup EXIT
|
||||
|
||||
log "Creating valid function $valid_fn_name"
|
||||
fission fn create --name $valid_fn_name --env $env --code hello.js
|
||||
|
||||
log "Testing valid function $valid_fn_name"
|
||||
fission fn test --name $valid_fn_name > /tmp/valid.log
|
||||
|
||||
log "---Valid Function logs---"
|
||||
cat /tmp/valid.log
|
||||
log "------"
|
||||
valid_num=$(grep 'Hello, Fission' /tmp/valid.log | wc -l)
|
||||
|
||||
if [ $valid_num -ne 1 ]
|
||||
then
|
||||
log "Valid function Test Failed: expected 1, found $valid_num logs"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "Creating function with an error $invalid_fn_name"
|
||||
fission fn create --name $invalid_fn_name --env $env --code errhello.js
|
||||
|
||||
log "Testing invalid function $valid_fn_name"
|
||||
fission fn test --name $invalid_fn_name > /tmp/invalid.log
|
||||
|
||||
for i in {1..10}
|
||||
do
|
||||
size=$(wc -c </tmp/invalid.log)
|
||||
if [ $size == 0 ]
|
||||
then
|
||||
fission fn test --name $invalid_fn_name > /tmp/invalid.log
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
log "---Invalid Function logs---"
|
||||
cat /tmp/invalid.log
|
||||
log "------"
|
||||
invalid_num=$(grep 'SyntaxError' /tmp/invalid.log | wc -l)
|
||||
|
||||
if [ $invalid_num -ne 1 ]
|
||||
then
|
||||
log "Invalid function Failed: expected 1, found $invalid_num logs"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "All tests passed"
|
||||
Reference in New Issue
Block a user