Create
Creates (runs) a test in the specified folder.
- TypeScript
- Python
import {
cloudApi,
decodeMessage,
serviceClients,
Session,
waitForOperation,
} from "@yandex-cloud/nodejs-sdk";
const CreateTestRequest =
cloudApi.loadtesting.api_test_service.CreateTestRequest;
const Test = cloudApi.loadtesting.api_test_test.Test;
(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.TestServiceClient);
const operation = await client.create(
CreateTestRequest.fromPartial({
folderId: "folderId",
// configurations: [{
// configId: "configId",
// agentSelector: {
// agentId: "agentId",
// matchByFilter: "matchByFilter",
// anonymousAgent: true
// },
// files: {undefined: {
// objectStorage: {
// bucket: "bucket",
// name: "name"
// }
// }}
// }],
// testDetails: {
// name: "name",
// description: "description",
// tags: [{
// key: "key",
// value: "value"
// }],
// loggingLogGroupId: "loggingLogGroupId",
// artifactSettings: {
// objectStorageBucket: "objectStorageBucket",
// isArchive: true,
// filterInclude: ["filterInclude"],
// filterExclude: ["filterExclude"]
// }
// }
})
);
const finishedOp = await waitForOperation(operation, session);
if (finishedOp.response) {
const result = decodeMessage<typeof test.Test>(finishedOp.response);
console.log(result);
}
})();
import os
import grpc
import yandexcloud
from yandex.cloud.loadtesting.api.v1.test.agent_selector_pb2 import AgentSelector
from yandex.cloud.loadtesting.api.v1.test.artifact_settings_pb2 import ArtifactSettings
from yandex.cloud.loadtesting.api.v1.test_service_pb2 import CreateTestMetadata
from yandex.cloud.loadtesting.api.v1.test_service_pb2 import CreateTestRequest
from yandex.cloud.loadtesting.api.v1.test.details_pb2 import Details
from yandex.cloud.loadtesting.api.v1.test.file_pointer_pb2 import FilePointer
from yandex.cloud.loadtesting.api.v1.test.object_storage_pb2 import ObjectStorage
from yandex.cloud.loadtesting.api.v1.test.single_agent_configuration_pb2 import (
SingleAgentConfiguration,
)
from yandex.cloud.loadtesting.api.v1.common.tag_pb2 import Tag
from yandex.cloud.loadtesting.api.v1.test.test_pb2 import Test
from yandex.cloud.loadtesting.agent.v1.test_service_pb2_grpc import TestServiceStub
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(TestServiceStub)
operation = service.Create(
CreateTestRequest(
folder_id="folderId",
# configurations = [SingleAgentConfiguration(
# config_id = "configId",
# agent_selector = AgentSelector(
# agent_id = "agentId",
# match_by_filter = "matchByFilter",
# anonymous_agent = true
# ),
# files = {undefined: FilePointer(
# object_storage = ObjectStorage(
# bucket = "bucket",
# name = "name"
# )
# )}
# )],
# test_details = Details(
# name = "name",
# description = "description",
# tags = [Tag(
# key = "key",
# value = "value"
# )],
# logging_log_group_id = "loggingLogGroupId",
# artifact_settings = ArtifactSettings(
# object_storage_bucket = "objectStorageBucket",
# is_archive = true,
# filter_include = ["filterInclude"],
# filter_exclude = ["filterExclude"]
# )
# )
)
)
operation_result = sdk.wait_operation_and_get_result(
operation,
response_type=test.Test,
meta_type=CreateTestMetadata,
)
print(operation_result)
CreateTestRequest
folderId
: string
ID of the folder to create a test in.
configurations
: test.SingleAgentConfiguration
Test configuration associated with agents on which they will be executed. In case of multiple configurations, a multitest will be created.
testDetails
: test.Details
Test details. Name, tags etc.
SingleAgentConfiguration
Configuration of a test.
configId
: string
ID of the config.
agentSelector
: AgentSelector
Agent selection criterion.
files
: FilePointer
Additional files to be used during test execution, represented as rel_path:file
pairs.
rel_path
can be either a simple file name, a relative path, or absolute path. Files are
downloaded by the agent to appropriate location.
Use cases include:
- Test Data files.
- Custom Pandora executable.
- JMeter executable or ".jmx" scenario.
- etc.
Details
Test meta information.
name
: string
Name of the test.
description
: string
Description of the test.
tags
: common.Tag
Tags assigned to the test.
loggingLogGroupId
: string
ID of the logging group to which test artifacts are uploaded.
artifactSettings
: ArtifactSettings
Settings which define where to upload test artifacts and which files should be included.
AgentSelector
Agent selection criterion.
The structure is used by service to determine on which agents a specific test should be executed.
One of agent
agentId
: stringSelection by agent ID.
matchByFilter
: stringSelection by filter string.
anonymousAgent
: boolSelect anonymoud (i.e. not registered) agents.
FilePointer
Variant-like structure for referencing files in different sources.
One of filePointer
objectStorage
: ObjectStorageReference to a file in Object Storage.
Tag
Tag attached to some entity.
key
: string
Key of the tag.
value
: string
Value of the tag.
ArtifactSettings
Artifact upload settings.
Defines where to upload test artifacts and which files should be included.
One of uploadTo
objectStorageBucket
: stringName of output object storage bucket in test's folder.
isArchive
: bool
Setting which defines whether artifact files should be archived prior to uploading.
filterInclude
: string
Filter strings defining which files should be included to artifacts. GLOB format.
Example:
- '*' - all files will be uploaded.
- '.log', '.yaml - all
.log
and.yaml
files will be uploaded.
filterExclude
: string
Filter strings defining which files should be excluded from artifacts. GLOB format.
Example:
- filter_include='*', filter_exclude='phout.log' - upload all
.log
files excludingphout.log
.
ObjectStorage
Reference to a file stored in Object Storage.
bucket
: string
Bucket name.
name
: string
File name.
Operation
An Operation resource. For more information, see Operation.
id
: string
ID of the operation.
description
: string
Description of the operation. 0-256 characters long.
createdAt
: google.protobuf.Timestamp
Creation timestamp.
createdBy
: string
ID of the user or service account who initiated the operation.
modifiedAt
: google.protobuf.Timestamp
The time when the Operation resource was last modified.
done
: bool
If the value is false
, it means the operation is still in progress.
If true
, the operation is completed, and either error
or response
is available.
metadata
: google.protobuf.Any
Service-specific metadata associated with the operation. It typically contains the ID of the target resource that the operation is performed on. Any method that returns a long-running operation should document the metadata type, if any.
One of result
The operation result.
If done == false
and there was no failure detected, neither error
nor response
is set.
If done == false
and there was a failure detected, error
is set.
If done == true
, exactly one of error
or response
is set.
error
: google.rpc.StatusThe error result of the operation in case of failure or cancellation.
response
: google.protobuf.AnyThe normal response of the operation in case of success.
If the original method returns no data on success, such as Delete, the response is google.protobuf.Empty. If the original method is the standard Create/Update, the response should be the target resource of the operation. Any method that returns a long-running operation should document the response type, if any.