Skip to main content

Create

Creates (runs) a test in the specified folder.

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);
}
})();

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 : string

    Selection by agent ID.

  • matchByFilter : string

    Selection by filter string.

  • anonymousAgent : bool

    Select anonymoud (i.e. not registered) agents.

FilePointer

Variant-like structure for referencing files in different sources.

One of filePointer

  • objectStorage : ObjectStorage

    Reference 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 : string

    Name 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 excluding phout.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.Status

    The error result of the operation in case of failure or cancellation.

  • response : google.protobuf.Any
    The 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.