Skip to content

Commit

Permalink
chore: add exit status codes for test pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: gouravkrosx <[email protected]>
  • Loading branch information
gouravkrosx committed Apr 23, 2024
1 parent 795dcc0 commit 7e19b14
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 8 deletions.
83 changes: 83 additions & 0 deletions keploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
path: ""
command: ""
port: 0
proxyPort: 16789
dnsPort: 26789
debug: false
disableANSI: false
disableTele: false
inDocker: false
generateGithubActions: true
containerName: ""
networkName: ""
buildDelay: 30s
test:
selectedTests: {}
globalNoise:
global: {}
test-sets: {}
delay: 5
apiTimeout: 5
coverage: false
goCoverage: false
coverageReportPath: ""
ignoreOrdering: true
mongoPassword: "default@123"
language: ""
removeUnusedMocks: false
record:
recordTimer: 0s
filters: []
configPath: ""
bypassRules: []
cmdType: "native"
enableTesting: false
fallbackOnMiss: false
keployContainer: "keploy-v2"
keployNetwork: "keploy-network"

# 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"]
# }
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,49 +48,49 @@ func main() {
*preRecPath, err = getAbsolutePath(*preRecPath)
if err != nil {
logger.Error("failed to get absolute path", zap.String("path", *preRecPath), zap.Error(err))
return
os.Exit(1)
}

*preRecPath = filepath.Join(*preRecPath, "keploy")

*testBenchPath, err = getAbsolutePath(*testBenchPath)
if err != nil {
logger.Error("failed to get absolute path", zap.String("path", *testBenchPath), zap.Error(err))
return
os.Exit(1)
}
*testBenchPath = filepath.Join(*testBenchPath, "keploy")

*configPath, err = getAbsolutePath(*configPath)
if err != nil {
logger.Error("failed to get absolute path", zap.String("path", *configPath), zap.Error(err))
return
os.Exit(1)
}
println("ConfigPath:", *configPath)

// get all the sessions
tsets1, err := pkg.ReadSessionIndices(*preRecPath, logger)
if err != nil {
logger.Error("failed to read session indices", zap.String("path", *preRecPath), zap.Error(err))
return
os.Exit(1)
}

tsets2, err := pkg.ReadSessionIndices(*testBenchPath, logger)
if err != nil {
logger.Error("failed to read session indices", zap.String("path", *testBenchPath), zap.Error(err))
return
os.Exit(1)
}

// compare sessions, both should contain equal number of same sessions
ok := compareSessions(tsets1, tsets2, logger)
if !ok {
logger.Error("sessions are not equal")
return
os.Exit(1)
}

sessions := tsets1

if len(sessions) == 0 {
logger.Info("no sessions found")
return
os.Exit(0)
}

// initialize the test dbs
Expand Down

0 comments on commit 7e19b14

Please sign in to comment.