@codyswann/lisa 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +867 -0
- package/all/copy-overwrite/.claude/README.md +205 -0
- package/all/copy-overwrite/.claude/agents/agent-architect.md +311 -0
- package/all/copy-overwrite/.claude/agents/codebase-analyzer.md +146 -0
- package/all/copy-overwrite/.claude/agents/codebase-locator.md +125 -0
- package/all/copy-overwrite/.claude/agents/codebase-pattern-finder.md +237 -0
- package/all/copy-overwrite/.claude/agents/git-history-analyzer.md +183 -0
- package/all/copy-overwrite/.claude/agents/hooks-expert.md +74 -0
- package/all/copy-overwrite/.claude/agents/skill-evaluator.md +246 -0
- package/all/copy-overwrite/.claude/agents/slash-command-architect.md +87 -0
- package/all/copy-overwrite/.claude/agents/web-search-researcher.md +112 -0
- package/all/copy-overwrite/.claude/commands/git/commit-and-submit-pr.md +8 -0
- package/all/copy-overwrite/.claude/commands/git/commit.md +44 -0
- package/all/copy-overwrite/.claude/commands/git/prune.md +34 -0
- package/all/copy-overwrite/.claude/commands/git/submit-pr.md +50 -0
- package/all/copy-overwrite/.claude/commands/jira/create.md +50 -0
- package/all/copy-overwrite/.claude/commands/jira/verify.md +34 -0
- package/all/copy-overwrite/.claude/commands/project/archive.md +8 -0
- package/all/copy-overwrite/.claude/commands/project/bootstrap.md +49 -0
- package/all/copy-overwrite/.claude/commands/project/complete-task.md +7 -0
- package/all/copy-overwrite/.claude/commands/project/debrief.md +65 -0
- package/all/copy-overwrite/.claude/commands/project/execute.md +94 -0
- package/all/copy-overwrite/.claude/commands/project/implement.md +42 -0
- package/all/copy-overwrite/.claude/commands/project/local-code-review.md +88 -0
- package/all/copy-overwrite/.claude/commands/project/lower-code-complexity.md +74 -0
- package/all/copy-overwrite/.claude/commands/project/plan.md +314 -0
- package/all/copy-overwrite/.claude/commands/project/research.md +248 -0
- package/all/copy-overwrite/.claude/commands/project/review.md +63 -0
- package/all/copy-overwrite/.claude/commands/project/setup.md +19 -0
- package/all/copy-overwrite/.claude/commands/project/verify.md +38 -0
- package/all/copy-overwrite/.claude/commands/pull-request/review.md +12 -0
- package/all/copy-overwrite/.claude/commands/rules/format-md.md +72 -0
- package/all/copy-overwrite/.claude/commands/sonarqube/check.md +6 -0
- package/all/copy-overwrite/.claude/commands/sonarqube/fix.md +3 -0
- package/all/copy-overwrite/.claude/hooks/README.md +301 -0
- package/all/copy-overwrite/.claude/hooks/notify-ntfy.sh +181 -0
- package/all/copy-overwrite/.claude/settings.json +41 -0
- package/all/copy-overwrite/.claude/settings.local.json.example +14 -0
- package/all/copy-overwrite/.claude/skills/coding-philosophy/SKILL.md +405 -0
- package/all/copy-overwrite/.claude/skills/coding-philosophy/references/function-structure.md +416 -0
- package/all/copy-overwrite/.claude/skills/coding-philosophy/references/immutable-patterns.md +316 -0
- package/all/copy-overwrite/.claude/skills/prompt-complexity-scorer/SKILL.md +118 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/LICENSE.txt +202 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/SKILL.md +210 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/__pycache__/quick_validate.cpython-312.pyc +0 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/init_skill.py +303 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/package_skill.py +110 -0
- package/all/copy-overwrite/.claude/skills/skill-creator/scripts/quick_validate.py +65 -0
- package/all/copy-overwrite/CLAUDE.md +77 -0
- package/all/copy-overwrite/HUMAN.md +17 -0
- package/all/copy-overwrite/specs/.keep +0 -0
- package/all/create-only/PROJECT_RULES.md +0 -0
- package/cdk/merge/package.json +20 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +107 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/prompts.d.ts +45 -0
- package/dist/cli/prompts.d.ts.map +1 -0
- package/dist/cli/prompts.js +58 -0
- package/dist/cli/prompts.js.map +1 -0
- package/dist/core/config.d.ts +73 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +36 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lisa.d.ts +81 -0
- package/dist/core/lisa.d.ts.map +1 -0
- package/dist/core/lisa.js +459 -0
- package/dist/core/lisa.js.map +1 -0
- package/dist/core/manifest.d.ts +58 -0
- package/dist/core/manifest.d.ts.map +1 -0
- package/dist/core/manifest.js +104 -0
- package/dist/core/manifest.js.map +1 -0
- package/dist/detection/detector.interface.d.ts +15 -0
- package/dist/detection/detector.interface.d.ts.map +1 -0
- package/dist/detection/detector.interface.js +2 -0
- package/dist/detection/detector.interface.js.map +1 -0
- package/dist/detection/detectors/cdk.d.ts +10 -0
- package/dist/detection/detectors/cdk.d.ts.map +1 -0
- package/dist/detection/detectors/cdk.js +34 -0
- package/dist/detection/detectors/cdk.js.map +1 -0
- package/dist/detection/detectors/expo.d.ts +10 -0
- package/dist/detection/detectors/expo.d.ts.map +1 -0
- package/dist/detection/detectors/expo.js +30 -0
- package/dist/detection/detectors/expo.js.map +1 -0
- package/dist/detection/detectors/nestjs.d.ts +10 -0
- package/dist/detection/detectors/nestjs.d.ts.map +1 -0
- package/dist/detection/detectors/nestjs.js +34 -0
- package/dist/detection/detectors/nestjs.js.map +1 -0
- package/dist/detection/detectors/npm-package.d.ts +13 -0
- package/dist/detection/detectors/npm-package.d.ts.map +1 -0
- package/dist/detection/detectors/npm-package.js +30 -0
- package/dist/detection/detectors/npm-package.js.map +1 -0
- package/dist/detection/detectors/typescript.d.ts +10 -0
- package/dist/detection/detectors/typescript.d.ts.map +1 -0
- package/dist/detection/detectors/typescript.js +25 -0
- package/dist/detection/detectors/typescript.js.map +1 -0
- package/dist/detection/index.d.ts +24 -0
- package/dist/detection/index.d.ts.map +1 -0
- package/dist/detection/index.js +57 -0
- package/dist/detection/index.js.map +1 -0
- package/dist/errors/index.d.ts +69 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +110 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/console-logger.d.ts +12 -0
- package/dist/logging/console-logger.d.ts.map +1 -0
- package/dist/logging/console-logger.js +22 -0
- package/dist/logging/console-logger.js.map +1 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +3 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.interface.d.ts +20 -0
- package/dist/logging/logger.interface.d.ts.map +1 -0
- package/dist/logging/logger.interface.js +2 -0
- package/dist/logging/logger.interface.js.map +1 -0
- package/dist/logging/silent-logger.d.ts +12 -0
- package/dist/logging/silent-logger.d.ts.map +1 -0
- package/dist/logging/silent-logger.js +21 -0
- package/dist/logging/silent-logger.js.map +1 -0
- package/dist/strategies/copy-contents.d.ts +14 -0
- package/dist/strategies/copy-contents.d.ts.map +1 -0
- package/dist/strategies/copy-contents.js +69 -0
- package/dist/strategies/copy-contents.js.map +1 -0
- package/dist/strategies/copy-overwrite.d.ts +14 -0
- package/dist/strategies/copy-overwrite.d.ts.map +1 -0
- package/dist/strategies/copy-overwrite.js +47 -0
- package/dist/strategies/copy-overwrite.js.map +1 -0
- package/dist/strategies/create-only.d.ts +13 -0
- package/dist/strategies/create-only.d.ts.map +1 -0
- package/dist/strategies/create-only.js +30 -0
- package/dist/strategies/create-only.js.map +1 -0
- package/dist/strategies/index.d.ts +31 -0
- package/dist/strategies/index.d.ts.map +1 -0
- package/dist/strategies/index.js +52 -0
- package/dist/strategies/index.js.map +1 -0
- package/dist/strategies/merge.d.ts +13 -0
- package/dist/strategies/merge.d.ts.map +1 -0
- package/dist/strategies/merge.js +60 -0
- package/dist/strategies/merge.js.map +1 -0
- package/dist/strategies/strategy.interface.d.ts +31 -0
- package/dist/strategies/strategy.interface.d.ts.map +1 -0
- package/dist/strategies/strategy.interface.js +2 -0
- package/dist/strategies/strategy.interface.js.map +1 -0
- package/dist/transaction/backup.d.ts +38 -0
- package/dist/transaction/backup.d.ts.map +1 -0
- package/dist/transaction/backup.js +97 -0
- package/dist/transaction/backup.js.map +1 -0
- package/dist/transaction/index.d.ts +4 -0
- package/dist/transaction/index.d.ts.map +1 -0
- package/dist/transaction/index.js +3 -0
- package/dist/transaction/index.js.map +1 -0
- package/dist/transaction/transaction.d.ts +34 -0
- package/dist/transaction/transaction.d.ts.map +1 -0
- package/dist/transaction/transaction.js +68 -0
- package/dist/transaction/transaction.js.map +1 -0
- package/dist/utils/file-operations.d.ts +29 -0
- package/dist/utils/file-operations.d.ts.map +1 -0
- package/dist/utils/file-operations.js +84 -0
- package/dist/utils/file-operations.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json-utils.d.ts +22 -0
- package/dist/utils/json-utils.d.ts.map +1 -0
- package/dist/utils/json-utils.js +57 -0
- package/dist/utils/json-utils.js.map +1 -0
- package/dist/utils/path-utils.d.ts +21 -0
- package/dist/utils/path-utils.d.ts.map +1 -0
- package/dist/utils/path-utils.js +35 -0
- package/dist/utils/path-utils.js.map +1 -0
- package/eslint-plugin-code-organization/README.md +149 -0
- package/eslint-plugin-code-organization/__tests__/enforce-statement-order.test.js +468 -0
- package/eslint-plugin-code-organization/index.js +23 -0
- package/eslint-plugin-code-organization/package.json +10 -0
- package/eslint-plugin-code-organization/rules/enforce-statement-order.js +157 -0
- package/expo/copy-overwrite/.claude/skills/apollo-client/SKILL.md +238 -0
- package/expo/copy-overwrite/.claude/skills/apollo-client/references/mutation-patterns.md +360 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/SKILL.md +360 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/references/atomic-levels.md +417 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/references/folder-structure.md +257 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/references/gluestack-mapping.md +233 -0
- package/expo/copy-overwrite/.claude/skills/atomic-design-gluestack/scripts/validate_atomic_structure.py +327 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/SKILL.md +299 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/references/examples.md +749 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/references/patterns.md +318 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/scripts/create_component.py +198 -0
- package/expo/copy-overwrite/.claude/skills/container-view-pattern/scripts/validate_component.py +207 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/SKILL.md +268 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/references/common-issues.md +619 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/references/file-extensions.md +340 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/references/platform-api.md +276 -0
- package/expo/copy-overwrite/.claude/skills/cross-platform-compatibility/scripts/validate_cross_platform.py +414 -0
- package/expo/copy-overwrite/.claude/skills/directory-structure/SKILL.md +202 -0
- package/expo/copy-overwrite/.claude/skills/directory-structure/scripts/validate_structure.py +443 -0
- package/expo/copy-overwrite/.claude/skills/expo-env-config/SKILL.md +309 -0
- package/expo/copy-overwrite/.claude/skills/expo-env-config/references/validation-patterns.md +417 -0
- package/expo/copy-overwrite/.claude/skills/expo-router-best-practices/SKILL.md +431 -0
- package/expo/copy-overwrite/.claude/skills/expo-router-best-practices/references/official-docs.md +290 -0
- package/expo/copy-overwrite/.claude/skills/expo-router-best-practices/scripts/generate-route.py +169 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/SKILL.md +411 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/references/color-tokens.md +343 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/references/component-mapping.md +307 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/references/spacing-scale.md +300 -0
- package/expo/copy-overwrite/.claude/skills/gluestack-nativewind/scripts/validate_styling.py +354 -0
- package/expo/copy-overwrite/.claude/skills/local-state/SKILL.md +362 -0
- package/expo/copy-overwrite/.claude/skills/local-state/references/async-storage.md +505 -0
- package/expo/copy-overwrite/.claude/skills/local-state/references/persistence-patterns.md +711 -0
- package/expo/copy-overwrite/.claude/skills/local-state/references/reactive-variables.md +446 -0
- package/expo/copy-overwrite/.claude/skills/playwright-selectors/SKILL.md +223 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/SKILL.md +319 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/references/async-patterns.md +420 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/references/expo-router-testing.md +556 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/references/mocking-patterns.md +590 -0
- package/expo/copy-overwrite/.claude/skills/testing-library/references/query-priority.md +291 -0
- package/expo/copy-overwrite/.easignore.extra +2 -0
- package/expo/copy-overwrite/.mcp.json +33 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/README.md +234 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/plugin-index.test.js +84 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/require-memo-in-view.test.js +196 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/__tests__/single-component-per-file.test.js +289 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/index.js +32 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/package.json +10 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/enforce-component-structure.js +230 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/no-return-in-view.js +91 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/require-memo-in-view.js +178 -0
- package/expo/copy-overwrite/eslint-plugin-component-structure/rules/single-component-per-file.js +238 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/README.md +260 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/index.js +29 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/package.json +10 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-classname-outside-ui.js +51 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-direct-rn-imports.js +55 -0
- package/expo/copy-overwrite/eslint-plugin-ui-standards/rules/no-inline-styles.js +73 -0
- package/expo/copy-overwrite/eslint.config.mjs +560 -0
- package/expo/copy-overwrite/lighthouserc.js +194 -0
- package/expo/create-only/lighthouserc-config.json +28 -0
- package/expo/merge/package.json +132 -0
- package/lisa.sh +35 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/SKILL.md +176 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/advanced-features.md +527 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/project-patterns.md +483 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/quick-start.md +257 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/resolvers-mutations.md +413 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-graphql/references/types-scalars.md +513 -0
- package/nestjs/copy-overwrite/.claude/skills/nestjs-rules/SKILL.md +536 -0
- package/nestjs/copy-overwrite/.claude/skills/typeorm-patterns/SKILL.md +275 -0
- package/nestjs/copy-overwrite/.claude/skills/typeorm-patterns/references/configuration-patterns.md +487 -0
- package/nestjs/copy-overwrite/.claude/skills/typeorm-patterns/references/entity-patterns.md +450 -0
- package/nestjs/copy-overwrite/.claude/skills/typeorm-patterns/references/observability-patterns.md +536 -0
- package/nestjs/merge/package.json +75 -0
- package/package.json +124 -0
- package/typescript/copy-contents/.husky/commit-msg +91 -0
- package/typescript/copy-contents/.husky/pre-commit +96 -0
- package/typescript/copy-contents/.husky/pre-push +211 -0
- package/typescript/copy-overwrite/.claude/hooks/format-on-edit.sh +74 -0
- package/typescript/copy-overwrite/.claude/hooks/install_pkgs.sh +59 -0
- package/typescript/copy-overwrite/.claude/hooks/lint-on-edit.sh +103 -0
- package/typescript/copy-overwrite/.claude/skills/jsdoc-best-practices/SKILL.md +388 -0
- package/typescript/copy-overwrite/.github/README.md +455 -0
- package/typescript/copy-overwrite/.github/dependabot.yml +40 -0
- package/typescript/copy-overwrite/.github/k6/BROWSER_TESTING_NOTE.md +129 -0
- package/typescript/copy-overwrite/.github/k6/INTEGRATION_GUIDE.md +354 -0
- package/typescript/copy-overwrite/.github/k6/README.md +386 -0
- package/typescript/copy-overwrite/.github/k6/SCENARIO_SELECTION_GUIDE.md +264 -0
- package/typescript/copy-overwrite/.github/k6/examples/customer-deploy-integration.yml +115 -0
- package/typescript/copy-overwrite/.github/k6/examples/data-driven-test.js +268 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/load.js +142 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/load.json +27 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/smoke.js +26 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/smoke.json +20 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/soak.js +244 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/soak.json +29 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/spike.js +180 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/spike.json +32 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/stress.js +206 -0
- package/typescript/copy-overwrite/.github/k6/scenarios/stress.json +38 -0
- package/typescript/copy-overwrite/.github/k6/scripts/api-test.js +452 -0
- package/typescript/copy-overwrite/.github/k6/scripts/default-test.js +185 -0
- package/typescript/copy-overwrite/.github/k6/thresholds/normal.json +30 -0
- package/typescript/copy-overwrite/.github/k6/thresholds/relaxed.json +21 -0
- package/typescript/copy-overwrite/.github/k6/thresholds/strict.json +29 -0
- package/typescript/copy-overwrite/.github/workflows/build.yml +72 -0
- package/typescript/copy-overwrite/.github/workflows/ci.yml +49 -0
- package/typescript/copy-overwrite/.github/workflows/claude.yml +51 -0
- package/typescript/copy-overwrite/.github/workflows/create-github-issue-on-failure.yml +113 -0
- package/typescript/copy-overwrite/.github/workflows/create-jira-issue-on-failure.yml +195 -0
- package/typescript/copy-overwrite/.github/workflows/create-sentry-issue-on-failure.yml +267 -0
- package/typescript/copy-overwrite/.github/workflows/deploy.yml +228 -0
- package/typescript/copy-overwrite/.github/workflows/k6-load-test-README.md +230 -0
- package/typescript/copy-overwrite/.github/workflows/lighthouse.yml +68 -0
- package/typescript/copy-overwrite/.github/workflows/load-test.yml +282 -0
- package/typescript/copy-overwrite/.github/workflows/quality.yml +1737 -0
- package/typescript/copy-overwrite/.github/workflows/release.yml +1599 -0
- package/typescript/copy-overwrite/.gitleaksignore +28 -0
- package/typescript/copy-overwrite/.nvmrc +1 -0
- package/typescript/copy-overwrite/.prettierignore +23 -0
- package/typescript/copy-overwrite/.prettierrc.json +22 -0
- package/typescript/copy-overwrite/.versionrc +42 -0
- package/typescript/copy-overwrite/.yamllint +20 -0
- package/typescript/copy-overwrite/commitlint.config.js +11 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/README.md +149 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/__tests__/enforce-statement-order.test.js +468 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/index.js +23 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/package.json +10 -0
- package/typescript/copy-overwrite/eslint-plugin-code-organization/rules/enforce-statement-order.js +157 -0
- package/typescript/copy-overwrite/eslint.config.mjs +390 -0
- package/typescript/copy-overwrite/eslint.ignore.config.json +57 -0
- package/typescript/copy-overwrite/eslint.thresholds.config.json +5 -0
- package/typescript/github-rulesets/base.json +106 -0
- package/typescript/merge/.claude/settings.json +28 -0
- package/typescript/merge/package.json +71 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
name: Deploy and Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
environment:
|
|
9
|
+
description: 'Deployment environment'
|
|
10
|
+
required: true
|
|
11
|
+
type: choice
|
|
12
|
+
options:
|
|
13
|
+
- staging
|
|
14
|
+
- production
|
|
15
|
+
default: staging
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
# Example: Using the release workflow
|
|
19
|
+
release:
|
|
20
|
+
uses: ./.github/workflows/release.yml
|
|
21
|
+
with:
|
|
22
|
+
environment: ${{ github.event.inputs.environment || 'staging' }}
|
|
23
|
+
secrets: inherit
|
|
24
|
+
|
|
25
|
+
# Customer-specific deployment steps
|
|
26
|
+
deploy:
|
|
27
|
+
needs: release
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
outputs:
|
|
30
|
+
app_url: ${{ steps.deploy.outputs.url }}
|
|
31
|
+
steps:
|
|
32
|
+
- name: Deploy to environment
|
|
33
|
+
id: deploy
|
|
34
|
+
run: |
|
|
35
|
+
# Your deployment logic here
|
|
36
|
+
echo "Deploying to ${{ github.event.inputs.environment || 'staging' }}..."
|
|
37
|
+
|
|
38
|
+
# Example output - replace with actual deployment URL
|
|
39
|
+
if [ "${{ github.event.inputs.environment || 'staging' }}" = "production" ]; then
|
|
40
|
+
echo "url=https://api.example.com" >> $GITHUB_OUTPUT
|
|
41
|
+
else
|
|
42
|
+
echo "url=https://staging.api.example.com" >> $GITHUB_OUTPUT
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# Run smoke test immediately after deployment
|
|
46
|
+
smoke_test:
|
|
47
|
+
needs: deploy
|
|
48
|
+
uses: ./.github/workflows/k6-load-test.yml
|
|
49
|
+
with:
|
|
50
|
+
environment: ${{ github.event.inputs.environment || 'staging' }}
|
|
51
|
+
test_scenario: smoke
|
|
52
|
+
base_url: ${{ needs.deploy.outputs.app_url }}
|
|
53
|
+
fail_on_threshold: true
|
|
54
|
+
secrets: inherit
|
|
55
|
+
|
|
56
|
+
# Run load test only if smoke test passes
|
|
57
|
+
load_test:
|
|
58
|
+
needs: [deploy, smoke_test]
|
|
59
|
+
uses: ./.github/workflows/k6-load-test.yml
|
|
60
|
+
with:
|
|
61
|
+
environment: ${{ github.event.inputs.environment || 'staging' }}
|
|
62
|
+
test_scenario: load
|
|
63
|
+
base_url: ${{ needs.deploy.outputs.app_url }}
|
|
64
|
+
fail_on_threshold: false # Don't fail deployment, just report
|
|
65
|
+
virtual_users: 20 # Override default VUs
|
|
66
|
+
secrets: inherit
|
|
67
|
+
|
|
68
|
+
# Optional: Run stress test for staging only
|
|
69
|
+
stress_test:
|
|
70
|
+
if: github.event.inputs.environment != 'production'
|
|
71
|
+
needs: [deploy, smoke_test]
|
|
72
|
+
uses: ./.github/workflows/k6-load-test.yml
|
|
73
|
+
with:
|
|
74
|
+
environment: ${{ github.event.inputs.environment || 'staging' }}
|
|
75
|
+
test_scenario: stress
|
|
76
|
+
base_url: ${{ needs.deploy.outputs.app_url }}
|
|
77
|
+
fail_on_threshold: false
|
|
78
|
+
upload_results: true
|
|
79
|
+
secrets: inherit
|
|
80
|
+
|
|
81
|
+
# Summary of all tests
|
|
82
|
+
test_summary:
|
|
83
|
+
needs: [smoke_test, load_test, stress_test]
|
|
84
|
+
if: always()
|
|
85
|
+
runs-on: ubuntu-latest
|
|
86
|
+
steps:
|
|
87
|
+
- name: Test Results Summary
|
|
88
|
+
run: |
|
|
89
|
+
echo "## 📊 Performance Test Summary" >> $GITHUB_STEP_SUMMARY
|
|
90
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
91
|
+
|
|
92
|
+
echo "### Smoke Test" >> $GITHUB_STEP_SUMMARY
|
|
93
|
+
if [ "${{ needs.smoke_test.outputs.test_passed }}" = "true" ]; then
|
|
94
|
+
echo "✅ **PASSED**" >> $GITHUB_STEP_SUMMARY
|
|
95
|
+
else
|
|
96
|
+
echo "❌ **FAILED**" >> $GITHUB_STEP_SUMMARY
|
|
97
|
+
fi
|
|
98
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
99
|
+
|
|
100
|
+
echo "### Load Test" >> $GITHUB_STEP_SUMMARY
|
|
101
|
+
if [ "${{ needs.load_test.outputs.test_passed }}" = "true" ]; then
|
|
102
|
+
echo "✅ **PASSED**" >> $GITHUB_STEP_SUMMARY
|
|
103
|
+
else
|
|
104
|
+
echo "⚠️ **FAILED** (non-blocking)" >> $GITHUB_STEP_SUMMARY
|
|
105
|
+
fi
|
|
106
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
107
|
+
|
|
108
|
+
if [ "${{ github.event.inputs.environment }}" != "production" ]; then
|
|
109
|
+
echo "### Stress Test" >> $GITHUB_STEP_SUMMARY
|
|
110
|
+
if [ "${{ needs.stress_test.outputs.test_passed }}" = "true" ]; then
|
|
111
|
+
echo "✅ **PASSED**" >> $GITHUB_STEP_SUMMARY
|
|
112
|
+
else
|
|
113
|
+
echo "⚠️ **FAILED** (non-blocking)" >> $GITHUB_STEP_SUMMARY
|
|
114
|
+
fi
|
|
115
|
+
fi
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import http from "k6/http";
|
|
2
|
+
import { check, group } from "k6";
|
|
3
|
+
import { SharedArray } from "k6/data";
|
|
4
|
+
import papaparse from "https://jslib.k6.io/papaparse/5.1.1/index.js";
|
|
5
|
+
import { randomItem } from "https://jslib.k6.io/k6-utils/1.2.0/index.js";
|
|
6
|
+
|
|
7
|
+
// Load test data from CSV file
|
|
8
|
+
const testUsers = new SharedArray("users", function () {
|
|
9
|
+
// In a real scenario, this would load from a CSV file
|
|
10
|
+
// For this example, we'll create sample data
|
|
11
|
+
return [
|
|
12
|
+
{ username: "user1", password: "pass1", role: "admin" },
|
|
13
|
+
{ username: "user2", password: "pass2", role: "user" },
|
|
14
|
+
{ username: "user3", password: "pass3", role: "user" },
|
|
15
|
+
{ username: "user4", password: "pass4", role: "moderator" },
|
|
16
|
+
{ username: "user5", password: "pass5", role: "user" },
|
|
17
|
+
];
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Load test scenarios from JSON
|
|
21
|
+
const testScenarios = new SharedArray("scenarios", function () {
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: "Browse Products",
|
|
25
|
+
endpoints: ["/products", "/products/featured", "/products/categories"],
|
|
26
|
+
expectedStatus: 200,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "Search Products",
|
|
30
|
+
endpoints: ["/search?q=laptop", "/search?q=phone", "/search?q=tablet"],
|
|
31
|
+
expectedStatus: 200,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "View Product Details",
|
|
35
|
+
endpoints: ["/products/1", "/products/2", "/products/3"],
|
|
36
|
+
expectedStatus: 200,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "Add to Cart",
|
|
40
|
+
endpoints: ["/cart/add"],
|
|
41
|
+
method: "POST",
|
|
42
|
+
expectedStatus: 201,
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Environment-specific configuration
|
|
48
|
+
const environments = {
|
|
49
|
+
dev: {
|
|
50
|
+
baseUrl: "https://dev.example.com",
|
|
51
|
+
timeout: "30s",
|
|
52
|
+
thinkTime: 1,
|
|
53
|
+
},
|
|
54
|
+
staging: {
|
|
55
|
+
baseUrl: "https://staging.example.com",
|
|
56
|
+
timeout: "20s",
|
|
57
|
+
thinkTime: 2,
|
|
58
|
+
},
|
|
59
|
+
production: {
|
|
60
|
+
baseUrl: "https://api.example.com",
|
|
61
|
+
timeout: "10s",
|
|
62
|
+
thinkTime: 3,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const ENV = __ENV.K6_ENVIRONMENT || "staging";
|
|
67
|
+
const config = environments[ENV];
|
|
68
|
+
|
|
69
|
+
export const options = {
|
|
70
|
+
scenarios: {
|
|
71
|
+
data_driven: {
|
|
72
|
+
executor: "ramping-arrival-rate",
|
|
73
|
+
startRate: 10,
|
|
74
|
+
timeUnit: "1m",
|
|
75
|
+
preAllocatedVUs: 10,
|
|
76
|
+
maxVUs: 50,
|
|
77
|
+
stages: [
|
|
78
|
+
{ duration: "2m", target: 30 },
|
|
79
|
+
{ duration: "5m", target: 30 },
|
|
80
|
+
{ duration: "2m", target: 0 },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
thresholds: {
|
|
85
|
+
http_req_failed: ["rate<0.1"],
|
|
86
|
+
http_req_duration: [`p(95)<${parseInt(config.timeout) * 100}`],
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Helper function to login and get auth token
|
|
91
|
+
function authenticateUser(user) {
|
|
92
|
+
const loginResponse = http.post(
|
|
93
|
+
`${config.baseUrl}/auth/login`,
|
|
94
|
+
JSON.stringify({
|
|
95
|
+
username: user.username,
|
|
96
|
+
password: user.password,
|
|
97
|
+
}),
|
|
98
|
+
{
|
|
99
|
+
headers: { "Content-Type": "application/json" },
|
|
100
|
+
timeout: config.timeout,
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (check(loginResponse, { "login successful": r => r.status === 200 })) {
|
|
105
|
+
const body = JSON.parse(loginResponse.body);
|
|
106
|
+
return body.token || body.access_token;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default function () {
|
|
113
|
+
// Select random user and scenario
|
|
114
|
+
const user = randomItem(testUsers);
|
|
115
|
+
const scenario = randomItem(testScenarios);
|
|
116
|
+
|
|
117
|
+
// Authenticate if needed
|
|
118
|
+
let authToken = null;
|
|
119
|
+
if (user.role !== "guest") {
|
|
120
|
+
authToken = authenticateUser(user);
|
|
121
|
+
|
|
122
|
+
if (!authToken) {
|
|
123
|
+
console.error(`Failed to authenticate user: ${user.username}`);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Execute scenario
|
|
129
|
+
group(`${scenario.name} - ${user.role}`, () => {
|
|
130
|
+
const headers = {
|
|
131
|
+
"Content-Type": "application/json",
|
|
132
|
+
"User-Agent": `k6-test/${ENV}`,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
if (authToken) {
|
|
136
|
+
headers["Authorization"] = `Bearer ${authToken}`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
scenario.endpoints.forEach(endpoint => {
|
|
140
|
+
const method = scenario.method || "GET";
|
|
141
|
+
const url = `${config.baseUrl}${endpoint}`;
|
|
142
|
+
|
|
143
|
+
let response;
|
|
144
|
+
if (method === "POST") {
|
|
145
|
+
// Generate dynamic payload based on endpoint
|
|
146
|
+
const payload = generatePayload(endpoint, user);
|
|
147
|
+
response = http.post(url, JSON.stringify(payload), {
|
|
148
|
+
headers,
|
|
149
|
+
timeout: config.timeout,
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
response = http.get(url, { headers, timeout: config.timeout });
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
check(response, {
|
|
156
|
+
[`${scenario.name} - status is ${scenario.expectedStatus}`]: r =>
|
|
157
|
+
r.status === scenario.expectedStatus,
|
|
158
|
+
"response time acceptable": r =>
|
|
159
|
+
r.timings.duration < parseInt(config.timeout) * 100,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Custom validation based on role
|
|
163
|
+
if (user.role === "admin") {
|
|
164
|
+
check(response, {
|
|
165
|
+
"admin data present": r => {
|
|
166
|
+
try {
|
|
167
|
+
const body = JSON.parse(r.body);
|
|
168
|
+
return (
|
|
169
|
+
body.adminData !== undefined || body.permissions !== undefined
|
|
170
|
+
);
|
|
171
|
+
} catch (e) {
|
|
172
|
+
return true; // Skip check if not JSON
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Dynamic think time based on environment
|
|
181
|
+
sleep(config.thinkTime + Math.random() * 2);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Generate dynamic payload based on endpoint and user
|
|
185
|
+
function generatePayload(endpoint, user) {
|
|
186
|
+
if (endpoint.includes("/cart/add")) {
|
|
187
|
+
return {
|
|
188
|
+
productId: Math.floor(Math.random() * 100) + 1,
|
|
189
|
+
quantity: Math.floor(Math.random() * 3) + 1,
|
|
190
|
+
userId: user.username,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (endpoint.includes("/order")) {
|
|
195
|
+
return {
|
|
196
|
+
items: [
|
|
197
|
+
{
|
|
198
|
+
productId: Math.floor(Math.random() * 100) + 1,
|
|
199
|
+
quantity: Math.floor(Math.random() * 3) + 1,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
shippingAddress: {
|
|
203
|
+
street: "123 Test St",
|
|
204
|
+
city: "Test City",
|
|
205
|
+
country: "Test Country",
|
|
206
|
+
},
|
|
207
|
+
paymentMethod: "test_card",
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return {};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export function handleSummary(data) {
|
|
215
|
+
const { metrics } = data;
|
|
216
|
+
|
|
217
|
+
// Group results by user role
|
|
218
|
+
const roleMetrics = {};
|
|
219
|
+
testUsers.forEach(user => {
|
|
220
|
+
// This is simplified - in reality, you'd parse metrics by tags
|
|
221
|
+
roleMetrics[user.role] = {
|
|
222
|
+
requests: Math.floor(
|
|
223
|
+
(metrics.http_reqs?.values?.count || 0) / testUsers.length
|
|
224
|
+
),
|
|
225
|
+
errors: Math.floor(
|
|
226
|
+
(metrics.http_req_failed?.values?.passes || 0) / testUsers.length
|
|
227
|
+
),
|
|
228
|
+
};
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const summary = {
|
|
232
|
+
environment: ENV,
|
|
233
|
+
timestamp: new Date().toISOString(),
|
|
234
|
+
total_requests: metrics.http_reqs?.values?.count || 0,
|
|
235
|
+
failed_requests: metrics.http_req_failed?.values?.passes || 0,
|
|
236
|
+
avg_response_time: Math.round(metrics.http_req_duration?.values?.avg || 0),
|
|
237
|
+
by_role: roleMetrics,
|
|
238
|
+
scenarios_tested: testScenarios.length,
|
|
239
|
+
users_tested: testUsers.length,
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
"k6-results/data-driven-summary.json": JSON.stringify(summary, null, 2),
|
|
244
|
+
stdout: createDataDrivenSummary(summary),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function createDataDrivenSummary(summary) {
|
|
249
|
+
let text = "\n=== Data-Driven Test Summary ===\n\n";
|
|
250
|
+
text += `Environment: ${summary.environment}\n`;
|
|
251
|
+
text += `Timestamp: ${summary.timestamp}\n`;
|
|
252
|
+
text += `Scenarios Tested: ${summary.scenarios_tested}\n`;
|
|
253
|
+
text += `Users Tested: ${summary.users_tested}\n\n`;
|
|
254
|
+
|
|
255
|
+
text += "Overall Results:\n";
|
|
256
|
+
text += ` Total Requests: ${summary.total_requests}\n`;
|
|
257
|
+
text += ` Failed Requests: ${summary.failed_requests}\n`;
|
|
258
|
+
text += ` Avg Response Time: ${summary.avg_response_time}ms\n\n`;
|
|
259
|
+
|
|
260
|
+
text += "Results by Role:\n";
|
|
261
|
+
Object.entries(summary.by_role).forEach(([role, metrics]) => {
|
|
262
|
+
text += ` ${role}:\n`;
|
|
263
|
+
text += ` Requests: ${metrics.requests}\n`;
|
|
264
|
+
text += ` Errors: ${metrics.errors}\n`;
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
return text;
|
|
268
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import http from "k6/http";
|
|
2
|
+
import { check, group, sleep } from "k6";
|
|
3
|
+
import { Rate } from "k6/metrics";
|
|
4
|
+
|
|
5
|
+
// Custom metrics
|
|
6
|
+
const errorRate = new Rate("errors");
|
|
7
|
+
const apiErrors = new Rate("api_errors");
|
|
8
|
+
|
|
9
|
+
export const options = {
|
|
10
|
+
stages: [
|
|
11
|
+
{ duration: "2m", target: 10 }, // Ramp up to 10 users
|
|
12
|
+
{ duration: "5m", target: 10 }, // Stay at 10 users
|
|
13
|
+
{ duration: "2m", target: 0 }, // Ramp down to 0 users
|
|
14
|
+
],
|
|
15
|
+
thresholds: {
|
|
16
|
+
http_req_failed: ["rate<0.05"], // http errors should be less than 5%
|
|
17
|
+
http_req_duration: ["p(95)<500"], // 95% of requests should be below 500ms
|
|
18
|
+
http_req_duration: ["p(99)<1000"], // 99% of requests should be below 1s
|
|
19
|
+
errors: ["rate<0.05"], // custom errors should be less than 5%
|
|
20
|
+
api_errors: ["rate<0.02"], // API errors should be less than 2%
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const BASE_URL = __ENV.K6_BASE_URL || "http://localhost:3000";
|
|
25
|
+
const CUSTOM_HEADERS = __ENV.K6_CUSTOM_HEADERS
|
|
26
|
+
? JSON.parse(__ENV.K6_CUSTOM_HEADERS)
|
|
27
|
+
: {};
|
|
28
|
+
|
|
29
|
+
export default function () {
|
|
30
|
+
const headers = {
|
|
31
|
+
"Content-Type": "application/json",
|
|
32
|
+
...CUSTOM_HEADERS,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// User flow simulation
|
|
36
|
+
group("Homepage Load", () => {
|
|
37
|
+
const homeResponse = http.get(`${BASE_URL}/`, {
|
|
38
|
+
headers,
|
|
39
|
+
tags: { name: "Home" },
|
|
40
|
+
});
|
|
41
|
+
check(homeResponse, {
|
|
42
|
+
"homepage status is 200": r => r.status === 200,
|
|
43
|
+
"homepage loads quickly": r => r.timings.duration < 300,
|
|
44
|
+
}) || errorRate.add(1);
|
|
45
|
+
sleep(1);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
group("API Health Check", () => {
|
|
49
|
+
const healthResponse = http.get(`${BASE_URL}/health`, {
|
|
50
|
+
headers,
|
|
51
|
+
tags: { name: "Health" },
|
|
52
|
+
});
|
|
53
|
+
check(healthResponse, {
|
|
54
|
+
"health check is healthy": r => r.status === 200,
|
|
55
|
+
"health check is fast": r => r.timings.duration < 100,
|
|
56
|
+
}) || errorRate.add(1);
|
|
57
|
+
sleep(0.5);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
group("API Operations", () => {
|
|
61
|
+
// GET request
|
|
62
|
+
const getResponse = http.get(`${BASE_URL}/api/items`, {
|
|
63
|
+
headers,
|
|
64
|
+
tags: { name: "API_GET" },
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const getCheck = check(getResponse, {
|
|
68
|
+
"GET status is 200": r => r.status === 200,
|
|
69
|
+
"GET response has data": r => {
|
|
70
|
+
try {
|
|
71
|
+
const body = JSON.parse(r.body);
|
|
72
|
+
return body && (Array.isArray(body) || body.data);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
"GET response time OK": r => r.timings.duration < 500,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
if (!getCheck) {
|
|
81
|
+
apiErrors.add(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
sleep(1);
|
|
85
|
+
|
|
86
|
+
// POST request (if applicable)
|
|
87
|
+
const payload = JSON.stringify({
|
|
88
|
+
name: `Test Item ${Date.now()}`,
|
|
89
|
+
value: Math.random() * 100,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const postResponse = http.post(`${BASE_URL}/api/items`, payload, {
|
|
93
|
+
headers,
|
|
94
|
+
tags: { name: "API_POST" },
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const postCheck = check(postResponse, {
|
|
98
|
+
"POST status is 201 or 200": r => r.status === 201 || r.status === 200,
|
|
99
|
+
"POST returns created item": r => {
|
|
100
|
+
try {
|
|
101
|
+
const body = JSON.parse(r.body);
|
|
102
|
+
return body && body.id;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"POST response time OK": r => r.timings.duration < 800,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (!postCheck) {
|
|
111
|
+
apiErrors.add(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
sleep(2);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Simulate user think time between iterations
|
|
118
|
+
sleep(Math.random() * 3 + 2); // 2-5 seconds
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function handleSummary(data) {
|
|
122
|
+
return {
|
|
123
|
+
"k6-results/load-summary.json": JSON.stringify(data),
|
|
124
|
+
stdout: textSummary(data, { indent: " ", enableColors: true }),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function textSummary(data, options) {
|
|
129
|
+
// Custom summary function for better console output
|
|
130
|
+
const { metrics } = data;
|
|
131
|
+
let summary = "\n=== Load Test Summary ===\n\n";
|
|
132
|
+
|
|
133
|
+
if (metrics) {
|
|
134
|
+
summary += `Total Requests: ${metrics.http_reqs?.values?.count || 0}\n`;
|
|
135
|
+
summary += `Failed Requests: ${metrics.http_req_failed?.values?.passes || 0}\n`;
|
|
136
|
+
summary += `Avg Response Time: ${Math.round(metrics.http_req_duration?.values?.avg || 0)}ms\n`;
|
|
137
|
+
summary += `95th Percentile: ${Math.round(metrics.http_req_duration?.values["p(95)"] || 0)}ms\n`;
|
|
138
|
+
summary += `99th Percentile: ${Math.round(metrics.http_req_duration?.values["p(99)"] || 0)}ms\n`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return summary;
|
|
142
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "load",
|
|
3
|
+
"description": "Standard load test with normal expected traffic",
|
|
4
|
+
"executor": "ramping-vus",
|
|
5
|
+
"startVUs": 0,
|
|
6
|
+
"stages": [
|
|
7
|
+
{ "duration": "2m", "target": 10 },
|
|
8
|
+
{ "duration": "5m", "target": 10 },
|
|
9
|
+
{ "duration": "2m", "target": 0 }
|
|
10
|
+
],
|
|
11
|
+
"gracefulStop": "30s",
|
|
12
|
+
"thresholds": {
|
|
13
|
+
"http_req_failed": ["rate<0.05"],
|
|
14
|
+
"http_req_duration": ["p(95)<500", "p(99)<1000"],
|
|
15
|
+
"http_req_receiving": ["p(95)<300"],
|
|
16
|
+
"checks": ["rate>0.9"],
|
|
17
|
+
"iterations": ["count>100"]
|
|
18
|
+
},
|
|
19
|
+
"env": {
|
|
20
|
+
"SCENARIO_NAME": "load",
|
|
21
|
+
"STEADY_STATE_DURATION": "5m"
|
|
22
|
+
},
|
|
23
|
+
"tags": {
|
|
24
|
+
"test_type": "load",
|
|
25
|
+
"environment": "${K6_ENVIRONMENT}"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import http from "k6/http";
|
|
2
|
+
import { check, sleep } from "k6";
|
|
3
|
+
|
|
4
|
+
export const options = {
|
|
5
|
+
vus: 1,
|
|
6
|
+
duration: "1m",
|
|
7
|
+
thresholds: {
|
|
8
|
+
http_req_failed: ["rate<0.01"], // http errors should be less than 1%
|
|
9
|
+
http_req_duration: ["p(95)<300"], // 95% of requests should be below 300ms
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const BASE_URL = __ENV.K6_BASE_URL || "http://localhost:3000";
|
|
14
|
+
|
|
15
|
+
export default function () {
|
|
16
|
+
// Smoke test - minimal load to verify system is working
|
|
17
|
+
const response = http.get(`${BASE_URL}/health`);
|
|
18
|
+
|
|
19
|
+
check(response, {
|
|
20
|
+
"status is 200": r => r.status === 200,
|
|
21
|
+
"response time < 300ms": r => r.timings.duration < 300,
|
|
22
|
+
"response has body": r => r.body.length > 0,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
sleep(1);
|
|
26
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "smoke",
|
|
3
|
+
"description": "Minimal load test to verify basic functionality",
|
|
4
|
+
"executor": "constant-vus",
|
|
5
|
+
"vus": 1,
|
|
6
|
+
"duration": "1m",
|
|
7
|
+
"thresholds": {
|
|
8
|
+
"http_req_failed": ["rate<0.01"],
|
|
9
|
+
"http_req_duration": ["p(95)<300", "p(99)<500"],
|
|
10
|
+
"checks": ["rate>0.95"]
|
|
11
|
+
},
|
|
12
|
+
"env": {
|
|
13
|
+
"SCENARIO_NAME": "smoke",
|
|
14
|
+
"RAMP_TIME": "10s"
|
|
15
|
+
},
|
|
16
|
+
"tags": {
|
|
17
|
+
"test_type": "smoke",
|
|
18
|
+
"environment": "${K6_ENVIRONMENT}"
|
|
19
|
+
}
|
|
20
|
+
}
|