Code Monkey home page Code Monkey logo

xaf-blazor-app-load-testing-example's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.