Skip to content

Implement load testing for workspace creation in Remote Development

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

MR: Pending

Description

It would be useful to have load testing in place for core workflows in Remote Development module as these would provide valuable insights about the existing limitations and bottlenecks of the system. These can then be used for informing future capacity planning and identification/prioritisation of optimisations.

Since workspace creation is a necessary first step before workspaces can be used / operated on by a user, implementing a load test scenario for this use case is a good starting point.

Acceptance Criteria

  • Implement a load test scenario for workspace creation

Technical Requirements

GitLab Performance Tool can be used to implement this load test.

  • Follow the instructions in the Environment Preparation Guide to set up the testing environment.
  • Create/define a new scenario file: In the performance/load_scenarios directory, create a new file called create_workspaces.js. A rough skeleton of the implementation can have the following structure:
// performance/load_scenarios/create_workspaces.js

import { check, group } from 'k6';
import { Rate } from 'k6/metrics';
import http from 'k6/http';
import { gitlabUrl, gitlabToken } from '../config.js';

export let errorRate = new Rate('errors');

export default function () {
    group('Create Workspaces', function () {
        let headers = {
            'PRIVATE-TOKEN': gitlabToken,
            'Content-Type': 'application/json',
        };

        // Replace with a group and project ID
        let groupID = 1;
        let projectID = 1;

        // Create a workspace
        let res = http.post(
            `${gitlabUrl}/api/graphql`,
            JSON.stringify({
                query: `
                    mutation {
                        workspaceCreate(input: {
                            clientMutationId: "workspace-${__VU}-${__ITER}",
                            clusterAgentId: "your-cluster-agent-id",
                            desiredState: "running",
                            devfilePath: "path-to-devfile",
                            devfileRef: "master",
                            editor: "webide",
                            maxHoursBeforeTermination: 24,
                            projectId: "${projectID}"
                        }) {
                            workspace {
                                id
                            }
                            errors
                        }
                    }
                `,
            }),
            { headers: headers }
        );

        // Check the response
        let result = check(res, {
            'status is 200': (r) => r.status === 200,
            'workspace was created': (r) => JSON.parse(r.body).data.workspaceCreate.workspace !== null,
        });

        errorRate.add(!result);
    });
}
  • Verify that the load test works and implement a run schedule for the test

Design Requirements

NA

Impact Assessment

There should be no impact as the load test should run in a dedicated environment.

User Story

NA

Edited by 🤖 GitLab Bot 🤖