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

fix how to pass the configuraton #1

Merged
merged 3 commits into from
Mar 30, 2024
Merged
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
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"printWidth": 120,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParents": "always"
"arrowParens": "always"
}
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,20 @@
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"ts-node": "^10.9.2",
"typescript": "5.3.3",
"webpack": "5.89.0",
"webpack-cli": "5.1.4",
"webpack-cli": "^5.1.4",
"webpack-glob-entries": "^1.0.1"
},
"scripts": {
"bundle": "webpack",
"lint:eslint": "npx eslint --ext .ts src",
"lint:prettier": "prettier --check src",
"format": "prettier --write 'src/**/*.ts' && npx eslint --fix --ext .ts src",
"smoke:sample-product": "./k6 run ./dist/loadTest.js --config ./src/sample-product/configs/smoke.json",
"smoke-debug:sample-product": "./k6 run ./dist/loadTest.js --config ./src/sample-product/configs/smoke.json --http-debug=full"
"smoke:sample-product": "./k6 run ./dist/loadTest.js -e CONFIG_PATH=./src/sample-product/configs/smoke.json",
"smoke-debug:sample-product": "./k6 run ./dist/loadTest.js -e CONFIG_PATH=./src/sample-product/configs/smoke.json --http-debug=full"
},
"dependencies": {
"find-up": "^7.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/sample-product/common/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { toBoolean } from './common'
const _ENV = parse(open("../.env"))
export const DEBUG =toBoolean(_ENV.DEBUG) || false
export const ENV = _ENV.ENV || 'local'
export const CONFIG_PATH = _ENV.CONFIG_PATH || ENV.CONFIG_PATH || '../src/sample-product/configs/smoke.json'
export const REDIS_ENDPOINT = _ENV.REDIS_ENDPOINT || 'redis://localhost:6379'
export const AMOUNT_OF_INDEX_SIZE_FOR_TEST_DATA = _ENV.AMOUNT_OF_INDEX_SIZE_FOR_TEST_DATA || 10000
export const SAMPLE_PRODUCT_ENDPOINT = _ENV.SAMPLE_PRODUCT_ENDPOINT || 'localhost'
export const SAMPLE_PRODUCT_ENDPOINT = _ENV.SAMPLE_PRODUCT_ENDPOINT || 'localhost'
12 changes: 12 additions & 0 deletions src/sample-product/configs/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as env from '../common/env'

export const OPTIONS_CONFIG = (): Record<string, unknown> => {
const defaultConfigs = {
blockHostnames: ['*.hogehoge.com'],
insecureSkipTLSVerify: true,
}

const configs = JSON.parse(open(env.CONFIG_PATH))

return Object.assign({}, defaultConfigs, configs)
}
7 changes: 3 additions & 4 deletions src/sample-product/loadTest.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Options } from 'k6/options'
import { setupTesting, teardownTesting, debugOrLog } from './common/common'
import { OPTIONS_CONFIG } from './configs/config'
import sampleScenario1 from './scenarios/sampleScenario1'
import sampleScenario2 from './scenarios/sampleScenario2'

// Options are passed from command line
export const options: Options = {}
export const options = OPTIONS_CONFIG() // eslint-disable-line

// The following document describe role of each endpoint
export { sampleScenario1, sampleScenario2 }
export { sampleScenario1, sampleScenario2 } // eslint-disable-line

export function setup(): void {
debugOrLog(`== setup() BEGIN ===========================================================`)
Expand Down
Loading