diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4f927d7a61b..378e648c3c3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,79 +1,79 @@ { - "name": "Dapr Dev Environment", - // Update the container version when you publish dev-container - "image": "ghcr.io/dapr/dapr-dev:latest", - // Replace with uncommented line below to build your own local copy of the image - //"dockerFile": "../docker/Dockerfile-dev", - "containerEnv": { - // Uncomment to overwrite devcontainer .kube/config and .minikube certs with the localhost versions - // each time the devcontainer starts, if the respective .kube-localhost/config and .minikube-localhost - // folders respectively are bind mounted to the devcontainer. - // "SYNC_LOCALHOST_KUBECONFIG": "true", + "name": "Dapr Dev Environment", + // Update the container version when you publish dev-container + "image": "ghcr.io/dapr/dapr-dev:latest", + // Replace with uncommented line below to build your own local copy of the image + //"dockerFile": "../docker/Dockerfile-dev", + "containerEnv": { + // Uncomment to overwrite devcontainer .kube/config and .minikube certs with the localhost versions + // each time the devcontainer starts, if the respective .kube-localhost/config and .minikube-localhost + // folders respectively are bind mounted to the devcontainer. + // "SYNC_LOCALHOST_KUBECONFIG": "true", - // Uncomment to disable docker-in-docker and automatically proxy default /var/run/docker.sock to - // the localhost bind-mount /var/run/docker-host.sock. - // "BIND_LOCALHOST_DOCKER": "true", + // Uncomment to disable docker-in-docker and automatically proxy default /var/run/docker.sock to + // the localhost bind-mount /var/run/docker-host.sock. + // "BIND_LOCALHOST_DOCKER": "true", - // Necessary for components-contrib's certification tests - "GOLANG_PROTOBUF_REGISTRATION_CONFLICT": "true" - }, - "extensions": [ - "davidanson.vscode-markdownlint", - "golang.go", - "ms-azuretools.vscode-dapr", - "ms-azuretools.vscode-docker", - "ms-kubernetes-tools.vscode-kubernetes-tools" - ], - "features": { - "ghcr.io/devcontainers/features/sshd:1": {}, - "ghcr.io/devcontainers/features/github-cli:1": {}, - "ghcr.io/devcontainers/features/azure-cli:1": {} - }, - "mounts": [ - // Mount docker-in-docker library volume - "type=volume,source=dind-var-lib-docker,target=/var/lib/docker", + // Necessary for components-contrib's certification tests + "GOLANG_PROTOBUF_REGISTRATION_CONFLICT": "true" + }, + "extensions": [ + "davidanson.vscode-markdownlint", + "golang.go", + "ms-azuretools.vscode-dapr", + "ms-azuretools.vscode-docker", + "ms-kubernetes-tools.vscode-kubernetes-tools" + ], + "features": { + "ghcr.io/devcontainers/features/sshd:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/azure-cli:1": {} + }, + "mounts": [ + // Mount docker-in-docker library volume + "type=volume,source=dind-var-lib-docker,target=/var/lib/docker", - // Bind mount docker socket under an alias to support docker-from-docker - "type=bind,source=/var/run/docker.sock,target=/var/run/docker-host.sock" + // Bind mount docker socket under an alias to support docker-from-docker + "type=bind,source=/var/run/docker.sock,target=/var/run/docker-host.sock" - // Uncomment to clone local .kube/config into devcontainer - // "type=bind,source=${env:HOME}${env:USERPROFILE}/.kube,target=/home/dapr/.kube-localhost", + // Uncomment to clone local .kube/config into devcontainer + // "type=bind,source=${env:HOME}${env:USERPROFILE}/.kube,target=/home/dapr/.kube-localhost", - // Uncomment to additionally clone minikube certs into devcontainer for use with .kube/config - // "type=bind,source=${env:HOME}${env:USERPROFILE}/.minikube,target=/home/dapr/.minikube-localhost" - ], - // Always run image-defined default command - "overrideCommand": false, - // On Linux, this will prevent new files getting created as root, but you - // may need to update the USER_UID and USER_GID in docker/Dockerfile-dev - // to match your user if not 1000. - "remoteUser": "dapr", - "runArgs": [ - // Enable ptrace-based debugging for go - "--cap-add=SYS_PTRACE", - "--security-opt", - "seccomp=unconfined", + // Uncomment to additionally clone minikube certs into devcontainer for use with .kube/config + // "type=bind,source=${env:HOME}${env:USERPROFILE}/.minikube,target=/home/dapr/.minikube-localhost" + ], + // Always run image-defined default command + "overrideCommand": false, + // On Linux, this will prevent new files getting created as root, but you + // may need to update the USER_UID and USER_GID in docker/Dockerfile-dev + // to match your user if not 1000. + "remoteUser": "dapr", + "runArgs": [ + // Enable ptrace-based debugging for go + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined", - // Uncomment to bind to host network for local devcontainer; this is necessary if using the - // bind-mounted /var/run/docker-host.sock directly. - // "--net=host", + // Uncomment to bind to host network for local devcontainer; this is necessary if using the + // bind-mounted /var/run/docker-host.sock directly. + // "--net=host", - // Enable docker-in-docker configuration. Comment out if not using for better security. - "--privileged", + // Enable docker-in-docker configuration. Comment out if not using for better security. + "--privileged", - // Run the entrypoint defined in container image. - "--init" - ], - "settings": { - "go.toolsManagement.checkForUpdates": "local", - "go.useLanguageServer": true, - "go.gopath": "/go", - "go.buildTags": "e2e,perf,conftests,unit,integration_test,certtests", - "git.alwaysSignOff": true, - "terminal.integrated.env.linux": { - "GOLANG_PROTOBUF_REGISTRATION_CONFLICT": "ignore" - } - }, - "workspaceFolder": "/workspaces/dapr", - "workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/workspaces/dapr" -} \ No newline at end of file + // Run the entrypoint defined in container image. + "--init" + ], + "settings": { + "go.toolsManagement.checkForUpdates": "local", + "go.useLanguageServer": true, + "go.gopath": "/go", + "go.buildTags": "e2e,perf,conftests,unit,integration_test,certtests", + "git.alwaysSignOff": true, + "terminal.integrated.env.linux": { + "GOLANG_PROTOBUF_REGISTRATION_CONFLICT": "ignore" + } + }, + "workspaceFolder": "/workspaces/dapr", + "workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/workspaces/dapr" +} diff --git a/.github/scripts/check_go_mod.mjs b/.github/scripts/check_go_mod.mjs index 9906b248072..ebaa1f28603 100755 --- a/.github/scripts/check_go_mod.mjs +++ b/.github/scripts/check_go_mod.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node -import {readFile} from 'node:fs/promises' +import { readFile } from 'node:fs/promises' const match = `// Uncomment for local development for testing with changes in the components-contrib repository. // Don't commit with this uncommented! @@ -10,9 +10,11 @@ const match = `// Uncomment for local development for testing with changes in th // Then, run \`make modtidy\` in this repository. // This ensures that go.mod and go.sum are up-to-date.` -const read = await readFile('go.mod', {encoding: 'utf8'}) +const read = await readFile('go.mod', { encoding: 'utf8' }) if (!read.includes(match)) { - console.log('File go.mod was committed with a change in the block around "replace github.com/dapr/components-contrib"') + console.log( + 'File go.mod was committed with a change in the block around "replace github.com/dapr/components-contrib"' + ) process.exit(1) } console.log('go.mod is ok') diff --git a/.github/scripts/dapr_bot.js b/.github/scripts/dapr_bot.js index 78c557806fd..8a8cffc2502 100644 --- a/.github/scripts/dapr_bot.js +++ b/.github/scripts/dapr_bot.js @@ -19,35 +19,45 @@ const owners = [ 'shubham1172', 'skyao', 'tanvigour', - 'yaron2' -]; + 'yaron2', +] const SDKs = [ - "dotnet-sdk", - "go-sdk", - "java-sdk", - "js-sdk", - "python-sdk", - "php-sdk", -]; + 'dotnet-sdk', + 'go-sdk', + 'java-sdk', + 'js-sdk', + 'python-sdk', + 'php-sdk', +] -const docsIssueBodyTpl = (issueNumber) => `This issue was automatically created by \ +const docsIssueBodyTpl = ( + issueNumber +) => `This issue was automatically created by \ [Dapr Bot](https://github.com/dapr/dapr/blob/master/.github/workflows/dapr-bot.yml) because a \"docs-needed\" label \ was added to dapr/dapr#${issueNumber}. \n\n\ -TODO: Add more details as per [this template](.github/ISSUE_TEMPLATE/new-content-needed.md).`; +TODO: Add more details as per [this template](.github/ISSUE_TEMPLATE/new-content-needed.md).` -const sdkIssueBodyTpl = (issueNumber) => `This issue was automatically created by \ +const sdkIssueBodyTpl = ( + issueNumber +) => `This issue was automatically created by \ [Dapr Bot](https://github.com/dapr/dapr/blob/master/.github/workflows/dapr-bot.yml) because a \"sdk-needed\" label \ was added to dapr/dapr#${issueNumber}. \n\n\ -TODO: Add more details.`; +TODO: Add more details.` module.exports = async ({ github, context }) => { - if (context.eventName == "issue_comment" && context.payload.action == "created") { - await handleIssueCommentCreate({ github, context }); - } else if (context.eventName == "issues" && context.payload.action == "labeled") { - await handleIssueLabeled({ github, context }); + if ( + context.eventName == 'issue_comment' && + context.payload.action == 'created' + ) { + await handleIssueCommentCreate({ github, context }) + } else if ( + context.eventName == 'issues' && + context.payload.action == 'labeled' + ) { + await handleIssueLabeled({ github, context }) } else { - console.log(`[main] event ${context.eventName} not supported, exiting.`); + console.log(`[main] event ${context.eventName} not supported, exiting.`) } } @@ -55,44 +65,55 @@ module.exports = async ({ github, context }) => { * Handle issue comment create event. */ async function handleIssueCommentCreate({ github, context }) { - const payload = context.payload; - const issue = context.issue; - const username = context.actor; - const isFromPulls = !!payload.issue.pull_request; - const commentBody = payload.comment.body; + const payload = context.payload + const issue = context.issue + const username = context.actor + const isFromPulls = !!payload.issue.pull_request + const commentBody = payload.comment.body if (!commentBody) { - console.log("[handleIssueCommentCreate] comment body not found, exiting."); - return; + console.log( + '[handleIssueCommentCreate] comment body not found, exiting.' + ) + return } const commandParts = commentBody.split(/\s+/) - const command = commandParts.shift(); + const command = commandParts.shift() // Commands that can be executed by anyone. - if (command === "/assign") { - await cmdAssign(github, issue, username, isFromPulls); - return; + if (command === '/assign') { + await cmdAssign(github, issue, username, isFromPulls) + return } // Commands that can only be executed by owners. - if (owners.indexOf(username) < 0) { - console.log(`[handleIssueCommentCreate] user ${username} is not an owner, exiting.`); - return; + if (!owners.includes(username)) { + console.log( + `[handleIssueCommentCreate] user ${username} is not an owner, exiting.` + ) + return } switch (command) { - case "/make-me-laugh": - await cmdMakeMeLaugh(github, issue); - break; - case "/ok-to-test": - await cmdOkToTest(github, issue, isFromPulls); - break; - case "/ok-to-perf": - await cmdOkToPerf(github, issue, isFromPulls, commandParts.join(" ")); - break; + case '/make-me-laugh': + await cmdMakeMeLaugh(github, issue) + break + case '/ok-to-test': + await cmdOkToTest(github, issue, isFromPulls) + break + case '/ok-to-perf': + await cmdOkToPerf( + github, + issue, + isFromPulls, + commandParts.join(' ') + ) + break default: - console.log(`[handleIssueCommentCreate] command ${command} not found, exiting.`); - break; + console.log( + `[handleIssueCommentCreate] command ${command} not found, exiting.` + ) + break } } @@ -100,40 +121,42 @@ async function handleIssueCommentCreate({ github, context }) { * Handle issue labeled event. */ async function handleIssueLabeled({ github, context }) { - const payload = context.payload; - const label = payload.label.name; - const issueNumber = payload.issue.number; + const payload = context.payload + const label = payload.label.name + const issueNumber = payload.issue.number // This should not run in forks. - if (context.repo.owner !== "dapr") { - console.log("[handleIssueLabeled] not running in dapr repo, exiting."); - return; + if (context.repo.owner !== 'dapr') { + console.log('[handleIssueLabeled] not running in dapr repo, exiting.') + return } // Authorization is not required here because it's triggered by an issue label event. // Only authorized users can add labels to issues. - if (label == "docs-needed") { + if (label == 'docs-needed') { // Open a new issue await github.issues.create({ - owner: "dapr", - repo: "docs", + owner: 'dapr', + repo: 'docs', title: `New content needed for dapr/dapr#${issueNumber}`, - labels: ["content/missing-information", "created-by/dapr-bot"], + labels: ['content/missing-information', 'created-by/dapr-bot'], body: docsIssueBodyTpl(issueNumber), }) - } else if (label == "sdk-needed") { + } else if (label == 'sdk-needed') { // Open an issue in all SDK repos. for (const sdk of SDKs) { await github.issues.create({ - owner: "dapr", + owner: 'dapr', repo: sdk, title: `Add support for dapr/dapr#${issueNumber}`, - labels: ["enhancement", "created-by/dapr-bot"], + labels: ['enhancement', 'created-by/dapr-bot'], body: sdkIssueBodyTpl(issueNumber), }) } } else { - console.log(`[handleIssueLabeled] label ${label} not supported, exiting.`); + console.log( + `[handleIssueLabeled] label ${label} not supported, exiting.` + ) } } @@ -141,16 +164,20 @@ async function handleIssueLabeled({ github, context }) { * Assign the issue to the user who commented. * @param {*} github GitHub object reference * @param {*} issue GitHub issue object - * @param {*} username GitHub user who commented + * @param {string} username GitHub user who commented * @param {boolean} isFromPulls is the workflow triggered by a pull request? */ async function cmdAssign(github, issue, username, isFromPulls) { if (isFromPulls) { - console.log("[cmdAssign] pull requests unsupported, skipping command execution."); - return; + console.log( + '[cmdAssign] pull requests unsupported, skipping command execution.' + ) + return } else if (issue.assignees && issue.assignees.length !== 0) { - console.log("[cmdAssign] issue already has assignees, skipping command execution."); - return; + console.log( + '[cmdAssign] issue already has assignees, skipping command execution.' + ) + return } await github.issues.addAssignees({ @@ -158,7 +185,7 @@ async function cmdAssign(github, issue, username, isFromPulls) { repo: issue.repo, issue_number: issue.number, assignees: [username], - }); + }) } /** @@ -167,11 +194,13 @@ async function cmdAssign(github, issue, username, isFromPulls) { * @param {*} issue GitHub issue object */ async function cmdMakeMeLaugh(github, issue) { - const result = await github.request("https://official-joke-api.appspot.com/random_joke"); - jokedata = result.data; - joke = "I have a bad feeling about this."; + const result = await github.request( + 'https://official-joke-api.appspot.com/random_joke' + ) + jokedata = result.data + joke = 'I have a bad feeling about this.' if (jokedata && jokedata.setup && jokedata.punchline) { - joke = `${jokedata.setup} - ${jokedata.punchline}`; + joke = `${jokedata.setup} - ${jokedata.punchline}` } await github.issues.createComment({ @@ -179,7 +208,7 @@ async function cmdMakeMeLaugh(github, issue) { repo: issue.repo, issue_number: issue.number, body: joke, - }); + }) } /** @@ -190,35 +219,41 @@ async function cmdMakeMeLaugh(github, issue) { */ async function cmdOkToTest(github, issue, isFromPulls) { if (!isFromPulls) { - console.log("[cmdOkToTest] only pull requests supported, skipping command execution."); - return; + console.log( + '[cmdOkToTest] only pull requests supported, skipping command execution.' + ) + return } // Get pull request const pull = await github.pulls.get({ owner: issue.owner, repo: issue.repo, - pull_number: issue.number - }); + pull_number: issue.number, + }) if (pull && pull.data) { // Get commit id and repo from pull head const testPayload = { pull_head_ref: pull.data.head.sha, pull_head_repo: pull.data.head.repo.full_name, - command: "ok-to-test", + command: 'ok-to-test', issue: issue, - }; + } // Fire repository_dispatch event to trigger e2e test await github.repos.createDispatchEvent({ owner: issue.owner, repo: issue.repo, - event_type: "e2e-test", + event_type: 'e2e-test', client_payload: testPayload, - }); + }) - console.log(`[cmdOkToTest] triggered E2E test for ${JSON.stringify(testPayload)}`); + console.log( + `[cmdOkToTest] triggered E2E test for ${JSON.stringify( + testPayload + )}` + ) } } @@ -230,35 +265,41 @@ async function cmdOkToTest(github, issue, isFromPulls) { */ async function cmdOkToPerf(github, issue, isFromPulls, args) { if (!isFromPulls) { - console.log("[cmdOkToPerf] only pull requests supported, skipping command execution."); - return; + console.log( + '[cmdOkToPerf] only pull requests supported, skipping command execution.' + ) + return } // Get pull request const pull = await github.pulls.get({ owner: issue.owner, repo: issue.repo, - pull_number: issue.number - }); + pull_number: issue.number, + }) if (pull && pull.data) { // Get commit id and repo from pull head const perfPayload = { pull_head_ref: pull.data.head.sha, pull_head_repo: pull.data.head.repo.full_name, - command: "ok-to-perf", + command: 'ok-to-perf', args, issue: issue, - }; + } // Fire repository_dispatch event to trigger e2e test await github.repos.createDispatchEvent({ owner: issue.owner, repo: issue.repo, - event_type: "perf-test", + event_type: 'perf-test', client_payload: perfPayload, - }); + }) - console.log(`[cmdOkToPerf] triggered perf test for ${JSON.stringify(perfPayload)}`); + console.log( + `[cmdOkToPerf] triggered perf test for ${JSON.stringify( + perfPayload + )}` + ) } } diff --git a/.github/scripts/dapr_tests_summary.js b/.github/scripts/dapr_tests_summary.js index af7500b8825..87b5eac6fec 100644 --- a/.github/scripts/dapr_tests_summary.js +++ b/.github/scripts/dapr_tests_summary.js @@ -1,7 +1,9 @@ const fs = require('fs') module.exports = async ({ glob, core }) => { - const globber = await glob.create(process.env["TEST_OUTPUT_FILE_PREFIX"] + "_summary_table_*.json") + const globber = await glob.create( + process.env['TEST_OUTPUT_FILE_PREFIX'] + '_summary_table_*.json' + ) for await (const file of globber.globGenerator()) { const testSummary = JSON.parse(fs.readFileSync(file, 'utf8')) await core.summary @@ -9,4 +11,4 @@ module.exports = async ({ glob, core }) => { .addTable(testSummary.data) .write() } -} \ No newline at end of file +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..f5ee2578171 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +tests/apps/*/obj/Debug +tests/apps/*/obj/Release +grafana/*.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000000..e74ed9ff357 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "trailingComma": "es5", + "tabWidth": 4, + "semi": false, + "singleQuote": true +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e5c7dbb5143..ccf698cbe8f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,6 +57,9 @@ All contributions come through pull requests. To submit a proposed change, we re 1. Fork the relevant repo and create a new branch 1. Create your change - Code changes require tests + - Make sure to run the linters to check and format the code: + - `make lint` executes the linter for Go code + - `make me prettier` uses Prettier to format JavaScript / JSON files (needed only if you've modified those) 1. Update relevant documentation for the change 1. Commit with [DCO sign-off](#developer-certificate-of-origin-signing-your-work) and open a PR 1. Wait for the CI process to finish and make sure all checks are green @@ -85,14 +88,16 @@ By making a contribution to this project, I certify that: Contributors sign-off that they adhere to these requirements by adding a `Signed-off-by` line to commit messages. -``` +```text This is my commit message Signed-off-by: Random J Developer ``` + Git even has a `-s` command line option to append this automatically to your commit message: -``` -$ git commit -s -m 'This is my commit message' + +```sh +git commit -s -m 'This is my commit message' ``` Each Pull Request is checked whether or not commits in a Pull Request do contain a valid Signed-off-by line. @@ -101,7 +106,7 @@ Each Pull Request is checked whether or not commits in a Pull Request do contai No worries - You can easily replay your changes, sign them and force push them! -``` +```sh git checkout git commit --amend --no-edit --signoff git push --force-with-lease diff --git a/Makefile b/Makefile index 79ae6537dd9..59a69fc3339 100644 --- a/Makefile +++ b/Makefile @@ -465,6 +465,26 @@ ifeq (,$(wildcard $(BUILD_TOOLS))) cd .build-tools; CGO_ENABLED=$(CGO) GOOS=$(TARGET_OS_LOCAL) GOARCH=$(TARGET_ARCH_LOCAL) go build -o $(BUILD_TOOLS_BIN) . endif +################################################################################ +# Prettier # +################################################################################ +.PHONY: prettier-install prettier-check prettier-format me prettier +prettier-install: + npm install --global prettier + +prettier-check: + npx prettier --check "*/**/*.{ts,js,mjs,json}" + +prettier-format: + npx prettier --write "*/**/*.{ts,js,mjs,json}" + +# "make me prettier" +me: + @echo "🪄💄🪄💄🪄💄" + +prettier: + @npx prettier --write "*/**/*.{ts,js,mjs,json}" + ################################################################################ # Targets for components-contrib # ################################################################################ diff --git a/swagger/swagger.json b/swagger/swagger.json index 33a10f12c49..69d56cc8092 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -1,389 +1,377 @@ -{ - "openapi": "3.0.2", - "info": { - "title": "Service Invocation", - "version": "1.0", - "description": "Using the service invocation API, your microservice can find and reliably communicate with other microservices in your system using standard protocols (gRPC or HTTP are currently supported).", - "termsOfService": "https://github.com/dapr/docs/blob/master/LICENSE", - "contact": {}, - "license": { - "name": "Apache 2.0 License", - "url": "https://github.com/dapr/docs/blob/master/LICENSE" - }, - "x-logo": { - "url": "" - } - }, - "servers": [ - { - "url": "http://{url}", - "description": "This endpoint lets you invoke a method in another Dapr enabled app.", - "variables": { - "url": { - "default": "localhost:3500", - "description": "url" - } - }, - "x-last-modified": 1597254685557 - } - ], - "paths": { - "/v1.0/invoke/{appId}/method/{method-name}": { - "description": "This endpoint lets you invoke a method in another Dapr enabled app.", - "get": { - "tags": [ - "Invocation ", - "service" - ], - "parameters": [ - { - "deprecated": false, - "$ref": "#/components/parameters/appId" - }, - { - "deprecated": false, - "$ref": "#/components/parameters/method-name" - }, - { - "deprecated": false, - "$ref": "#/components/parameters/Content-Type" - }, - { - "$ref": "#/components/securitySchemes/ApiKeyAuth", - "name": "ApiKeyAuth", - "x-last-modified": 1597270199372 - } - ], - "responses": { - "200": { - "$ref": "#/components/responses/200" - }, - "500": { - "$ref": "#/components/responses/500" - } - }, - "deprecated": false, - "operationId": "invoke_get", - "summary": "Invoke a method on a remote dapr app", - "description": "This endpoint lets you invoke a method in another Dapr enabled app.", - "externalDocs": { - "description": "Documentation", - "url": "https://docs.dapr.io/reference/api/service_invocation_api/" - } - }, - "put": { - "requestBody": { - "description": "Within the body of the request place the data you want to send to the service:\n{\n \"arg1\": 10,\n \"arg2\": 23,\n \"operator\": \"+\"\n}\n", - "content": { - "application/json": { - "schema": { - "description": "any app arguments", - "type": "object", - "example": { - "arg1": 10, - "arg2": 23, - "operator": "+" - }, - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "example": { - "arg1": 10, - "arg2": 23, - "operator": "+" - }, - "description": "any app arguments", - "type": "object", - "properties": "", - "x-rc-meta": { - "x-rc-comments": {} - } - } - } - }, - "tags": [ - "Invocation ", - "service" - ], - "parameters": [ - { - "deprecated": false, - "$ref": "#/components/parameters/appId" - }, - { - "deprecated": false, - "$ref": "#/components/parameters/method-name" - }, - { - "deprecated": false, - "$ref": "#/components/parameters/Content-Type", - "name": "Content-Type" - }, - { - "$ref": "#/components/securitySchemes/ApiKeyAuth", - "name": "ApiKeyAuth", - "x-last-modified": 1597270378537 - } - ], - "responses": { - "200": { - "$ref": "#/components/responses/200" - }, - "500": { - "$ref": "#/components/responses/500" - } - }, - "operationId": "invoke_put", - "summary": "This endpoint lets you invoke a method in another Dapr enabled app.", - "externalDocs": { - "url": "" - } - }, - "post": { - "requestBody": { - "description": "Within the body of the request place the data you want to send to the service:\n{\n \"arg1\": 10,\n \"arg2\": 23,\n \"operator\": \"+\"\n}\n", - "content": { - "application/json": { - "schema": { - "description": "Within the body of the request place the data you want to send to the service:\n{\n \"arg1\": 10,\n \"arg2\": 23,\n \"operator\": \"+\"\n}", - "type": "object", - "example": { - "arg1": 10, - "arg2": 23, - "operator": "+" - }, - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "example": { - "arg1": 10, - "arg2": 23, - "operator": "+" - }, - "x-rc-meta": { - "x-rc-comments": {} - } - } - } - }, - "tags": [ - "Invocation ", - "service" - ], - "parameters": [ - { - "deprecated": false, - "$ref": "#/components/parameters/appId" - }, - { - "deprecated": false, - "$ref": "#/components/parameters/method-name" - }, - { - "deprecated": false, - "$ref": "#/components/parameters/Content-Type" - }, - { - "$ref": "#/components/securitySchemes/ApiKeyAuth", - "name": "ApiKeyAuth", - "x-last-modified": 1597270398630 - } - ], - "responses": { - "200": { - "$ref": "#/components/responses/200" - }, - "500": { - "$ref": "#/components/responses/500" - } - }, - "operationId": "invoke_post", - "summary": "This endpoint lets you invoke a method in another Dapr enabled app.", - "externalDocs": { - "url": "https://docs.dapr.io/reference/api/service_invocation_api/" - } - }, - "delete": { - "tags": [ - "Invocation ", - "service" - ], - "parameters": [ - { - "deprecated": false, - "$ref": "#/components/parameters/appId" - }, - { - "deprecated": false, - "$ref": "#/components/parameters/method-name" - }, - { - "deprecated": false, - "$ref": "#/components/parameters/Content-Type" - }, - { - "$ref": "#/components/securitySchemes/ApiKeyAuth", - "name": "ApiKeyAuth", - "x-last-modified": 1597270419336 - } - ], - "responses": { - "200": { - "$ref": "#/components/responses/200" - }, - "500": { - "$ref": "#/components/responses/500" - } - }, - "operationId": "invoke_delete", - "summary": "This endpoint lets you invoke a method in another Dapr enabled app." - }, - "x-last-modified": 1597254788230 - } - }, - "components": { - "responses": { - "200": { - "content": { - "text/plain": { - "schema": { - "type": "number", - "example": "", - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "example": 200, - "x-rc-meta": { - "x-rc-comments": {} - } - } - }, - "description": "Operation succeeded", - "x-last-modified": 1597011885893 - }, - "500": { - "content": { - "text/plain": { - "schema": { - "format": "", - "pattern": "", - "type": "number", - "example": 500, - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "example": 500, - "x-rc-meta": { - "x-rc-comments": {} - } - } - }, - "description": "Server Error", - "x-last-modified": 1597011858483 - } - }, - "parameters": { - "method-name": { - "example": "neworder", - "name": "method-name", - "description": "name of the method to be envoked", - "schema": { - "format": "", - "description": "name of the method to be envoked", - "pattern": "", - "type": "string", - "example": "neworder", - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "in": "path", - "required": true, - "x-last-modified": 1597011358645, - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "appId": { - "example": "nodeapp", - "name": "appId", - "description": "the App ID associated with the remote app", - "schema": { - "format": "", - "description": "the App ID associated with the remote app", - "pattern": "", - "type": "string", - "example": "nodeapp", - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "in": "path", - "required": true, - "x-last-modified": 1597253939494, - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "Content-Type": { - "deprecated": false, - "example": "application/json", - "name": "Content-Type", - "description": "the App ID associated with the remote app", - "schema": { - "format": "", - "description": "the App ID associated with the remote app", - "pattern": "", - "type": "string", - "example": "application/json", - "x-rc-meta": { - "x-rc-comments": {} - } - }, - "in": "header", - "required": false, - "x-last-modified": 1597269332645, - "x-rc-meta": { - "x-rc-comments": {} - } - } - }, - "securitySchemes": { - "ApiKeyAuth": { - "type": "apiKey", - "name": "dapr-api-token", - "in": "header", - "x-last-modified": 1597014915425 - } - }, - "schemas": {} - }, - "tags": [ - { - "name": "service", - "description": "Dapr provides users with the ability to call other applications that have unique ids. This functionality allows apps to interact with one another via named identifiers and puts the burden of service discovery on the Dapr runtime.", - "externalDocs": { - "description": "Dapr provides users with the ability to call other applications that have unique ids. This functionality allows apps to interact with one another via named identifiers and puts the burden of service discovery on the Dapr runtime.", - "url": "https://docs.dapr.io/reference/api/service_invocation_api/" - }, - "x-last-modified": 1594246229173 - }, - { - "name": "Invocation ", - "description": "Dapr provides users with the ability to call other applications that have unique ids. This functionality allows apps to interact with one another via named identifiers and puts the burden of service discovery on the Dapr runtime.\n\n", - "externalDocs": { - "url": "https://docs.dapr.io/reference/api/service_invocation_api/" - }, - "x-last-modified": 1594246379461 - } - ], - "externalDocs": { - "description": "Dapr provides users with the ability to call other applications that have unique ids. This functionality allows apps to interact with one another via named identifiers and puts the burden of service discovery on the Dapr runtime.", - "url": "https://docs.dapr.io/reference/api/service_invocation_api/" - }, - "security": [] -} +{ + "openapi": "3.0.2", + "info": { + "title": "Service Invocation", + "version": "1.0", + "description": "Using the service invocation API, your microservice can find and reliably communicate with other microservices in your system using standard protocols (gRPC or HTTP are currently supported).", + "termsOfService": "https://github.com/dapr/docs/blob/master/LICENSE", + "contact": {}, + "license": { + "name": "Apache 2.0 License", + "url": "https://github.com/dapr/docs/blob/master/LICENSE" + }, + "x-logo": { + "url": "" + } + }, + "servers": [ + { + "url": "http://{url}", + "description": "This endpoint lets you invoke a method in another Dapr enabled app.", + "variables": { + "url": { + "default": "localhost:3500", + "description": "url" + } + }, + "x-last-modified": 1597254685557 + } + ], + "paths": { + "/v1.0/invoke/{appId}/method/{method-name}": { + "description": "This endpoint lets you invoke a method in another Dapr enabled app.", + "get": { + "tags": ["Invocation ", "service"], + "parameters": [ + { + "deprecated": false, + "$ref": "#/components/parameters/appId" + }, + { + "deprecated": false, + "$ref": "#/components/parameters/method-name" + }, + { + "deprecated": false, + "$ref": "#/components/parameters/Content-Type" + }, + { + "$ref": "#/components/securitySchemes/ApiKeyAuth", + "name": "ApiKeyAuth", + "x-last-modified": 1597270199372 + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/200" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "deprecated": false, + "operationId": "invoke_get", + "summary": "Invoke a method on a remote dapr app", + "description": "This endpoint lets you invoke a method in another Dapr enabled app.", + "externalDocs": { + "description": "Documentation", + "url": "https://docs.dapr.io/reference/api/service_invocation_api/" + } + }, + "put": { + "requestBody": { + "description": "Within the body of the request place the data you want to send to the service:\n{\n \"arg1\": 10,\n \"arg2\": 23,\n \"operator\": \"+\"\n}\n", + "content": { + "application/json": { + "schema": { + "description": "any app arguments", + "type": "object", + "example": { + "arg1": 10, + "arg2": 23, + "operator": "+" + }, + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "example": { + "arg1": 10, + "arg2": 23, + "operator": "+" + }, + "description": "any app arguments", + "type": "object", + "properties": "", + "x-rc-meta": { + "x-rc-comments": {} + } + } + } + }, + "tags": ["Invocation ", "service"], + "parameters": [ + { + "deprecated": false, + "$ref": "#/components/parameters/appId" + }, + { + "deprecated": false, + "$ref": "#/components/parameters/method-name" + }, + { + "deprecated": false, + "$ref": "#/components/parameters/Content-Type", + "name": "Content-Type" + }, + { + "$ref": "#/components/securitySchemes/ApiKeyAuth", + "name": "ApiKeyAuth", + "x-last-modified": 1597270378537 + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/200" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "operationId": "invoke_put", + "summary": "This endpoint lets you invoke a method in another Dapr enabled app.", + "externalDocs": { + "url": "" + } + }, + "post": { + "requestBody": { + "description": "Within the body of the request place the data you want to send to the service:\n{\n \"arg1\": 10,\n \"arg2\": 23,\n \"operator\": \"+\"\n}\n", + "content": { + "application/json": { + "schema": { + "description": "Within the body of the request place the data you want to send to the service:\n{\n \"arg1\": 10,\n \"arg2\": 23,\n \"operator\": \"+\"\n}", + "type": "object", + "example": { + "arg1": 10, + "arg2": 23, + "operator": "+" + }, + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "example": { + "arg1": 10, + "arg2": 23, + "operator": "+" + }, + "x-rc-meta": { + "x-rc-comments": {} + } + } + } + }, + "tags": ["Invocation ", "service"], + "parameters": [ + { + "deprecated": false, + "$ref": "#/components/parameters/appId" + }, + { + "deprecated": false, + "$ref": "#/components/parameters/method-name" + }, + { + "deprecated": false, + "$ref": "#/components/parameters/Content-Type" + }, + { + "$ref": "#/components/securitySchemes/ApiKeyAuth", + "name": "ApiKeyAuth", + "x-last-modified": 1597270398630 + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/200" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "operationId": "invoke_post", + "summary": "This endpoint lets you invoke a method in another Dapr enabled app.", + "externalDocs": { + "url": "https://docs.dapr.io/reference/api/service_invocation_api/" + } + }, + "delete": { + "tags": ["Invocation ", "service"], + "parameters": [ + { + "deprecated": false, + "$ref": "#/components/parameters/appId" + }, + { + "deprecated": false, + "$ref": "#/components/parameters/method-name" + }, + { + "deprecated": false, + "$ref": "#/components/parameters/Content-Type" + }, + { + "$ref": "#/components/securitySchemes/ApiKeyAuth", + "name": "ApiKeyAuth", + "x-last-modified": 1597270419336 + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/200" + }, + "500": { + "$ref": "#/components/responses/500" + } + }, + "operationId": "invoke_delete", + "summary": "This endpoint lets you invoke a method in another Dapr enabled app." + }, + "x-last-modified": 1597254788230 + } + }, + "components": { + "responses": { + "200": { + "content": { + "text/plain": { + "schema": { + "type": "number", + "example": "", + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "example": 200, + "x-rc-meta": { + "x-rc-comments": {} + } + } + }, + "description": "Operation succeeded", + "x-last-modified": 1597011885893 + }, + "500": { + "content": { + "text/plain": { + "schema": { + "format": "", + "pattern": "", + "type": "number", + "example": 500, + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "example": 500, + "x-rc-meta": { + "x-rc-comments": {} + } + } + }, + "description": "Server Error", + "x-last-modified": 1597011858483 + } + }, + "parameters": { + "method-name": { + "example": "neworder", + "name": "method-name", + "description": "name of the method to be envoked", + "schema": { + "format": "", + "description": "name of the method to be envoked", + "pattern": "", + "type": "string", + "example": "neworder", + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "in": "path", + "required": true, + "x-last-modified": 1597011358645, + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "appId": { + "example": "nodeapp", + "name": "appId", + "description": "the App ID associated with the remote app", + "schema": { + "format": "", + "description": "the App ID associated with the remote app", + "pattern": "", + "type": "string", + "example": "nodeapp", + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "in": "path", + "required": true, + "x-last-modified": 1597253939494, + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "Content-Type": { + "deprecated": false, + "example": "application/json", + "name": "Content-Type", + "description": "the App ID associated with the remote app", + "schema": { + "format": "", + "description": "the App ID associated with the remote app", + "pattern": "", + "type": "string", + "example": "application/json", + "x-rc-meta": { + "x-rc-comments": {} + } + }, + "in": "header", + "required": false, + "x-last-modified": 1597269332645, + "x-rc-meta": { + "x-rc-comments": {} + } + } + }, + "securitySchemes": { + "ApiKeyAuth": { + "type": "apiKey", + "name": "dapr-api-token", + "in": "header", + "x-last-modified": 1597014915425 + } + }, + "schemas": {} + }, + "tags": [ + { + "name": "service", + "description": "Dapr provides users with the ability to call other applications that have unique ids. This functionality allows apps to interact with one another via named identifiers and puts the burden of service discovery on the Dapr runtime.", + "externalDocs": { + "description": "Dapr provides users with the ability to call other applications that have unique ids. This functionality allows apps to interact with one another via named identifiers and puts the burden of service discovery on the Dapr runtime.", + "url": "https://docs.dapr.io/reference/api/service_invocation_api/" + }, + "x-last-modified": 1594246229173 + }, + { + "name": "Invocation ", + "description": "Dapr provides users with the ability to call other applications that have unique ids. This functionality allows apps to interact with one another via named identifiers and puts the burden of service discovery on the Dapr runtime.\n\n", + "externalDocs": { + "url": "https://docs.dapr.io/reference/api/service_invocation_api/" + }, + "x-last-modified": 1594246379461 + } + ], + "externalDocs": { + "description": "Dapr provides users with the ability to call other applications that have unique ids. This functionality allows apps to interact with one another via named identifiers and puts the burden of service discovery on the Dapr runtime.", + "url": "https://docs.dapr.io/reference/api/service_invocation_api/" + }, + "security": [] +} diff --git a/tests/e2e/stateapp/query-data/dataset.json b/tests/e2e/stateapp/query-data/dataset.json index 69935f9bdae..a3fbf9a0c29 100644 --- a/tests/e2e/stateapp/query-data/dataset.json +++ b/tests/e2e/stateapp/query-data/dataset.json @@ -1,112 +1,112 @@ [ - { - "key": "1", - "value": { - "person": { - "org": "Dev Ops", - "id": 1036 - }, - "city": "Seattle", - "state": "WA" + { + "key": "1", + "value": { + "person": { + "org": "Dev Ops", + "id": 1036 + }, + "city": "Seattle", + "state": "WA" + } + }, + { + "key": "2", + "value": { + "person": { + "org": "Hardware", + "id": 1028 + }, + "city": "Portland", + "state": "OR" + } + }, + { + "key": "3", + "value": { + "person": { + "org": "Finance", + "id": 1071 + }, + "city": "Sacramento", + "state": "CA" + } + }, + { + "key": "4", + "value": { + "person": { + "org": "Dev Ops", + "id": 1042 + }, + "city": "Spokane", + "state": "WA" + } + }, + { + "key": "5", + "value": { + "person": { + "org": "Hardware", + "id": 1007 + }, + "city": "Los Angeles", + "state": "CA" + } + }, + { + "key": "6", + "value": { + "person": { + "org": "Finance", + "id": 1094 + }, + "city": "Eugene", + "state": "OR" + } + }, + { + "key": "7", + "value": { + "person": { + "org": "Dev Ops", + "id": 1015 + }, + "city": "San Francisco", + "state": "CA" + } + }, + { + "key": "8", + "value": { + "person": { + "org": "Hardware", + "id": 1077 + }, + "city": "Redmond", + "state": "WA" + } + }, + { + "key": "9", + "value": { + "person": { + "org": "Finance", + "id": 1002 + }, + "city": "San Diego", + "state": "CA" + } + }, + { + "key": "10", + "value": { + "person": { + "org": "Dev Ops", + "id": 1054 + }, + "city": "New York", + "state": "NY" + } } - }, - { - "key": "2", - "value": { - "person": { - "org": "Hardware", - "id": 1028 - }, - "city": "Portland", - "state": "OR" - } - }, - { - "key": "3", - "value": { - "person": { - "org": "Finance", - "id": 1071 - }, - "city": "Sacramento", - "state": "CA" - } - }, - { - "key": "4", - "value": { - "person": { - "org": "Dev Ops", - "id": 1042 - }, - "city": "Spokane", - "state": "WA" - } - }, - { - "key": "5", - "value": { - "person": { - "org": "Hardware", - "id": 1007 - }, - "city": "Los Angeles", - "state": "CA" - } - }, - { - "key": "6", - "value": { - "person": { - "org": "Finance", - "id": 1094 - }, - "city": "Eugene", - "state": "OR" - } - }, - { - "key": "7", - "value": { - "person": { - "org": "Dev Ops", - "id": 1015 - }, - "city": "San Francisco", - "state": "CA" - } - }, - { - "key": "8", - "value": { - "person": { - "org": "Hardware", - "id": 1077 - }, - "city": "Redmond", - "state": "WA" - } - }, - { - "key": "9", - "value": { - "person": { - "org": "Finance", - "id": 1002 - }, - "city": "San Diego", - "state": "CA" - } - }, - { - "key": "10", - "value": { - "person": { - "org": "Dev Ops", - "id": 1054 - }, - "city": "New York", - "state": "NY" - } - } ] diff --git a/tests/e2e/stateapp/query-data/query.json b/tests/e2e/stateapp/query-data/query.json index c763d5a1bb5..b92a2d9f716 100644 --- a/tests/e2e/stateapp/query-data/query.json +++ b/tests/e2e/stateapp/query-data/query.json @@ -10,7 +10,7 @@ "EQ": { "person.org": "Finance" } }, { - "IN": { "state": [ "CA", "WA" ] } + "IN": { "state": ["CA", "WA"] } } ] } diff --git a/tests/perf/actor_double_activation/test.js b/tests/perf/actor_double_activation/test.js index 445b03f1567..10926c784e5 100644 --- a/tests/perf/actor_double_activation/test.js +++ b/tests/perf/actor_double_activation/test.js @@ -11,100 +11,100 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { PodDisruptor } from "k6/x/disruptor"; -import http from "k6/http"; -import { check } from "k6"; -import { Counter } from "k6/metrics"; +import { PodDisruptor } from 'k6/x/disruptor' +import http from 'k6/http' +import { check } from 'k6' +import { Counter } from 'k6/metrics' -const DoubleActivations = new Counter('double_activations'); +const DoubleActivations = new Counter('double_activations') -const singleId = "SINGLE_ID" +const singleId = 'SINGLE_ID' export const options = { - discardResponseBodies: true, - thresholds: { - "double_activations{scenario:base}": ["count==0"], - "double_activations{scenario:faults}": ["count==0"], - }, - scenarios: { - base: { - executor: "ramping-vus", - startVUs: 0, - stages: [ - { duration: "5s", target: 1000 }, - { duration: "5s", target: 3000 }, - { duration: "5s", target: 5000 }, - ], - gracefulRampDown: "0s", + discardResponseBodies: true, + thresholds: { + 'double_activations{scenario:base}': ['count==0'], + 'double_activations{scenario:faults}': ['count==0'], }, - disrupt: { - executor: 'shared-iterations', - iterations: 1, - vus: 1, - exec: "disrupt", - startTime: "15s", + scenarios: { + base: { + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '5s', target: 1000 }, + { duration: '5s', target: 3000 }, + { duration: '5s', target: 5000 }, + ], + gracefulRampDown: '0s', + }, + disrupt: { + executor: 'shared-iterations', + iterations: 1, + vus: 1, + exec: 'disrupt', + startTime: '15s', + }, + faults: { + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '5s', target: 1000 }, + { duration: '5s', target: 3000 }, + { duration: '5s', target: 5000 }, + ], + gracefulRampDown: '0s', + startTime: '15s', + }, }, - faults: { - executor: "ramping-vus", - startVUs: 0, - stages: [ - { duration: "5s", target: 1000 }, - { duration: "5s", target: 3000 }, - { duration: "5s", target: 5000 }, - ], - gracefulRampDown: "0s", - startTime: "15s", - } - }, -}; +} -const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}/v1.0`; +const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}/v1.0` function callActorMethod(id, method) { - return http.post( - `${DAPR_ADDRESS}/actors/fake-actor-type/${id}/method/${method}`, - JSON.stringify({}) - ); + return http.post( + `${DAPR_ADDRESS}/actors/fake-actor-type/${id}/method/${method}`, + JSON.stringify({}) + ) } export default function () { - const result = callActorMethod(singleId, "Lock"); - if (result.status >= 400) { - DoubleActivations.add(1); - } + const result = callActorMethod(singleId, 'Lock') + if (result.status >= 400) { + DoubleActivations.add(1) + } } export function teardown(_) { - const shutdownResult = http.post(`${DAPR_ADDRESS}/shutdown`); - check(shutdownResult, { - "shutdown response status code is 2xx": - shutdownResult.status >= 200 && shutdownResult.status < 300, - }); + const shutdownResult = http.post(`${DAPR_ADDRESS}/shutdown`) + check(shutdownResult, { + 'shutdown response status code is 2xx': + shutdownResult.status >= 200 && shutdownResult.status < 300, + }) } export function handleSummary(data) { - return { - 'stdout': JSON.stringify(data), - }; + return { + stdout: JSON.stringify(data), + } } // add disruption const selector = { - namespace: __ENV.TEST_NAMESPACE, - select: { - labels: { - testapp: __ENV.TEST_APP_NAME - } - } + namespace: __ENV.TEST_NAMESPACE, + select: { + labels: { + testapp: __ENV.TEST_APP_NAME, + }, + }, } export function disrupt() { - const podDisruptor = new PodDisruptor(selector) + const podDisruptor = new PodDisruptor(selector) - // delay traffic from one random replica of the deployment - const fault = { - averageDelay: 50, - errorCode: 500, - errorRate: 0.1 - } - podDisruptor.injectHTTPFaults(fault, 15) -} \ No newline at end of file + // delay traffic from one random replica of the deployment + const fault = { + averageDelay: 50, + errorCode: 500, + errorRate: 0.1, + } + podDisruptor.injectHTTPFaults(fault, 15) +} diff --git a/tests/perf/actor_id_scale/test.js b/tests/perf/actor_id_scale/test.js index 351fc00a3ab..795b1569d77 100644 --- a/tests/perf/actor_id_scale/test.js +++ b/tests/perf/actor_id_scale/test.js @@ -11,58 +11,59 @@ See the License for the specific language governing permissions and limitations under the License. */ -import http from "k6/http"; -import { check } from "k6"; -import exec from "k6/execution"; +import http from 'k6/http' +import { check } from 'k6' +import exec from 'k6/execution' -const defaultMethod = "default" +const defaultMethod = 'default' const actorType = __ENV.ACTOR_TYPE export const options = { - discardResponseBodies: true, - thresholds: { - checks: ['rate==1'], - http_req_duration: ['p(95)<90'], // 95% of requests should be below 70ms - }, - scenarios: { - idStress: { - executor: "ramping-vus", - startVUs: 0, - stages: [ - { duration: "2s", target: 100 }, - { duration: "2s", target: 300 }, - { duration: "4s", target: 500 }, - ], - gracefulRampDown: "0s", + discardResponseBodies: true, + thresholds: { + checks: ['rate==1'], + http_req_duration: ['p(95)<90'], // 95% of requests should be below 70ms }, - }, -}; + scenarios: { + idStress: { + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '2s', target: 100 }, + { duration: '2s', target: 300 }, + { duration: '4s', target: 500 }, + ], + gracefulRampDown: '0s', + }, + }, +} -const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}/v1.0`; +const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}/v1.0` function callActorMethod(id, method) { - return http.put( - `${DAPR_ADDRESS}/actors/${actorType}/${id}/method/${method}`, - JSON.stringify({}) - ); + return http.put( + `${DAPR_ADDRESS}/actors/${actorType}/${id}/method/${method}`, + JSON.stringify({}) + ) } export default function () { - const result = callActorMethod(exec.scenario.iterationInTest, defaultMethod); - check(result, { - "response code was 2xx": (result) => result.status >= 200 && result.status < 300, - }) + const result = callActorMethod(exec.scenario.iterationInTest, defaultMethod) + check(result, { + 'response code was 2xx': (result) => + result.status >= 200 && result.status < 300, + }) } export function teardown(_) { - const shutdownResult = http.post(`${DAPR_ADDRESS}/shutdown`); - check(shutdownResult, { - "shutdown response status code is 2xx": - shutdownResult.status >= 200 && shutdownResult.status < 300, - }); + const shutdownResult = http.post(`${DAPR_ADDRESS}/shutdown`) + check(shutdownResult, { + 'shutdown response status code is 2xx': + shutdownResult.status >= 200 && shutdownResult.status < 300, + }) } export function handleSummary(data) { - return { - 'stdout': JSON.stringify(data), - }; + return { + stdout: JSON.stringify(data), + } } diff --git a/tests/perf/actor_type_scale/test.js b/tests/perf/actor_type_scale/test.js index 4cf109b6697..9cb0a2f3eeb 100644 --- a/tests/perf/actor_type_scale/test.js +++ b/tests/perf/actor_type_scale/test.js @@ -11,63 +11,68 @@ See the License for the specific language governing permissions and limitations under the License. */ -import http from "k6/http"; -import { check } from "k6"; -import exec from "k6/execution"; -import { SharedArray } from 'k6/data'; +import http from 'k6/http' +import { check } from 'k6' +import exec from 'k6/execution' +import { SharedArray } from 'k6/data' -const defaultMethod = "default" +const defaultMethod = 'default' const actorsTypes = __ENV.ACTORS_TYPES const actors = new SharedArray('actors types', function () { - return actorsTypes.split(",") -}); + return actorsTypes.split(',') +}) export const options = { - discardResponseBodies: true, - thresholds: { - checks: ['rate==1'], - http_req_duration: ['p(95)<90'], // 95% of requests should be below 90ms - }, - scenarios: { - idStress: { - executor: "ramping-vus", - startVUs: 0, - stages: [ - { duration: "2s", target: 100 }, - { duration: "2s", target: 300 }, - { duration: "4s", target: 500 }, - ], - gracefulRampDown: "0s", + discardResponseBodies: true, + thresholds: { + checks: ['rate==1'], + http_req_duration: ['p(95)<90'], // 95% of requests should be below 90ms }, - }, -}; + scenarios: { + idStress: { + executor: 'ramping-vus', + startVUs: 0, + stages: [ + { duration: '2s', target: 100 }, + { duration: '2s', target: 300 }, + { duration: '4s', target: 500 }, + ], + gracefulRampDown: '0s', + }, + }, +} -const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}/v1.0`; +const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}/v1.0` function callActorMethod(actor, id, method) { - return http.put( - `${DAPR_ADDRESS}/actors/${actor}/${id}/method/${method}`, - JSON.stringify({}) - ); + return http.put( + `${DAPR_ADDRESS}/actors/${actor}/${id}/method/${method}`, + JSON.stringify({}) + ) } export default function () { - const result = callActorMethod(actors[exec.scenario.iterationInTest % actors.length], exec.scenario.iterationInTest, defaultMethod); - check(result, { - "response code was 2xx": (result) => result.status >= 200 && result.status < 300, - }) + const result = callActorMethod( + actors[exec.scenario.iterationInTest % actors.length], + exec.scenario.iterationInTest, + defaultMethod + ) + check(result, { + 'response code was 2xx': (result) => + result.status >= 200 && result.status < 300, + }) } export function teardown(_) { - const shutdownResult = http.post(`${DAPR_ADDRESS}/shutdown`); - check(shutdownResult, { - "shutdown response status code is 2xx": - shutdownResult.status >= 200 && shutdownResult.status < 300, - }); + const shutdownResult = http.post(`${DAPR_ADDRESS}/shutdown`) + check(shutdownResult, { + 'shutdown response status code is 2xx': + shutdownResult.status >= 200 && shutdownResult.status < 300, + }) } export function handleSummary(data) { - return { - 'stdout': JSON.stringify(data), - }; + return { + stdout: JSON.stringify(data), + } } diff --git a/tests/perf/pubsub_bulk_subscribe_http/test.js b/tests/perf/pubsub_bulk_subscribe_http/test.js index c886b6ad0ac..3b31b088d8f 100644 --- a/tests/perf/pubsub_bulk_subscribe_http/test.js +++ b/tests/perf/pubsub_bulk_subscribe_http/test.js @@ -11,24 +11,24 @@ See the License for the specific language governing permissions and limitations under the License. */ -import http from "k6/http"; -import { check } from "k6"; -import exec from "k6/execution"; -import ws from "k6/ws"; -import { Counter } from 'k6/metrics'; +import http from 'k6/http' +import { check } from 'k6' +import exec from 'k6/execution' +import ws from 'k6/ws' +import { Counter } from 'k6/metrics' const targetUrl = __ENV.TARGET_URL const pubsubName = __ENV.PUBSUB_NAME const subscribeType = __ENV.SUBSCRIBE_TYPE -const publishType = __ENV.PUBLISH_TYPE || "bulk" +const publishType = __ENV.PUBLISH_TYPE || 'bulk' const httpReqDurationThreshold = __ENV.HTTP_REQ_DURATION_THRESHOLD -const defaultTopic = "perf-test" +const defaultTopic = 'perf-test' const defaultCount = 100 -const hundredBytesMessage = "a".repeat(100) +const hundredBytesMessage = 'a'.repeat(100) const testTimeoutMs = 60 * 1000 -const errCounter = new Counter("error_counter"); +const errCounter = new Counter('error_counter') export const options = { discardResponseBodies: true, @@ -41,19 +41,19 @@ export const options = { }, scenarios: { bulkPSubscribe: { - executor: "ramping-vus", + executor: 'ramping-vus', startVUs: 0, stages: [ - { duration: "2s", target: 100 }, - { duration: "3s", target: 300 }, - { duration: "4s", target: 500 }, + { duration: '2s', target: 100 }, + { duration: '3s', target: 300 }, + { duration: '4s', target: 500 }, ], - gracefulRampDown: "0s", + gracefulRampDown: '0s', }, }, -}; +} -const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}`; +const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}` /** * Publishes messages to a topic using the bulk publish API. @@ -61,102 +61,116 @@ const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}`; * @param {String} topic topic name * @param {String} message message to publish * @param {Number} count number of messages to publish - * @returns + * @returns */ function publishMessages(pubsub, topic, message, count) { - const bulkPublishBody = []; + const bulkPublishBody = [] for (let i = 0; i < count; i++) { bulkPublishBody.push({ - entryId: exec.vu.idInTest + "-" + i, // unique id for the message + entryId: exec.vu.idInTest + '-' + i, // unique id for the message event: message, - contentType: "text/plain", - }); + contentType: 'text/plain', + }) } return http.post( `${DAPR_ADDRESS}/v1.0-alpha1/publish/bulk/${pubsub}/${topic}`, JSON.stringify(bulkPublishBody), - { headers: { 'Content-Type': 'application/json' }, }); + { headers: { 'Content-Type': 'application/json' } } + ) } /** * Publish a message to a topic using the publish API. - * @param {String} pubsub - * @param {String} topic - * @param {String} message - * @returns + * @param {String} pubsub + * @param {String} topic + * @param {String} message + * @returns */ function publishMessage(pubsub, topic, message) { return http.post( `${DAPR_ADDRESS}/v1.0/publish/${pubsub}/${topic}`, message, - { headers: { 'Content-Type': 'text/plain' }, }); + { headers: { 'Content-Type': 'text/plain' } } + ) } export default function () { const url = `ws://${targetUrl}/test` - const params = { tags: { "subscribeType": subscribeType } } + const params = { tags: { subscribeType: subscribeType } } let topic = defaultTopic - if (subscribeType === "bulk") { + if (subscribeType === 'bulk') { topic = `${defaultTopic}-bulk` } const res = ws.connect(url, params, (socket) => { - socket.on("open", () => { + socket.on('open', () => { // Publish messages to the topic - if (publishType === "bulk") { - let publishResponse = publishMessages(pubsubName, topic, hundredBytesMessage, defaultCount); + if (publishType === 'bulk') { + let publishResponse = publishMessages( + pubsubName, + topic, + hundredBytesMessage, + defaultCount + ) check(publishResponse, { - "bulk publish response status code is 2xx": (r) => r.status >= 200 && r.status < 300 - }); + 'bulk publish response status code is 2xx': (r) => + r.status >= 200 && r.status < 300, + }) } else { for (let i = 0; i < defaultCount; i++) { - const publishResponse = publishMessage(pubsubName, topic, hundredBytesMessage); + const publishResponse = publishMessage( + pubsubName, + topic, + hundredBytesMessage + ) check(publishResponse, { - "publish response status code is 2xx": (r) => r.status >= 200 && r.status < 300 - }); + 'publish response status code is 2xx': (r) => + r.status >= 200 && r.status < 300, + }) } } - }); + }) - socket.on("message", (data) => { - console.log("Received data: " + data); + socket.on('message', (data) => { + console.log('Received data: ' + data) check(data, { - "completed with success": (d) => d === "true", - }); - }); + 'completed with success': (d) => d === 'true', + }) + }) - socket.on("close", () => { - console.log("closed"); - }); + socket.on('close', () => { + console.log('closed') + }) - socket.on("error", (err) => { + socket.on('error', (err) => { if (err.error() != 'websocket: close sent') { - console.log("Error: " + err.error()); - errCounter.add(1); + console.log('Error: ' + err.error()) + errCounter.add(1) } - }); + }) socket.setTimeout(() => { - console.log("timeout reached, closing socket and failing test"); - errCounter.add(1, { "errType": "timeout" }) - socket.close(); - }, testTimeoutMs); - }); + console.log('timeout reached, closing socket and failing test') + errCounter.add(1, { errType: 'timeout' }) + socket.close() + }, testTimeoutMs) + }) - check(res, { "status is 101": (r) => r && r.status === 101 }); + check(res, { 'status is 101': (r) => r && r.status === 101 }) } export function teardown(_) { - const shutdownResult = http.post(`${DAPR_ADDRESS}/v1.0/shutdown`); + const shutdownResult = http.post(`${DAPR_ADDRESS}/v1.0/shutdown`) check(shutdownResult, { - "shutdown response status code is 2xx": (r) => r.status >= 200 && r.status < 300, - }); + 'shutdown response status code is 2xx': (r) => + r.status >= 200 && r.status < 300, + }) } export function handleSummary(data) { return { - 'stdout': JSON.stringify(data), - }; + stdout: JSON.stringify(data), + } } diff --git a/tests/perf/pubsub_publish_http/test.js b/tests/perf/pubsub_publish_http/test.js index 2c1fb88f5cc..306bb64f7f8 100644 --- a/tests/perf/pubsub_publish_http/test.js +++ b/tests/perf/pubsub_publish_http/test.js @@ -11,34 +11,36 @@ See the License for the specific language governing permissions and limitations under the License. */ -import http from "k6/http"; -import { check } from "k6"; -import crypto from "k6/crypto"; -import { SharedArray } from 'k6/data'; +import http from 'k6/http' +import { check } from 'k6' +import crypto from 'k6/crypto' +import { SharedArray } from 'k6/data' const KB = 1024 const MAX_MS_ALLOWED = 1 // padd with leading 0 if <16 function i2hex(i) { - return ('0' + i.toString(16)).slice(-2); + return ('0' + i.toString(16)).slice(-2) } function randomStringOfSize(size) { - const bytes = crypto.randomBytes(Math.round(size / 2)); // because of hex transformation - const view = new Uint8Array(bytes); - return view.reduce(function (memo, i) { return memo + i2hex(i) }, '') + const bytes = crypto.randomBytes(Math.round(size / 2)) // because of hex transformation + const view = new Uint8Array(bytes) + return view.reduce(function (memo, i) { + return memo + i2hex(i) + }, '') } const data = new SharedArray('scenarios', function () { const scenarioBase = { - executor: "constant-arrival-rate", + executor: 'constant-arrival-rate', rate: 1, preAllocatedVUs: 2, maxVUs: 50, } const delaysMs = [5, 50, 100, 1000] const messageSizeKb = [2, 31] - const brokers = __ENV.BROKERS.split(",") + const brokers = __ENV.BROKERS.split(',') const samples = [200] let scenarios = {} @@ -57,7 +59,9 @@ const data = new SharedArray('scenarios', function () { for (const sampleIdx in samples) { const sample = samples[sampleIdx] const scenario = `${delay}ms_${msgSize}kb_${broker}_${sample}` - thresholds[`http_req_duration{scenario:${scenario}}`] = [`avg<${MAX_MS_ALLOWED}`] + thresholds[`http_req_duration{scenario:${scenario}}`] = [ + `avg<${MAX_MS_ALLOWED}`, + ] const duration = delay * sample scenarios[scenario] = Object.assign( { @@ -66,11 +70,11 @@ const data = new SharedArray('scenarios', function () { env: { MSG: msgStr, BROKER: broker, - TOPIC: "my-topic" + TOPIC: 'my-topic', }, - startTime: `${startTime}ms` + startTime: `${startTime}ms`, }, - scenarioBase, + scenarioBase ) startTime += duration } @@ -78,41 +82,42 @@ const data = new SharedArray('scenarios', function () { } } // more operations - return [{ scenarios, thresholds }]; // must be an array -}); + return [{ scenarios, thresholds }] // must be an array +}) const { scenarios, thresholds } = data[0] export const options = { discardResponseBodies: true, thresholds, scenarios, -}; +} -const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}/v1.0`; +const DAPR_ADDRESS = `http://127.0.0.1:${__ENV.DAPR_HTTP_PORT}/v1.0` function publishRawMsg(broker, topic, msg) { return http.post( `${DAPR_ADDRESS}/publish/${broker}/${topic}?metadata.rawPayload=true`, - msg, - ); + msg + ) } export default function () { - const result = publishRawMsg(__ENV.BROKER, __ENV.TOPIC, __ENV.MSG); + const result = publishRawMsg(__ENV.BROKER, __ENV.TOPIC, __ENV.MSG) check(result, { - "response code was 2xx": (result) => result.status >= 200 && result.status < 300, + 'response code was 2xx': (result) => + result.status >= 200 && result.status < 300, }) } export function teardown(_) { - const shutdownResult = http.post(`${DAPR_ADDRESS}/shutdown`); + const shutdownResult = http.post(`${DAPR_ADDRESS}/shutdown`) check(shutdownResult, { - "shutdown response status code is 2xx": + 'shutdown response status code is 2xx': shutdownResult.status >= 200 && shutdownResult.status < 300, - }); + }) } export function handleSummary(data) { return { - 'stdout': JSON.stringify(data), - }; + stdout: JSON.stringify(data), + } }