Skip to content

Commit

Permalink
Merge branch 'master' into k6-squash
Browse files Browse the repository at this point in the history
  • Loading branch information
taotao-circle authored Aug 2, 2024
2 parents 9314e6b + a51620d commit 80859dd
Show file tree
Hide file tree
Showing 17 changed files with 5,000 additions and 1 deletion.
1 change: 0 additions & 1 deletion .licenseignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ pkg:npm/solana-dapp
pkg:npm/ethereum
pkg:npm/iniparser@~1.0.5
pkg:npm/hardhat@%5E2.0.0

2 changes: 2 additions & 0 deletions k6/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
2 changes: 2 additions & 0 deletions k6/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
1 change: 1 addition & 0 deletions k6/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
50 changes: 50 additions & 0 deletions k6/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.DEFAULT_GOAL := build
ifeq (, $(shell which node))
NODE_INSTALLED=false
else
NODE_INSTALLED=true
endif

.PHONY: check-node-installed
check-node-installed:
@$(NODE_INSTALLED) || echo NodeJS is not installed. Call "make install" to install

.PHONY: build
build: clean check-node-installed node-modules
npm run bundle

.PHONY: build-dev
build-dev: export WEBPACK_DEVTOOL=source-map
build-dev: build

AWS_ACCOUNT_ID:=$(shell aws sts get-caller-identity --query "Account" --output text)
.PHONY: run
run: build
AWS_ACCOUNT_ID=$(AWS_ACCOUNT_ID) ./run-test.sh

.PHONY: run-dev
run-dev: export WEBPACK_DEVTOOL=source-map
run-dev: run

.PHONY: node-modules
node-modules:
npm install

.PHONY: clean
clean:
rm -rf dist

GOPATH_DIR = ${GOPATH}
ifeq ($(GOPATH_DIR),)
GOPATH_DIR := ~/go
endif
.PHONY: install
install:
brew install node@18
brew install k6
go install go.k6.io/xk6/cmd/xk6@latest
(cd $(GOPATH)/bin && ./xk6 build --with github.com/grafana/xk6-sql --with github.com/mridehalgh/xk6-sqs)

.PHONY: style
style: check-node-installed node-modules
npm run style
24 changes: 24 additions & 0 deletions k6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Usage

For a quick start:
- Follow the steps in [In-Depth Documentation](https://circlepay.atlassian.net/wiki/spaces/ENGINEERIN/pages/428179543/Load+Test+Instructions)
to install K6.
- Download dependencies and build the project by running: `make build`.
- (todo: Instruction of starting dependency services or mock)
- Start Verifier.
- Run tests with `make run` command. Example: `make run TEST=dist/verification.post_challenge.test.bundle.js`

| Command | Description | Environment Variables |
|-----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `make install` | Install all dependencies to run k6 locally | N/A |
| `make run` | Clean, build, and run tests locally | `TEST={PATH_TO_TEST_FILE} ENV={ENVIRONMENT}` <br/>Example: `make run ENV=dev TEST=dist/wallet_resource.create_wallet.test.bundle.js` <br/> When `ENV` is `dev`, logs will show the position of error in original source file |
| `make run-dev` | Clean, build with webpack source-map, and run tests locally. Errors during runtime will point to the error location in the original source file | Same as `make run` |
| `make style` | Style and fix all linting errors | N/A |
| `make check-node-installed` | Check if NodeJS is installed | N/A |
| `make build` | Build test source files to `dist` directory | N/A |
| `make build-dev` | Build test source files to `dist` directory with webpack source-map. | N/A |
| `make node-modules` | Install Node.JS npm dependencies | N/A |
| `make clean` | Clean test artifacts in `dist` directory | N/A |



91 changes: 91 additions & 0 deletions k6/k6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Copyright 2024 Circle Internet Group, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

services:
verifier_api:
url: "${VERIFIER_API_URL:-http://127.0.0.1:3000}"
issuer_api:
url: "${ISSUER_API_URL:-https://issuer-smokebox.circle.com}" # pointing to smoke box for local development

tests:
verification:
create:
k6_options:
setupTimeout: '2m' # timeout for the setup() function
thresholds:
http_req_failed: [ 'rate<0.01' ] # http errors should be less than 1%
scenarios:
scenario:
executor: 'ramping-vus' # https://k6.io/docs/using-k6/scenarios/executors/ramping-vus/
startVUs: 1
stages:
- duration: '1m'
target: 10
- duration: '30m'
target: 10
- duration: '1m'
target: 1
offer:
challenge_token_url_count: 20
k6_options:
setupTimeout: '2m' # timeout for the setup() function
thresholds:
http_req_failed: [ 'rate<0.01' ] # http errors should be less than 1%
scenarios:
scenario:
executor: 'ramping-vus' # https://k6.io/docs/using-k6/scenarios/executors/ramping-vus/
startVUs: 1
stages:
- duration: '1m'
target: 10
- duration: '30m'
target: 10
- duration: '1m'
target: 1
submit:
verifiable_credential_count: 20
k6_options:
setupTimeout: '2m' # timeout for the setup() function
thresholds:
http_req_failed: [ 'rate<0.01' ] # http errors should be less than 1%
scenarios:
scenario:
executor: 'ramping-vus' # https://k6.io/docs/using-k6/scenarios/executors/ramping-vus/
startVUs: 1
stages:
- duration: '1m'
target: 10
- duration: '30m'
target: 10
- duration: '1m'
target: 1
end_to_end:
verifiable_credential_count: 20
k6_options:
setupTimeout: '2m' # timeout for the setup() function
thresholds:
http_req_failed: [ 'rate<0.01' ] # http errors should be less than 1%
scenarios:
scenario:
executor: 'ramping-vus' # https://k6.io/docs/using-k6/scenarios/executors/ramping-vus/
startVUs: 1
stages:
- duration: '1m'
target: 10
- duration: '30m'
target: 10
- duration: '1m'
target: 1
Loading

0 comments on commit 80859dd

Please sign in to comment.