{"id":18794126,"url":"https://github.com/yandex-cloud-examples/yc-load-testing-start-test","last_synced_at":"2025-07-25T22:02:35.401Z","repository":{"id":227430759,"uuid":"769047575","full_name":"yandex-cloud-examples/yc-load-testing-start-test","owner":"yandex-cloud-examples","description":"Запуск теста в сервисе Yandex Load Testing с помощью инструмента YC CLI.","archived":false,"fork":false,"pushed_at":"2024-05-14T10:10:42.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-12-29T15:47:02.846Z","etag":null,"topics":["bash","load-testing","pandora","yandex-cloud","yandexcloud","yc-cli"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yandex-cloud-examples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-08T08:32:00.000Z","updated_at":"2024-05-14T10:10:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9dae755-044a-449c-bd47-8ac479d7fb61","html_url":"https://github.com/yandex-cloud-examples/yc-load-testing-start-test","commit_stats":null,"previous_names":["yandex-cloud-examples/yc-load-testing-start-test"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yandex-cloud-examples%2Fyc-load-testing-start-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yandex-cloud-examples%2Fyc-load-testing-start-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yandex-cloud-examples%2Fyc-load-testing-start-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yandex-cloud-examples%2Fyc-load-testing-start-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yandex-cloud-examples","download_url":"https://codeload.github.com/yandex-cloud-examples/yc-load-testing-start-test/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718378,"owners_count":19685725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","load-testing","pandora","yandex-cloud","yandexcloud","yc-cli"],"created_at":"2024-11-07T21:28:16.061Z","updated_at":"2025-02-19T19:20:22.664Z","avatar_url":"https://github.com/yandex-cloud-examples.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Start a test in Yandex Cloud Load Testing service using YC CLI.\n\nIn this example, it is shown how to start a test in Load Testing service using YC CLI tool.\n\nNOTE: in snippets bellow, it is assumed that folder-id setting is already set in `yc`:\n\n```bash\nyc config set folder-id 'my_folder_id'\n```\n\n### 1. Prepare testing agent\n\nHere we assume that you already have a set of suitable LT agents.\n\n```bash\nexport AGENT_ID='agent id'\n```\n\nOn how to create an agent, see following guides:\n- [How to create an agent in YC Compute](https://cloud.yandex.ru/en/docs/load-testing/operations/create-agent).\n- [How to create an external agent](https://cloud.yandex.ru/en/docs/load-testing/tutorials/loadtesting-external-agent).\n\n### 2. Prepare test yaml config\n\nUpload your test configuration defined in YAML file.\n\n```bash\nexport TEST_CONFIG_FILE=\"sample/_config_requests_in_file.yaml\"\n\nexport TEST_CONFIG_ID=$(yc loadtesting test-config create --from-yaml-file $TEST_CONFIG_FILE --format json | jq -r \".id\")\n```\n\nFor information about config files, see [related documentation](https://yandextank.readthedocs.io/en/latest/config_reference.html#).\n\n### 3. Prepare test payload\n\nUpload test data payload.\n\n```bash\nexport TEST_PAYLOAD_FILE_IN_CONFIG=\"requests.uri\"\nexport TEST_PAYLOAD_FILE=\"sample/_requests.uri\"\nexport S3_PAYLOAD_BUCKET=\"my_bucket\"\nexport S3_PAYLOAD_FILENAME=\"my_requests.uri\"\n\nexport YC_TOKEN=$(yc iam create-token)\ncurl -H \"X-YaCloud-SubjectToken: $YC_TOKEN\" --upload-file - \"https://storage.yandexcloud.net/$S3_PAYLOAD_BUCKET/$S3_PAYLOAD_FILENAME\" \u003c $TEST_PAYLOAD_FILE\n```\n\nFor information about data payload files, see [related documentation](https://cloud.yandex.ru/en/docs/load-testing/concepts/payload).\n\n### 4. Start test\n\nGiven that all previous steps are done, start test with following command:\n\n```bash\n\nyc loadtesting test create \\\n    --name \"yc-examples-test\" \\\n    --description \"Test has been created using YC\" \\\n    --labels source=gh,type=tutorial \\\n    --configuration id=$TEST_CONFIG_ID,agent-id=$AGENT_ID,test-data=$TEST_PAYLOAD_FILE_IN_CONFIG \\\n    --test-data name=$TEST_PAYLOAD_FILE_IN_CONFIG,s3bucket=$S3_PAYLOAD_BUCKET,s3file=$S3_PAYLOAD_FILENAME\n\n```\n\n### 4.1 Start a multitest\n\nYou can also start a multitest using YC. A multitest is a test that utilizes multiple agents simulteneously,\nthus surpassing a limit for a single load generation agent (either a bandwidth, cpu, or other resources).\n\n```bash\nexport AGENT_ID1='first agent id'\nexport AGENT_ID2='second agent id'\n\nyc loadtesting test create \\\n    --name \"yc-examples-test\" \\\n    --description \"Test has been created using YC\" \\\n    --labels source=gh,type=tutorial,kind=multi \\\n    --configuration id=$TEST_CONFIG_ID,agent-id=$AGENT_ID1,test-data=$TEST_PAYLOAD_FILE_IN_CONFIG \\\n    --configuration id=$TEST_CONFIG_ID,agent-id=$AGENT_ID2,test-data=$TEST_PAYLOAD_FILE_IN_CONFIG \\\n    --test-data name=$TEST_PAYLOAD_FILE_IN_CONFIG,s3bucket=$S3_PAYLOAD_BUCKET,s3file=$S3_PAYLOAD_FILENAME\n```\n\n### 4.2 Start test using first available agent\n\nSometimes, you may want to run a test on the first available agent or on a subset of agents. \nYou can specify the agent selection option with the `agent-by-filter` option.\nIn the following example, we create a multitest. The first part will run on the first available agent, and the second part will run on any agent with the label `key=value1` or `key=value2`\n\n```bash\nexport ANY_AGENT_SELECTOR=\"\"\nexport SPECIFIC_AGENT_SELECTOR=\"labels.key IN (value1, value2)\"\n\nyc loadtesting test create \\\n    --name \"yc-examples-test\" \\\n    --description \"Test has been created using YC\" \\\n    --labels source=gh,type=tutorial \\\n    --configuration id=$TEST_CONFIG_ID,agent-by-filter=$ANY_AGENT_SELECTOR,test-data=$TEST_PAYLOAD_FILE_IN_CONFIG \\\n    --configuration id=$TEST_CONFIG_ID,agent-by-filter={$SPECIFIC_AGENT_SELECTOR},test-data=$TEST_PAYLOAD_FILE_IN_CONFIG \\\n    --test-data name=$TEST_PAYLOAD_FILE_IN_CONFIG,s3bucket=$S3_PAYLOAD_BUCKET,s3file=$S3_PAYLOAD_FILENAME\n```\n\n### 4.3 Waiting for completion\n\nYou can wait for the test to finish using the command `wait`\n\n```bash\nexport TEST_ID='test id to wait to finish'\n\nyc loadtesting test wait $TEST_ID\n``` \n\nOr using flag `--wait` with `test create` command.\n\n```bash\n\nyc loadtesting test create \\\n    --wait \\\n    --name \"yc-examples-test\" \\\n    --description \"Test has been created using YC\" \\\n    --labels source=gh,type=tutorial \\\n    --configuration id=$TEST_CONFIG_ID,agent-id=$AGENT_ID,test-data=$TEST_PAYLOAD_FILE_IN_CONFIG \\\n    --test-data name=$TEST_PAYLOAD_FILE_IN_CONFIG,s3bucket=$S3_PAYLOAD_BUCKET,s3file=$S3_PAYLOAD_FILENAME\n\n```\n\n### (Optional) 5. Stop tests\n\nThe code here will stop all running tests\n\n```bash\nexport TESTS_TO_STOP=$(yc loadtesting test list --filter \"summary.status not in (CREATED, DONE, STOPPED, AUTOSTOPPED, FAILED)\" --format json | jq -r \"[.[].id] | join(\\\" \\\")\")\necho $TESTS_TO_STOP | xargs yc loadtesting test stop\n```\n\n### (Optional) 6. Delete tests\n\nThe code here will delete all tests created today which have `Failed` or `Created` statuses.\n\n```bash\nexport TODAY=$(date +'%Y-%m-%d')\nexport TESTS_TO_DELETE=$(yc loadtesting test list --filter \"summary.status in (FAILED, CREATED) and summary.created_at \u003e= $TODAY\" --format json | jq -r \"[.[].id] | join(\\\" \\\")\")\necho $TESTS_TO_DELETE | xargs yc loadtesting test delete\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyandex-cloud-examples%2Fyc-load-testing-start-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyandex-cloud-examples%2Fyc-load-testing-start-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyandex-cloud-examples%2Fyc-load-testing-start-test/lists"}