Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: keploy integrate #70

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"corejs": 3
}
]
],
"plugins": [
"babel-plugin-istanbul"
]
}
}
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ jobs:
run: yarn install
- name: Lint
run: yarn lint
- name: Install keploy
run: curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh
himanshu-wedensday marked this conversation as resolved.
Show resolved Hide resolved
- name: Run Keploy test
run: keploy -c "yarn e2eTest"
- name: Test
run: yarn test
Comment on lines 29 to 30
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we need to run yarn test as well ? Because we are doing coverage total right

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need yarn test to generate coverage file for unit test.

- name: Total Coverage
run: yarn coverage:total
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<p>
An enterprise Mongo-Express REST API built using nodejs showcasing - Testing Strategy, mongoDB sharding, models, a REST API Interface, support for Redis, aggregation queries, aggregation caching, circuit-breakers, slack integration, RBAC, rate limited APIs and multi-container queues and schedulers.
</p>

---

<p>
Expand Down Expand Up @@ -80,6 +79,7 @@ A basic starter for a web app with node, express and mongoose -->
- Autogenerated swagger documentation
- Load testing using k6
- Support for i18n
- Support Keploy Test Integration

## Running Load tests

Expand Down Expand Up @@ -118,7 +118,33 @@ Run the following command to begin seeding
- ./seeders/seed.sh
- yarn start
- open browser to `localhost:9000` (port default to 9000)

## How to Run Tests
### Running Test with Jest
- To run the test using jest use command below

`yarn test`

### Running test with keploy
- Install Keploy using following command
` curl -O https://raw.githubusercontent.com/keploy/keploy/main/keploy.sh && source keploy.sh`
- To record the test with keploy Use the command below.

`keploy record -c 'yarn start'`

- To run the keploy test use following command

`keploy test -c 'yarn e2eTest'`
- To get Test coverage with keploy use command below

`yarn coverage:report`

Note: To run keploy test you must have lima for Mac and WSL for windows.
### Test Coverage
- To get Total coverage which includes unit-test coverage and keploy test coverage use command below:

`yarn coverage:total`

Note: To run keploy test you must have lima for Mac and WSL for windows.
## API Documentation

