Skip to content

Commit

Permalink
Merge pull request #808 from kremerpatrick/issue-807
Browse files Browse the repository at this point in the history
  • Loading branch information
embano1 authored Feb 25, 2022
2 parents 19778c9 + 40ae218 commit cc04243
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/knative/powercli/kn-pcli-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Next, locate the `ConfigSpec` section of the JSON file. Change the `MaxMTU` prop
**WARNING** - This function will reconfigure your distributed virtual switch - if your MTU is not set to 1500, it will be reset by this function.
---

In a separate terminal, run either `send-cloudevent-test.ps1` (PowerShell Script) or `send-cloudevent-test.sh` (Bash Script) to simulate a CloudEvent payload being sent to the local container image
In a separate terminal, run either `send-cloudevent-test.ps1` (PowerShell Script) or `send-cloudevent-test.sh` (Bash Script) to simulate a CloudEvent payload being sent to the local container image. When run with no arguments, the scripts will send the contents of `test-payload.json` as the payload. If you pass the scripts a different filename as an argument, they will send the contents of the specified file instead. Example: `send-cloudevent-test.ps1 test-payload2.json`. This testing technique is useful when writing complex functions with varying payloads.

```console
Testing Function ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ $headers = @{
"ce-subject" = "DvsReconfiguredEvent";
}

$body = Get-Content -Raw -Path "./test-payload.json"
$payloadPath = "./test-payload.json"
if ( $args.Count -gt 0 ) {
if ( Test-Path $args[0] ) {
$payloadPath = $args[0]
}
else {
Write-Host "$(Get-Date) - ERROR: Invalid path"$args[0]"`n"
exit
}
}
$body = Get-Content -Raw -Path $payloadPath

Write-Host "Testing Function ..."
Invoke-WebRequest -Uri http://localhost:8080 -Method POST -Headers $headers -Body $body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

# The ce-subject value should match the event router subject in function.yaml
echo "Testing Function ..."
curl [email protected] \
PAYLOAD_PATH="test-payload.json"
if [ $# -gt 0 ]; then
if test -f "$1"; then
PAYLOAD_PATH=$1
else
echo "$1 not found"
exit 1
fi
fi
curl -d@$PAYLOAD_PATH \
-H "Content-Type: application/json" \
-H 'ce-specversion: 1.0' \
-H 'ce-id: d70079f9-fddd-4b7f-aa76-1193f28b0611' \
Expand Down

0 comments on commit cc04243

Please sign in to comment.