Skip to content

DevExpress/xaf-blazor-app-load-testing-example

Repository files navigation

XAF Blazor load testing on Linux and MySql using Puppeteer and GitHub Actions

This repository contains a mid-size XAF Blazor application with several views and high-load test scripts in the tests directory (powered by the Puppeteer, puppeteer-cluster, and GitHub Actions automation tools). These test scripts allow running a lot of concurrent browser instances on a cloud virtual Ubuntu machine with a pre-installed MySql database engine. In addition, we can test end user experience in case of moderate server usage/loading. Since the Blazor Server technology uses WebSocket connection instead of HTTP requests, traditional tools like JMeter are not suitable for this task.

Getting Started

  1. Clone this repository:
git clone https://github.com/DevExpress/xaf-blazor-app-load-testing-example.git
  1. Build and run the application using Visual Studio or .NET SDK CLI.

  2. Go to the project's root directory:

cd xaf-blazor-app-load-testing-example
  1. Install the Node.JS modules for running test scripts:
npm install
  1. Launch the test scripts for running an application using the following command. Specify the application url and the number of the concurrent browser instances.
node ./tests/index.js localhost:5000 30

Test Scripts

There are two test script samples in this repo. For example, the list-view-test.js script opens List View with 100 records per page and switches between pages:

List View

const DXGRID           = '.dxbs-grid .card';
const NEXT_PAGE_BUTTON = '[data-args="PBN"] div svg';

async function listViewTest(page) {
    await page.waitForSelector(DXGRID, { timeout: 60000 });

    await page.evaluate(() => {
        window.scrollTo(0, window.document.body.scrollHeight);
    });

    for (let i = 0; i < 19; i++) {
        await page.waitForSelector(NEXT_PAGE_BUTTON);

        const nextPageButton = await page.$(NEXT_PAGE_BUTTON);
        await nextPageButton.click();

        await page.waitForTimeout(500);

        await page.waitForFunction(`document.querySelector(".dxbs-grid .page-link input").value === "${i + 2}"`);

        await page.waitForTimeout(1000);
    }
}

module.exports = listViewTest;

The detail-view-test.js script is intended for checking Detail View concurrent loading.

Detail View

The run-tests.js script launches all these tests with predefined concurrency and produces a report with information about successful and failed runs. Also, it can capture a screenshot when the test fails.

Test Log Test Error

GitHub Actions CI Integration

In the following example, we use a cloud virtual Ubuntu machine for building and running an application and github-hosted runners for tests. This machine has a pre-installed MySql database engine. You can deploy your app any way you want (local machine, cloud VM, Azure App Service, etc.).

The workflow described in the deploy-app-linux.yaml file is running manually. It builds and runs an app on the self-hosted runner; then, it triggers another workflow load-tests-linux.yaml, which runs load tests themselves. We use the aurelien-baudet/workflow-dispatch@v2.

Failed task

NOTE: We store GitHub personal access token (PAT) in the PERSONAL_TOKEN secret.

You can launch the “Build and Run Application on Linux“ workflow, and it will trigger the “Load Testing”. Besides, you can deploy your app manually (e.g., to Azure App Services) and trigger only a second one with a predefined application url.

Run tests for deploy

See Also

About

XAF Blazor Server application load testing example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published