Once you've to the server started check out the api documentation at [/api-docs](http://localhost:9000/api-docs)
Expand Down
2 changes: 1 addition & 1 deletion jest.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"!__tests__/__load__/libs/**/*.*"
],
"testRegex": "(/__tests__/.*\\.test)\\.js$",
"coverageReporters": ["json-summary", "text", "lcov"],
"coverageReporters": ["json", "text", "lcov"],
"testPathIgnorePatterns": ["<rootDir>/dist/"],
"moduleNameMapper": {
"@server(.*)$": "<rootDir>/server/$1",
Expand Down
1,717 changes: 1,717 additions & 0 deletions keploy/test-set-2/mocks.yaml

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions keploy/test-set-2/tests/aggregate-order-amount-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
version: api.keploy.io/v1beta1
kind: Http
name: aggregate-order-amount-test
spec:
metadata: {}
req:
method: GET
proto_major: 1
proto_minor: 1
url: http://localhost:9000/aggregate/order-amount
header:
Accept: application/json
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Host: localhost:9000
Keploy-Test-Name: aggregate-order-amount-test
Postman-Token: 7a11718d-8130-4df2-aab7-f9fa73a8daa2
User-Agent: PostmanRuntime/7.37.3
body: ""
timestamp: 2024-05-14T13:04:03.507615257+05:30
resp:
status_code: 200
header:
Access-Control-Allow-Origin: '*'
Connection: keep-alive
Content-Length: "184"
Content-Security-Policy: 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' https: data:;form-action ''self'';frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
Content-Type: application/json; charset=utf-8
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Date: Tue, 14 May 2024 07:34:03 GMT
Etag: W/"b8-Nra9DUYrCDsBvr9MBzavAdVFbEg"
Expect-Ct: max-age=0
Keep-Alive: timeout=5
Origin-Agent-Cluster: ?1
Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-Dns-Prefetch-Control: "off"
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Response-Time: 1.088ms
X-Xss-Protection: "0"
body: '{"errors":[{"name":"UnauthorizedError","message":"No authorization token was found","code":"credentials_required","status":401,"inner":{"message":"No authorization token was found"}}]}'
status_message: OK
proto_major: 0
proto_minor: 0
timestamp: 2024-05-14T13:04:05.56695173+05:30
objects: []
assertions:
noise:
body.errors.status: []
header.Date: []
header.X-Response-Time: []
created: 1715672045
curl: |
curl --request GET \
--url http://localhost:9000/aggregate/order-amount \
--header 'Keploy-Test-Name: aggregate-order-amount-test' \
--header 'User-Agent: PostmanRuntime/7.37.3' \
--header 'Postman-Token: 7a11718d-8130-4df2-aab7-f9fa73a8daa2' \
--header 'Host: localhost:9000' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Connection: keep-alive' \
--header 'Accept: application/json' \
84 changes: 84 additions & 0 deletions keploy/test-set-2/tests/assign-role-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
version: api.keploy.io/v1beta1
kind: Http
name: assign-role-test
spec:
metadata: {}
req:
method: PUT
proto_major: 1
proto_minor: 1
url: http://localhost:9000/assign-roles
header:
Accept: '*/*'
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: "118"
Content-Type: application/json
Host: localhost:9000
Keploy-Test-Name: assign-role-test
Postman-Token: f3366d2f-8272-418c-ac12-e7d56bfb5f7d
User-Agent: PostmanRuntime/7.37.3
body: |-
{
"authId": "sunt",
"role": [
"ea magna voluptate mollit nostrud",
"exercitation anim qui consequat"
]
}
timestamp: 2024-05-14T13:04:03.487410149+05:30
resp:
status_code: 200
header:
Access-Control-Allow-Origin: '*'
Connection: keep-alive
Content-Length: "184"
Content-Security-Policy: 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' https: data:;form-action ''self'';frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
Content-Type: application/json; charset=utf-8
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Date: Tue, 14 May 2024 07:34:03 GMT
Etag: W/"b8-Nra9DUYrCDsBvr9MBzavAdVFbEg"
Expect-Ct: max-age=0
Keep-Alive: timeout=5
Origin-Agent-Cluster: ?1
Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-Dns-Prefetch-Control: "off"
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Response-Time: 2.504ms
X-Xss-Protection: "0"
body: '{"errors":[{"name":"UnauthorizedError","message":"No authorization token was found","code":"credentials_required","status":401,"inner":{"message":"No authorization token was found"}}]}'
status_message: OK
proto_major: 0
proto_minor: 0
timestamp: 2024-05-14T13:04:05.566862564+05:30
objects: []
assertions:
noise:
body.errors.status: []
header.Date: []
header.X-Response-Time: []
created: 1715672045
curl: |-
curl --request PUT \
--url http://localhost:9000/assign-roles \
--header 'Accept: */*' \
--header 'Content-Type: application/json' \
--header 'Postman-Token: f3366d2f-8272-418c-ac12-e7d56bfb5f7d' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Host: localhost:9000' \
--header 'Connection: keep-alive' \
--header 'User-Agent: PostmanRuntime/7.37.3' \
--header 'Keploy-Test-Name: assign-role-test' \
--data '{
"authId": "sunt",
"role": [
"ea magna voluptate mollit nostrud",
"exercitation anim qui consequat"
]
}'
78 changes: 78 additions & 0 deletions keploy/test-set-2/tests/create-role-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
version: api.keploy.io/v1beta1
kind: Http
name: create-role-test
spec:
metadata: {}
req:
method: POST
proto_major: 1
proto_minor: 1
url: http://localhost:9000/roles
header:
Accept: '*/*'
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: "58"
Content-Type: application/json
Host: localhost:9000
Keploy-Test-Name: create-role-test
Postman-Token: e7a4697c-5bbe-4e83-9865-bb884bf28673
User-Agent: PostmanRuntime/7.37.3
body: |-
{
"name": "adipisicing",
"description": "nostrud ea"
}
timestamp: 2024-05-14T13:04:03.455470022+05:30
resp:
status_code: 200
header:
Access-Control-Allow-Origin: '*'
Connection: keep-alive
Content-Length: "184"
Content-Security-Policy: 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' https: data:;form-action ''self'';frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
Content-Type: application/json; charset=utf-8
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Date: Tue, 14 May 2024 07:34:03 GMT
Etag: W/"b8-Nra9DUYrCDsBvr9MBzavAdVFbEg"
Expect-Ct: max-age=0
Keep-Alive: timeout=5
Origin-Agent-Cluster: ?1
Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-Dns-Prefetch-Control: "off"
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Response-Time: 1.964ms
X-Xss-Protection: "0"
body: '{"errors":[{"name":"UnauthorizedError","message":"No authorization token was found","code":"credentials_required","status":401,"inner":{"message":"No authorization token was found"}}]}'
status_message: OK
proto_major: 0
proto_minor: 0
timestamp: 2024-05-14T13:04:05.466285958+05:30
objects: []
assertions:
noise:
body.errors.status: []
header.Date: []
header.X-Response-Time: []
created: 1715672045
curl: |-
curl --request POST \
--url http://localhost:9000/roles \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'User-Agent: PostmanRuntime/7.37.3' \
--header 'Content-Type: application/json' \
--header 'Host: localhost:9000' \
--header 'Connection: keep-alive' \
--header 'Accept: */*' \
--header 'Postman-Token: e7a4697c-5bbe-4e83-9865-bb884bf28673' \
--header 'Keploy-Test-Name: create-role-test' \
--data '{
"name": "adipisicing",
"description": "nostrud ea"
}'
68 changes: 68 additions & 0 deletions keploy/test-set-2/tests/create-store-product-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: api.keploy.io/v1beta1
kind: Http
name: create-store-product-test
spec:
metadata: {}
req:
method: POST
proto_major: 1
proto_minor: 1
url: http://localhost:9000/store-products
header:
Accept: application/json
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: "0"
Host: localhost:9000
Keploy-Test-Name: create-store-product-test
Postman-Token: c5b8fa81-7598-4a4b-a5a9-7e14eb0c557a
User-Agent: PostmanRuntime/7.37.3
body: ""
timestamp: 2024-05-14T13:04:00.600687265+05:30
resp:
status_code: 200
header:
Access-Control-Allow-Origin: '*'
Connection: keep-alive
Content-Length: "184"
Content-Security-Policy: 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' https: data:;form-action ''self'';frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests'
Content-Type: application/json; charset=utf-8
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Date: Tue, 14 May 2024 07:34:00 GMT
Etag: W/"b8-Nra9DUYrCDsBvr9MBzavAdVFbEg"
Expect-Ct: max-age=0
Keep-Alive: timeout=5
Origin-Agent-Cluster: ?1
Referrer-Policy: no-referrer
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Content-Type-Options: nosniff
X-Dns-Prefetch-Control: "off"
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Response-Time: 0.415ms
X-Xss-Protection: "0"
body: '{"errors":[{"name":"UnauthorizedError","message":"No authorization token was found","code":"credentials_required","status":401,"inner":{"message":"No authorization token was found"}}]}'
status_message: OK
proto_major: 0
proto_minor: 0
timestamp: 2024-05-14T13:04:02.647431789+05:30
objects: []
assertions:
noise:
body.errors.status: []
header.Date: []
header.X-Response-Time: []
created: 1715672042
curl: |
curl --request POST \
--url http://localhost:9000/store-products \
--header 'Postman-Token: c5b8fa81-7598-4a4b-a5a9-7e14eb0c557a' \
--header 'Host: localhost:9000' \
--header 'Accept-Encoding: gzip, deflate, br' \
--header 'Connection: keep-alive' \
--header 'Accept: application/json' \
--header 'Keploy-Test-Name: create-store-product-test' \
--header 'User-Agent: PostmanRuntime/7.37.3' \
Loading
Loading