-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49eeb93
commit b8a4e07
Showing
9 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ profile.out | |
coverage.out | ||
output | ||
cmd/seeder/exec/build | ||
keploy-logs.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
test: | ||
path: "" | ||
# mandatory | ||
command: "./main" | ||
proxyport: 0 | ||
containerName: "" | ||
networkName: "" | ||
# example: "test-set-1": ["test-1", "test-2", "test-3"] | ||
selectedTests: | ||
# to use globalNoise, please follow the guide at the end of this file. | ||
globalNoise: | ||
global: | ||
body: {} | ||
header: {"X-Request-Id":[]} | ||
delay: 5 | ||
buildDelay: 30s | ||
apiTimeout: 5 | ||
ignoreOrdering: false | ||
stubs: | ||
filters: | ||
- path: "" | ||
host: "" | ||
ports: 0 | ||
withCoverage: true | ||
generateTestReport: true | ||
coverageReportPath: "" | ||
|
||
# Example on using tests | ||
#tests: | ||
# filters: | ||
# - path: "/user/app" | ||
# urlMethods: ["GET"] | ||
# headers: { | ||
# "^asdf*": "^test" | ||
# } | ||
# host: "dc.services.visualstudio.com" | ||
#Example on using stubs | ||
#stubs: | ||
# filters: | ||
# - path: "/user/app" | ||
# port: 8080 | ||
# - port: 8081 | ||
# - host: "dc.services.visualstudio.com" | ||
# - port: 8081 | ||
# host: "dc.services.visualstudio.com" | ||
# path: "/user/app" | ||
# | ||
#Example on using globalNoise | ||
#globalNoise: | ||
# global: | ||
# body: { | ||
# # to ignore some values for a field, | ||
# # pass regex patterns to the corresponding array value | ||
# "url": ["https?://\S+", "http://\S+"], | ||
# } | ||
# header: { | ||
# # to ignore the entire field, pass an empty array | ||
# "Date": [], | ||
# } | ||
# # to ignore fields or the corresponding values for a specific test-set, | ||
# # pass the test-set-name as a key to the "test-sets" object and | ||
# # populate the corresponding "body" and "header" objects | ||
# test-sets: | ||
# test-set-1: | ||
# body: { | ||
# # ignore all the values for the "url" field | ||
# "url": [] | ||
# } | ||
# header: { | ||
# # we can also pass the exact value to ignore for a field | ||
# "User-Agent": ["PostmanRuntime/7.34.0"] | ||
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Download and install keploy | ||
curl --silent --location "https://github.com/keploy/keploy/releases/latest/download/keploy_linux_amd64.tar.gz" | tar xz -C /tmp | ||
sudo mkdir -p /usr/local/bin && sudo mv /tmp/keploy /usr/local/bin && keploy | ||
|
||
# Build the Go server | ||
go build -cover -o main ./cmd/server/main.go | ||
|
||
# Run tests with keploy | ||
sudo -E keploy test -c "./main" --withCoverage --delay 10 | ||
|
||
# Generate coverage profile | ||
go tool covdata textfmt -i="./keploy/coverage-reports" -o coverage-profile | ||
|
||
# Check coverage against threshold | ||
coverage_percentage=$(go tool cover -func=coverage-profile | grep 'total' | tail -n 1 | awk '{print $3}') | ||
coverage_percentage=${coverage_percentage%\%} # Remove the percentage sign | ||
threshold=80 | ||
echo "Required threshold: ${threshold}%" | ||
if (( $(awk -v num="$coverage_percentage" -v thresh="$threshold" 'BEGIN { if (num < thresh) print 1; else print 0 }') )); then | ||
echo "Coverage below threshold: $coverage_percentage%" | ||
exit 1 | ||
else | ||
echo "Coverage meets threshold: $coverage_percentage" | ||
fi | ||
|