Skip to content

codeurjc-students/2022-PruebasRendimientoDocker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2022-Docker Performance Testing

Table of Contents

Related Documentation

Repository Guides

Pre-requisites

  1. Install Docker (Tested on version 20.10.23)

  2. Install Docker Compose (Tested on version 2.16.0)

  3. Create a docker Volume for grafana called grafana-storage

    docker volume create grafana-storage

Prepare PHP application

Follow the steps below to perform the observability tests on the PHP application:

  1. Create a docker Volume for PostgreSQL:

    docker volume create postgres-data
  2. Create inside the current directory a directory an .env file with the following content:

    UID=1000
    GID=1000
    POSTGRES_USER=postgres
    POSTGRES_PASSWORD=postgres
    POSTGRES_DB=postgres

    Change the values of UID and GID to your user and group IDs. To find out your user and group IDs, run the following commands:

    id -u # User ID
    id -g # Group ID
  3. Run the docker-compose:

    docker compose -f docker-compose.yml up -d
  4. Clone the repository app-apache-php

    git clone [email protected]:MarioRP-01/app-apache-php.git # SSH
    git clone https://github.com/MarioRP-01/app-apache-php.git # HTTPS
  5. Copy the .env file into the app-apache-php directory and change to the app-apache-php directory:

    cp .env app-apache-php/
    cd app-apache-php
  6. Follow the instructions of the set up resources guide to dump the information in the volume.

    It's possible to use the docker-compose.yml containers instead of the ones in the guide. Skip the steps 1 and 2 in the Postgres section.

  7. Finally, copy the resources directory into this directory and remove the app-apache-php directory`:

    cp -r app-apache-php/resources ./apache-resources
    rm -rf app-apache-php

How to run

Run the docker-compose file

docker compose up -d

Link grafana with prometheus

For grafana to be able to query prometheus, you need to create a data source in grafana. There are two ways to do this:

Using the UI

  1. Run the docker-compose file
  2. Open the browser and go to localhost:3000 and login with the default username and password admin:admin
  3. Go to Configuration > Data sources > Add data source
  4. Pick Prometheus as data type
  5. Save the URL as http://prometheus:9090 and save the data source

Using the provisioning file

Alternatively, you can create a provisioning file for grafana to automatically create the data source. See the directory grafana/provisioning/datasources for an example. For more information, see the references section.

Run artillery tests

One of the goals of this repository is to be able to observe the changes in the metrics when the application is subjected to different loads. To do this, we use Artillery, a load testing tool that allows us to simulate different loads on the application.

The artillery directory contains all the Artillery tests and other artifacts used by the tests.

Running the test with the Artillery CLI

  1. Ensure that you have Artillery installed (last tested with version 2.0.0-31)

    npm install -g artillery@latest
  2. To run a specific test, execute the following command:

    artillery run artillery/<test-script>

    Replace <test-script> with the name of the Artillery test script you want to run.

Running the tests with Docker

  • To run the tests using Docker, execute the following command:

    docker run --rm -it \
        --volume ${PWD}/artillery:/scripts \
        --network host \
        artilleryio/artillery:2.0.0-31 \
        run /scripts/<test-script>

    Replace <test-script> with the name of the Artillery test script you want to run.

  • Alternatively, you can use the shell script run-artillery to run the tests:

    ./run-artillery <test-script>

    Replace <test-script> with the name of the Artillery test script you want to run.

Available tests

  • apache-test-1.yml: Go to the main page, then ask for pages until there are no more pages to ask for.

    # Artillery CLI
    artillery run artillery/apache-test-1.yml
    # Docker
    docker run --rm -it \
        --volume ${PWD}/artillery:/scripts \
        --network host \
        artilleryio/artillery:2.0.0-31 \
        run /scripts/apache-test-1.yml
    # Shell script
    ./run-artillery apache-test-1.yml
  • apache-test-2.yml: Go to the main page and then navigate to a new product each two seconds twenty times.

    # Artillery CLI
    artillery run artillery/apache-test-2.yml
    # Docker
    docker run --rm -it \
        --volume ${PWD}/artillery:/scripts \
        --network host \
        artilleryio/artillery:2.0.0-31 \
        run /scripts/apache-test-2.yml
    # Shell script
    ./run-artillery apache-test-2.yml
  • apache-test-3.yml: Search for a product and navigate to the first result.

    # Artillery CLI
    artillery run artillery/apache-test-3.yml
    # Docker
    docker run --rm -it \
        --volume ${PWD}/artillery:/scripts \
        --network host \
        artilleryio/artillery:2.0.0-31 \
        run /scripts/apache-test-3.yml
    # Shell script
    ./run-artillery apache-test-3.yml

References

Related repositories

cAdvisor

cAdvisor fixes

Integration of cAdvisor with Prometheus

Grafana

Artillery

Pushing Artillery metrics to Prometheus

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published