avatarDonald Le

Summary

The webpage provides a comprehensive guide on setting up an Allure Report server using Docker for both single and multiple software testing projects, aiming to save costs on enterprise reporting solutions.

Abstract

The article outlines the process of deploying an Allure Report server using Docker, which is a cost-effective alternative to enterprise reporting services. It details the setup for both single project and multiple project configurations, including the necessary Docker Compose files, environment variables, and API usage for managing projects and results. The guide emphasizes the ease of updating reports with new test results and the flexibility of generating reports on demand. It also provides practical examples, such as shell scripts for sending results to the Allure service and instructions for making the scripts executable. The author expresses gratitude to fescobar for the open-source Allure docker service, which is integral to the setup described.

Opinions

  • The author highly values the open-source contribution of fescobar, as it forms the foundation of the cost-saving reporting solution presented.
  • There is an opinion that the Allure docker service is user-friendly and supports both single and multiple project setups effectively.
  • The article suggests that using the Allure docker service can significantly reduce expenses compared to enterprise solutions, implying a preference for open-source tools in software testing.
  • The inclusion of shell scripts and API examples indicates the author's view that automation and on-demand report generation are important features for a modern reporting service.

Allure Report

Set up allure server store automation report

Save some money spent on enterprise solution for reporting service.

Photo by Anastasiya Leskova on Unsplash

First thing first, a huge thanks to fescobar for his open source work. This article can’t be made without him.

Allure docker service supports for both single project and multiple project.

Single project

We will deploy with docker-compose.

version: '3'
services:
  allure:
    image: "frankescobar/allure-docker-service"
    environment:
      CHECK_RESULTS_EVERY_SECONDS: 1
      KEEP_HISTORY: 1
    ports:
      - "5050:5050"
    volumes:
      - ${PWD}/allure-results:/app/allure-results
      - ${PWD}/allure-reports:/app/default-reports

Prepare the example code to generate allure result. Allure result should be placed in allure-results folder.

Report allure results

Run the service with

docker-compose up -d allure

Now you can checkout the report at

http://localhost:5050/allure-docker-service/projects/default/reports/latest/index.html

Allure server docker service single project

With everytime the new version of test result is updated at allure-results folder, the report will be updated automatically.

Multiple projects

This one is a little bit more complicated. We will setup with docker-compose too.

version: '3'
services:
  allure:
    image: "frankescobar/allure-docker-service"
    environment:
      CHECK_RESULTS_EVERY_SECONDS: NONE
      KEEP_HISTORY: 1
      KEEP_HISTORY_LATEST: 25
    ports:
      - "5050:5050"
    volumes:
      - ${PWD}/projects:/app/projects

Run the service with

docker-compose up -d allure

Then, we will need to create a new project by using allure service API.

Create new project id in allure service

Prepare some allure result in allure-results folder like with single project.

Now what we need to do next is push the result to allure service by send results API. There’s already shell script which supports us do this.

send_results.sh

#!/bin/bash
# This directory is where you have all your results locally, generally named as `allure-results`
ALLURE_RESULTS_DIRECTORY='allure-results'
# This url is where the Allure container is deployed. We are using localhost as example
ALLURE_SERVER='http://localhost:5050'
# Project ID according to existent projects in your Allure container - Check endpoint for project creation >> `[POST]/projects`
PROJECT_ID='mailservice'
#PROJECT_ID='my-project-id'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
FILES_TO_SEND=$(ls -dp $DIR/$ALLURE_RESULTS_DIRECTORY/* | grep -v /$)
if [ -z "$FILES_TO_SEND" ]; then
  exit 1
fi
FILES=''
for FILE in $FILES_TO_SEND; do
  FILES+="-F files[]=@$FILE "
done
set -o xtrace
echo "------------------SEND-RESULTS------------------"
curl -X POST "$ALLURE_SERVER/allure-docker-service/send-results?project_id=$PROJECT_ID" -H 'Content-Type: multipart/form-data' $FILES -ik
#If you want to generate reports on demand use the endpoint `GET /generate-report` and disable the Automatic Execution >> `CHECK_RESULTS_EVERY_SECONDS: NONE`
#echo "------------------GENERATE-REPORT------------------"
#EXECUTION_NAME='execution_from_my_bash_script'
#EXECUTION_FROM='http://google.com'
#EXECUTION_TYPE='bamboo'
#You can try with a simple curl
#RESPONSE=$(curl -X GET "$ALLURE_SERVER/allure-docker-service/generate-report?project_id=$PROJECT_ID&execution_name=$EXECUTION_NAME&execution_from=$EXECUTION_FROM&execution_type=$EXECUTION_TYPE" $FILES)
#ALLURE_REPORT=$(grep -o '"report_url":"[^"]*' <<< "$RESPONSE" | grep -o '[^"]*$')
#OR You can use JQ to extract json values -> https://stedolan.github.io/jq/download/
#ALLURE_REPORT=$(echo $RESPONSE | jq '.data.report_url')

Make this file executable then run it

chmod 777 send_results.sh
./send_results.sh
+ echo ------------------SEND-RESULTS------------------
------------------SEND-RESULTS------------------
+ curl -X POST 'http://localhost:5050/allure-docker-service/send-results?project_id=gtcommon-test' -H 'Content-Type: multipart/form-data' -F 'files[]=@/home/cuongld/Projects/Genetics-Testing/api-testing/allure-results/report.xml' -ik
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Content-Length: 270
Content-Type: application/json
Date: Sat, 12 Mar 2022 09:53:48 GMT
Server: waitress
{"data":{"current_files":["report.xml"],"current_files_count":1,"failed_files":[],"failed_files_count":0,"processed_files":["report.xml"],"processed_files_count":1,"sent_files_count":1},"meta_data":{"message":"Results successfully sent for project_id 'mailservice'"}}

Now the results are sent to the service, we need to generate the report from the result by calling this API.

Generate result

That’s it. When you go to the allure server, the report_url should be ready to view.

Report is ready to view

Hope it helps.

~~PEACE~~

Allure Reporting
Report Server
Automation Testing
Software
Programming
Recommended from ReadMedium