GithubHelp home page GithubHelp logo

fescobar / allure-docker-service Goto Github PK

View Code? Open in Web Editor NEW
590.0 22.0 171.0 24.9 MB

This docker container allows you to see up to date reports simply mounting your "allure-results" directory in the container (for a Single Project) or your "projects" directory (for Multiple Projects). Every time appears new results (generated for your tests), Allure Docker Service will detect those changes and it will generate a new report automatically (optional: send results / generate report through API), what you will see refreshing your browser.

License: Apache License 2.0

Shell 19.37% Python 55.79% HTML 13.12% Groovy 9.52% PowerShell 2.19%
allure docker report reporting report-generator reporting-tool allure-framework allure2 docker-compose testing

allure-docker-service's Introduction

ALLURE DOCKER SERVICE

Table of contents

FEATURES

Allure Framework provides you good looking reports for automation testing. For using this tool is required to install a server. You could have this server running on Jenkins or if you want to see reports locally, you need to run some commands on your machine. This work results tedious, at least for me :)

For that reason, this docker container allows you to see up to date reports simply mounting your allure-results directory (for a Single Project) or your projects directory (for Multiple Projects). Every time appears new results (generated for your tests), Allure Docker Service will detect those changes and it will generate a new report automatically (optional: send results / generate report through API), what you will see refreshing your browser.

  • Useful for developers who wants to run tests locally and want to see what were the problems during regressions.
  • Useful for the team to check the tests status for every project.

Docker Hub

Docker Versions

Docker container versions are based on binary Allure 2 releases

Image Variants

Allure Docker Service supports architectures amd64, arm32v7 and arm64v8.

The following table shows the variation of provided images.

Tag Base Image Arch OS
0.20.7-amd64 amd64/adoptopenjdk:11-jre-openj9-bionic amd64 ubuntu
0.20.7-arm32v7 arm32v7/adoptopenjdk:11-jdk-hotspot-bionic arm32v7 ubuntu
0.20.7-arm64v8 arm64v8/adoptopenjdk:11-jre-hotspot-bionic arm64v8 ubuntu

The following table shows the provided Manifest Lists.

Tag allure-docker-service Base Image
latest, 2.27.0 frankescobar/allure-docker-service:2.27.0-amd64
frankescobar/allure-docker-service:2.27.0-arm32v7
frankescobar/allure-docker-service:2.27.0-arm64v8

USAGE

Generate Allure Results

First at all it's important to be clear. This container only generates reports based on results. You have to generate allure results according to the technology what are you using.

Reference: https://github.com/fescobar/allure-docker-service-examples

We have some examples projects:

In this case we are going to generate results using the java project allure-docker-java-testng-example of this repository.

Go to directory allure-docker-java-testng-example via command line:

cd allure-docker-java-testng-example

Execute:

mvn test -Dtest=FirstTest

If everything is OK, you should see something like this:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.allure.docker.FirstTest
13:19:03.028 [main] INFO com.allure.docker.FirstTest - test1
13:19:03.044 [main] DEBUG io.qameta.allure.AllureLifecycle - Adding attachment to item with uuid 4b282bd9-6a0f-4fc3-a5cc-be6e8220d3c6
13:19:03.124 [main] INFO com.allure.docker.FirstTest - test2
13:19:03.133 [main] DEBUG io.qameta.allure.AllureLifecycle - Adding attachment to item with uuid e2097440-e9e8-46e9-8b9d-09467b5a49b1
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.702 s <<< FAILURE! - in com.allure.docker.FirstTest
[ERROR] test2(com.allure.docker.FirstTest)  Time elapsed: 0.028 s  <<< FAILURE!
java.lang.AssertionError: FAILURE ON PURPOSE
        at com.allure.docker.FirstTest.test2(FirstTest.java:37)

[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   FirstTest.test2:37 FAILURE ON PURPOSE
[INFO]
[ERROR] Tests run: 2, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.600 s
[INFO] Finished at: 2019-09-16T13:19:03+01:00
[INFO] ------------------------------------------------------------------------

There are 2 tests, one of them failed. Now you can see the allure-results diretory was created inside of allure-docker-java-testng-example project.

Just it has left 1 step more. You have to run allure-docker-service mounting your allure-results directory.

Start the container for a single project -> SINGLE PROJECT - LOCAL REPORTS

ALLURE DOCKER SERVICE

Docker Image: https://hub.docker.com/r/frankescobar/allure-docker-service/

Project Type Port Volume Path Container Volume Path
Single Project 5050 ${PWD}/allure-results /app/allure-results
${PWD}/allure-reports /app/default-reports
Multiple Projects 5050 ${PWD}/projects /app/projects

To improve the navigability is recommended to install an Extension/AddOn in your browser:

NOTE:

SINGLE PROJECT - LOCAL REPORTS

This option is recommended for local executions. You should attach the volume where your results are being generated locally for your automation project.

All the information related local executions will be stored in the default project what is created when you start the container. You can see the complete info using the GET /projects/default endpoint:

Single Project - Docker on Unix/Mac

From this directory allure-docker-java-testng-example execute next command:

      docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=3 -e KEEP_HISTORY=1 \
                 -v ${PWD}/allure-results:/app/allure-results \
                 -v ${PWD}/allure-reports:/app/default-reports \
                 frankescobar/allure-docker-service
Single Project - Docker on Windows (Git Bash)

From this directory allure-docker-java-testng-example execute next command:

      docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=3 -e KEEP_HISTORY=1 \
                 -v "/$(pwd)/allure-results:/app/allure-results" \
                 -v "/$(pwd)/allure-reports:/app/default-reports" \
                 frankescobar/allure-docker-service
Single Project - Docker Compose

Using docker-compose is the best way to manage containers: allure-docker-java-testng-example/docker-compose.yml

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

From this directory allure-docker-java-testng-example execute next command:

docker-compose up allure

If you want to run in background:

docker-compose up -d allure

You can see the logs:

docker-compose logs -f allure

NOTE:

  • Check the New User Interface
  • Read about PORT 4040 Deprecated in case you are using previous versions.
  • The ${PWD}/allure-results directory could be in anywhere on your machine. Your project must generate results in that directory.
  • The /app/allure-results directory is inside of the container. You MUST NOT change this directory, otherwise, the container won't detect the new changes.
  • The /app/default-reports directory is inside of the container. You MUST NOT change this directory, otherwise, the history reports won't be stored.

NOTE FOR WINDOWS USERS:

  • ${PWD} determines the current directory. This only works for GIT BASH. If you want to use PowerShell or CMD you need to put your full path to allure-results directory or find the way to get the current directory path using those tools.

MULTIPLE PROJECTS - REMOTE REPORTS

Available from Allure Docker Service version 2.13.3

With this option you could generate multiple reports for multiple projects, you can create, delete and get projects using Project Endpoints. You can use Swagger documentation to help you.

IMPORTANT NOTE:

  • For multiple projects configuration you must use CHECK_RESULTS_EVERY_SECONDS with value NONE. Otherwise, your performance machine would be affected, it could consume high memory, processors and storage. Use the endpoint GET /generate-report on demand after sending the results POST /send-results.
  • If you use automatic reports a daemom is created and it will be listening any change in the results directory it will generate a new report each time find a new file. The same will happen for every project. For that reason, it's convenient disable the automatic reports using the value NONE in CHECK_RESULTS_EVERY_SECONDS.
Multiple Project - Docker on Unix/Mac
      docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=NONE -e KEEP_HISTORY=1 \
                 -v ${PWD}/projects:/app/projects \
                 frankescobar/allure-docker-service
Multiple Project - Docker on Windows (Git Bash)
      docker run -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=NONE -e KEEP_HISTORY=1 \
                 -v "/$(pwd)/projects:/app/projects" \
                 frankescobar/allure-docker-service
Multiple Project - Docker Compose

Using docker-compose is the best way to manage containers: allure-docker-multi-project-example/docker-compose.yml

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
docker-compose up allure

If you want to run in background:

docker-compose up -d allure

You can see the logs:

docker-compose logs -f allure

NOTE:

NOTE FOR WINDOWS USERS:

  • ${PWD} determines the current directory. This only works for GIT BASH. If you want to use PowerShell or CMD you need to put your full path to allure-results directory or find the way to get the current directory path using those tools.
Creating our first project
  • Creating the project my-project-id using the endpoint POST /projects:

  • You can see all the existent projects using the endpoint GET /projects:

  • The default project is always created automatically, it shouldn't be removed.

  • And get specific information using the endpoint GET /projects/{id}

If we want to generate reports for this specific project we need to use the same Action Endpoints that we used for a single project, but the difference now is we need to use the query parameter project_id to specify our new project.

For example if we want to get the latest report for a single project, generally we execute this command:

This command will return the latest report from the default project as you see in the url above

If we want to get the latest report from our new project we need to execute this one:

You can appreciate the difference in the path /projects/{PROJECT_ID}/....

You can use any Action Endpoints, but don't forget to pass the parameter project_id with the right project id that you want to interact with it.

'GET' /latest-report?project_id=my-project-id

'POST' /send-results?project_id=my-project-id

'GET' /generate-report?project_id=my-project-id

'GET' /clean-results?project_id=my-project-id

'GET' /clean-history?project_id=my-project-id

'GET' /emailable-report/render?project_id=my-project-id

'GET' /emailable-report/export?project_id=my-project-id

'GET' /report/export?project_id=my-project-id

We are going to attach our volume NOT for our local allure-results. For this case is necessary to store the information regarding all our projects. The project structure is this one:

projects
   |-- default
   |   |-- results
   |   |-- reports
   |   |   |-- latest
   |   |   |-- ..
   |   |   |-- 3
   |   |   |-- 2
   |   |   |-- 1
   |-- my-project-id
   |   |-- results
   |   |-- reports
   |   |   |-- latest
   |   |   |-- ..
   |   |   |-- 3
   |   |   |-- 2
   |   |   |-- 1

NOTE:

  • You MUST NOT MODIFY MANUALLY the structure directory of any project, you could affect the right behaviour.
  • If you don't attach your volume with the proper path /app/projects you will lost the information about the projects generated for you.

PORT 4040 Deprecated

The first versions of this container used port 4040 for Allure Report and port 5050 for Allure API.

The latest version includes new features Multiple Projects & Navigate detailed previous history/trends. These improvements allow us to handle multiple projects and multiple history reports.

The only change required from your side is start using only port 5050 and instead to use http://localhost:4040/ for rendering Allure report you should use http://localhost:5050/allure-docker-service/latest-report

If you are mounting your volume -v ${PWD}/allure-results:/app/allure-results your allure results are being used and stored in default project internally in the container, you don't need to change your volume path directory or do anything else. If you want to keep the history reports start to attach another path -v ${PWD}/allure-reports:/app/default-reports.

If you are already using port 4040, NO WORRIES. The Allure Report exposed in port 4040 will still being rendered for avoiding compatibility problems. The only issue you will face will be when you try to navigate the HISTORY from the TREND chart or any other widget aiming to any historic data. The error you will see is HTTP ERROR 404 NOT FOUND

Version Port Volume Path Container Volume Path Get Latest Report
Previous to 2.13.3 4040 ${PWD}/allure-results /app/allure-results http://localhost:4040/
From 2.13.3 5050 ${PWD}/allure-results /app/allure-results http://localhost:5050/allure-docker-service/latest-report
${PWD}/allure-reports /app/default-reports

Check the new commands to start the container for a single project or for multiple projects: ALLURE DOCKER SERVICE

Known Issues

  • Permission denied --> #108

Opening & Refreshing Report

If everything was OK, you will see this:

allure_1  | Generating default report
allure_1  | Overriding configuration
allure_1  | Checking Allure Results every 1 second/s
allure_1  | Creating executor.json for PROJECT_ID: default
allure_1  | Generating report for PROJECT_ID: default
allure_1  | Report successfully generated to /app/allure-docker-api/static/projects/default/reports/latest
allure_1  | Status: 200
allure_1  | Detecting results changes for PROJECT_ID: default
allure_1  | Automatic Execution in Progress for PROJECT_ID: default...
allure_1  | Creating history on results directory for PROJECT_ID: default ...
allure_1  | Copying history from previous results...
allure_1  | Creating executor.json for PROJECT_ID: default
allure_1  | Generating report for PROJECT_ID: default
allure_1  | 2020-06-18 17:02:12.364:INFO::main: Logging initialized @1620ms to org.eclipse.jetty.util.log.StdErrLog
allure_1  | Report successfully generated to /app/allure-docker-api/static/projects/default/reports/latest
allure_1  | Storing report history for PROJECT_ID: default
allure_1  | BUILD_ORDER:1
allure_1  | Status: 200

To see your latest report simply open your browser and access to:

The latest report is generated automatically and sometimes could be not available temporary until the new latest report has been generated. If you access to the latest report url when is not available you will see the NOT FOUND page. It will take a few seconds until the latest report be available again.

When you use the latest-report will be redirected to the resource url:

When you start the container for a single report, the default project will be created automatically, for that reason you are redirected to this endpoint to get information about default project, you can see this in the path .../projects/default/...

The redirect=false parameter is used to avoid be redirected to the GET /projects/{id} endpoint (default behaviour)

Now we can run other tests without being worried about Allure server. You don't need to restart or execute any Allure command.

Just go again to this directory allure-docker-java-testng-example via command line:

cd allure-docker-java-testng-example

And execute another suite test:

mvn test -Dtest=SecondTest

When this second test finished, refresh your browser and you will see there is a new report including last results tests.

We can run the same test suite again and navigate the history:

You can repeat these steps, but now execute the third and fourth test

mvn test -Dtest=ThirdTest
mvn test -Dtest=FourthTestFactory

New User Interface

Check the new UI

Deploy using Kubernetes

Check yaml definitions here:

Extra options

Allure API

Available endpoints:

Info Endpoints

'GET' /version

'GET' /swagger

'GET' /swagger.json

Action Endpoints

'GET' /config

'GET' /latest-report

'POST' /send-results (admin role)

'GET' /generate-report (admin role)

'GET' /clean-results (admin role)

'GET' /clean-history (admin role)

'GET' /emailable-report/render

'GET' /emailable-report/export

'GET' /report/export

Project Endpoints

'POST' /projects (admin role)

'GET' /projects

'DELETE' /projects/{id} (admin role)

'GET' /projects/{id}

'GET' /projects/{id}/reports/{path}

'GET' /projects/search

Security Endpoints

'POST' /login

'POST' /refresh

'DELETE' /logout

'DELETE' /logout-refresh-token

Access to http://localhost:5050 to see Swagger documentation with examples

From version 2.13.4 you can request an endpoint using the base path (prefix) /allure-docker-service/:

curl http://localhost:5050/allure-docker-service/version

or you can request without the prefix like in previous versions

curl http://localhost:5050/version

For accessing Security Endpoints, you have to enable the security. Check Enable Security section.

Send results through API

Available from Allure Docker Service version 2.12.1

After running your tests, you can execute any script to send the generated results from any node/agent/machine to the Allure Docker server container using the Allure API. Use the endpoint POST /send-results.

You have 2 options to send results:

Content-Type - application/json
python send_results.py
python send_results_security.py
./send_results.ps1
Content-Type - multipart/form-data

Available from Allure Docker Service version 2.13.3

./send_results.sh
./send_results_security.sh

NOTE:

Force Project Creation Option

Available from Allure Docker Service version 2.13.6 If you use the query parameter force_project_creation with value true, the project where you want to send the results will be created automatically in case doesn't exist.

POST /send-results?project_id=any-unexistent-project&force_project_creation=true

Customize Executors Configuration

Available from Allure Docker Service version 2.13.3

When you use the GET /generate-report, you will see this in your report:

If you want to change the execution name, you need to pass a parameter named execution_name with the value. Example: GET /generate-report?execution_name=my-execution-name

If you want to change the execution from (by default is empty), you need to pass a parameter named execution_from with the value. Example: GET /generate-report?execution_from=http://my-jenkins-url/job/my-job/7/

This option allow you to come back to your executor server.

If you want to change the execution icon (default is empty), you need to pass a parameter named execution_type with the value. Example: GET /generate-report?execution_type=jenkins

If the type is not recognized it will take the default icon. You can use different types like:

  • jenkins

  • teamcity

  • bamboo

  • gitlab

  • github

The icons are based on the native Allure2 Framework:

API Response Less Verbose

Available from Allure Docker Service version 2.13.1

Enable API_RESPONSE_LESS_VERBOSE environment variable if you are handling big quantities of files. This option is useful to avoid to transfer too much data when you request the API. Have in mind the json response structure will change.

    environment:
      API_RESPONSE_LESS_VERBOSE: 1

Switching version

You can switch the version container using frankescobar/allure-docker-service:${VERSION_NUMBER}. Docker Compose example:

  allure:
    image: "frankescobar/allure-docker-service:2.27.0"

or using latest version:

  allure:
    image: "frankescobar/allure-docker-service:latest"

By default it will take last version: https://hub.docker.com/r/frankescobar/allure-docker-service/tags

Switching port

Inside of the container Allure API use port 5050. You can switch the port according to your convenience. Docker Compose example:

    ports:
      - "9292:5050"

Updating seconds to check Allure Results

Updating seconds to check results directory to generate a new report up to date. Docker Compose example:

    environment:
      CHECK_RESULTS_EVERY_SECONDS: 5

Use NONE value to disable automatic checking results. If you use this option, the only way to generate a new report up to date it's using the Allure API.

    environment:
      CHECK_RESULTS_EVERY_SECONDS: NONE
  • CHECK_RESULTS_EVERY_SECONDS=3 It's only useful for executions in yourLOCAL machine. With this option ENABLED the container detects any changes in the allure-results directory. Every time detects a new file, the container will generate a new report. The workflow will be the next:
  1. Start allure-docker-service via docker-compose mounting the allure-results volume that your project will use to storage the results files. It's recommended to use this configuration SINGLE PROJECT - LOCAL REPORTS
  2. Generate your allure results with any Allure Framework according technology (Allure/Cucumber/Java, Allure/Specflow/C#, Allure/CucumberJS/NodeJS, etc). Your results will be stored in a directory named allure-results in any directory inside your project. Remember to use the same location that you are mounting when you start the docker container in the previous step. Also, never remove that allure-results directory, otherwise docker will lose the reference to that volume.
  3. Every time new results files are generated during every test execution, automatically the containers will detects those changes and it will generate a new report.
  4. You will see the report generated
  5. If you see multiple reports that it doesn't represent the real quantity of executions it's because the report is generated each time detects changes in the allure-results directory including existing previous results files in that directory. That's the reason is only useful locally.
  • CHECK_RESULTS_EVERY_SECONDS=NONE. This option is useful when you deploy allure-docker-service in a server and you are planning to feed results from any CI tool. With this option DISABLED the container won't detect any changes in the allure-results directory (Otherwise, it's higly cost if you handle multiple projects in terms of processor comsuption). The report won't be generated until you generate the report on demand using the API GET /generate-report. This will be the workflow:

From any server machine:

  1. Deploy allure-docker-service using Kubernetes or any other tool in any server. It's recommended to use this configuration MULTIPLE PROJECTS - REMOTE REPORTS.
  2. Make sure the server is accessible from where your scripts are requesting the API.

From your automation tests project:

  1. Request endpoint GET /clean-results (specify project if it's needed) to clean all existing results. This will be BEFORE starting any test execution.
  2. Execute your tests and generate your allure results with any Allure Framework according technology (Allure/Cucumber/Java, Allure/Specflow/C#, Allure/CucumberJS/NodeJS, etc).
  3. Once all your tests were executed, send all your results generated recently using the endpoint POST /send-results (specify project if it's needed).
  4. You won't see any report generated because at the moment you have only your results stored in the container.
  5. Now that you have all the info (allure results files) in the server, you can request the endpoint GET /generate-report. This action will build the report to be show.

NOTE:

  • Scripts to interact with the API: Send results through API (Check commented code in the scripts).

  • If you execute GET /generate-report endpoint after every test execution, you will see multiple reports that doesn't represent your executions, that is because the container is building the report taking in count existing results files. For that reason, we use the GET /clean-results endpoint before starting any new execution to delete all results not related the current execution.

Resume:

---EXECUTION 1---
1. Clean results files to avoid data from previous results files - GET /clean-results
2. Execute Suite1
3. Execute Suite2
4. Execute Suite3
5. Wait for all suites to finish
6. Send results using endpoints - POST /send-results
7. Generate report using endpoint - GET /generate-report
Report will include all suites results from this execution.

---EXECUTION 2---
Same steps from previous execution (don't forget to clean results first)

Keep History and Trends

Available from Allure Docker Service version 2.12.1

Enable KEEP_HISTORY environment variable to work with history & trends

Docker Compose example:

    environment:
      KEEP_HISTORY: "TRUE"

From version 2.13.4 you can also use as value 1

    environment:
      KEEP_HISTORY: 1

If you want to clean the history use the Allure API.

Allure framework allow you to see the latest 20 executions in the history allure-framework/allure2#1059

Available from Allure Docker Service version 2.13.3

You can access to previous history clicking on the Allure image in the report. If the report is not available you will be redirected to the endpoint GET /projects/{id}

Also, Allure Docker Service by default keeps the latest 20 executions in the history, but you can extend that limit:

    environment:
      KEEP_HISTORY_LATEST: 28

or you can reduce it

    environment:
      KEEP_HISTORY_LATEST: 10

The latest directory contains the report from the last execution. On this case, the 29 directory contains the same report in the latest directory:

Override User Container

Available from Allure Docker Service version 2.13.1

Override the user container in case your platform required it. The container must have permissions to create files inside directories like allure-results (Single Project) or projects (Multiple Project) or any other directory that you want to mount.

1000:1000 is the user:group for allure user

Docker Compose example:

    user: 1000:1000
    environment:
      ...

or you can pass the current user using environment variable

    user: ${MY_USER}
    environment:
      ...
MY_USER=$(id -u):$(id -g) docker-compose up -d allure

or from Docker you can use parameter --user

docker run --user="$(id -u):$(id -g)" -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=3 -e KEEP_HISTORY="TRUE" \
           -v ${PWD}/allure-results:/app/allure-results \
           -v ${PWD}/allure-reports:/app/default-reports \
           frankescobar/allure-docker-service

Note: It's not a good practice to use root user to manipulate containers.

Reference:

Start in DEV Mode

Available from Allure Docker Service version 2.13.3

Enable dev mode, if you want to see the logs about api requests using the DEV_MODE environment variable.

Docker Compose example:

    environment:
      DEV_MODE: 1

NOTE:

  • Don't use this mode for live/prod environments.

Enable TLS

Available from Allure Docker Service version 2.13.4

Enable TLS, if you want to implement https protocol using the TLS environment variable.

Docker Compose example:

    environment:
      TLS: 1

Enable Security

Available from Allure Docker Service version 2.13.5

If you are going to publish this API, this feature MUST BE USED TOGETHER with Enable TLS, otherwise, your tokens can be intercepted and your security could be vulnerable. When you enable TLS, the cookies credentials will be stored as SECURE.

It's recommended to use Allure Docker Service UI container New User Interface for accessing to the information without credentials problems.

You can define the ADMIN user credentials with env vars 'SECURITY_USER' & 'SECURITY_PASS' Also you need to enable the security to protect the endpoints with env var 'SECURITY_ENABLED'.

Docker Compose example:

    environment:
      SECURITY_USER: "my_username"
      SECURITY_PASS: "my_password"
      SECURITY_ENABLED: 1

Where 'SECURITY_PASS' env var is case sensitive.

Note: Check Roles section if you want to handle different roles.

When the security is enabled, you will see the Swagger documentation (http://localhost:5050/allure-docker-service/swagger) updated with new security endpoints and specifying the protected endpoints.

If you try to use the endpoints GET /projects

curl -X GET http://localhost:5050/allure-docker-service/projects -ik

You will see this response

HTTP/1.1 401 UNAUTHORIZED
Access-Control-Allow-Origin: *
Content-Length: 67
Content-Type: application/json
Date: Tue, 11 Aug 2020 10:31:37 GMT
Server: waitress

{"meta_data":{"message":"Missing cookie \"access_token_cookie\""}}
Login

To access to protected endpoints you need to use the endpoint POST /login with the credentials configured in the initial step.

curl -X POST http://localhost:5050/allure-docker-service/login \
  -H 'Content-Type: application/json' \
  -d '{
    "username": "my_username",
    "password": "my_password"
}' -c cookiesFile -ik

We are storing the cookies obtained in a file cookiesFile to use it in the next requests:

Now we try to request the protected endpoints using the cookies obtained from POST /login endpoint.

curl -X GET http://localhost:5050/allure-docker-service/projects -b cookiesFile -ik

Using the security cookies we will have access to any endpoint protected.

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin:
Content-Length: 606
Content-Type: application/json
Date: Sun, 16 Aug 2020 11:09:01 GMT
Server: waitress

{"data":{"projects":{"default":{"uri":"http://localhost:5050/allure-docker-service/projects/default"}}},"meta_data":{"message":"Projects successfully obtained"}}

X-CSRF-TOKEN

For example, if you try to create a new project with the security enabled with the cookies obtained in the POST /login endpoint

curl -X POST "http://localhost:5050/allure-docker-service/projects" \
-H "Content-Type: application/json" \
-d '{
  "id": "my-project-id"
}' -b cookiesFile -ik

You will received a 401 asking for CSRF token

HTTP/1.1 401 UNAUTHORIZED
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin:
Content-Length: 47
Content-Type: application/json
Date: Mon, 17 Aug 2020 07:46:51 GMT
Server: waitress

{"meta_data":{"message":"Missing CSRF token"}}

You need to pass the header X-CSRF-TOKEN (Cross-Site Request Forgery) if you request to endpoints with method type POST, PUT, PATCH & DELETE.

You can get the X-CSRF-TOKEN value from the cookie csrf_access_token which is obtained from the POST /login successfully response (check your cookies section).

Here we are extracting the value of csrf_access_token cookie from the cookiesFile file generated with the POST /login

CRSF_ACCESS_TOKEN_VALUE=$(cat cookiesFile | grep -o 'csrf_access_token.*' | cut -f2)
echo "csrf_access_token value: $CRSF_ACCESS_TOKEN_VALUE"

Once you get the csrf_access_token value you need to send it as header named X-CSRF-TOKEN

curl -X POST "http://localhost:5050/allure-docker-service/projects" \
-H "X-CSRF-TOKEN: $CRSF_ACCESS_TOKEN_VALUE" -H "Content-Type: application/json" \
-d '{
  "id": "my-project-id"
}' -b cookiesFile -ik
HTTP/1.1 201 CREATED
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin:
Content-Length: 90
Content-Type: application/json
Date: Mon, 17 Aug 2020 07:51:37 GMT
Server: waitress

{"data":{"id":"my-project-id"},"meta_data":{"message":"Project successfully created"}}

Refresh Access Token

If you want to avoid the user login each time the access token expired, you need to refresh your token

For refreshing the access token, you have to use the refresh_token_cookie and csrf_refresh_token

Here, we are extracting the value of csrf_refresh_token cookie from the cookiesFile file generated with the POST /login endpoint

CRSF_REFRESH_TOKEN_VALUE=$(cat cookiesFile | grep -o 'csrf_refresh_token.*' | cut -f2)
echo "csrf_refresh_token value: $CRSF_REFRESH_TOKEN_VALUE"

After that, we need to send csrf_refresh_token as header X-CSRF-TOKEN and the cookies file with the -b option.

curl -X POST http://localhost:5050/allure-docker-service/refresh -H "X-CSRF-TOKEN: $CRSF_REFRESH_TOKEN_VALUE" -c cookiesFile -b cookiesFile -ik

With -c options we are overriding the cookies file with the new tokens provided for POST /refresh endpoint.

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin:
Content-Length: 428
Content-Type: application/json
Date: Mon, 17 Aug 2020 08:25:21 GMT
Server: waitress
Set-Cookie: access_token_cookie=eyJ0eXAiOiJKV1Qi...; HttpOnly; Path=/
Set-Cookie: csrf_access_token=d34c2eb1-dcc5-481c-a4ad-2c499a992f65; Path=/

{"data":{"access_token":"eyJ0eXAiOiJKV1Qi..."},"meta_data":{"message":"Successfully token obtained"}}

The Access Token expires in 15 mins by default. You can change the default behaviour with env var ACCESS_TOKEN_EXPIRES_IN_MINS

Docker Compose example:

    environment:
      ACCESS_TOKEN_EXPIRES_IN_MINS: 30

Also for development purposes, you can use the env var ACCESS_TOKEN_EXPIRES_IN_SECONDS Docker Compose example:

    environment:
      ACCESS_TOKEN_EXPIRES_IN_SECONDS: 30

You should use the Refresh Token to avoid the user login again.

The Refresh token doesn't expire by default. You can change the default behaviour with env var REFRESH_TOKEN_EXPIRES_IN_DAYS Docker Compose example:

    environment:
      REFRESH_TOKEN_EXPIRES_IN_DAYS: 60

Also for development purposes you can use the env var REFRESH_TOKEN_EXPIRES_IN_SECONDS Docker Compose example:

    environment:
      REFRESH_TOKEN_EXPIRES_IN_SECONDS: 10

NOTE:

  • You can disable the expiration of any token using value 0.
Logout

We have 2 endpoints:

With DELETE /logout your current access_token will be invalidated. You need to pass as header the csrf_access_token token.

CRSF_ACCESS_TOKEN_VALUE=$(cat cookiesFile | grep -o 'csrf_access_token.*' | cut -f2)
echo "csrf_access_token value: $CRSF_ACCESS_TOKEN_VALUE"

curl -X DELETE http://localhost:5050/allure-docker-service/logout -H "X-CSRF-TOKEN: $CRSF_ACCESS_TOKEN_VALUE" -b cookiesFile -ik
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Content-Length: 52
Content-Type: application/json
Date: Fri, 21 Aug 2020 11:17:22 GMT
Server: waitress

{"meta_data":{"message":"Successfully logged out"}}

With DELETE /logout-refresh-token your current refresh_token will be invalidated and all cookies removed. You need to pass as header the csrf_refresh_token token:

CRSF_REFRESH_TOKEN_VALUE=$(cat cookiesFile | grep -o 'csrf_refresh_token.*' | cut -f2)
echo "csrf_refresh_token value: $CRSF_REFRESH_TOKEN_VALUE"

curl -X DELETE http://localhost:5050/allure-docker-service/logout-refresh-token -H "X-CSRF-TOKEN: $CRSF_REFRESH_TOKEN_VALUE" -b cookiesFile -ik
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Content-Length: 52
Content-Type: application/json
Date: Fri, 21 Aug 2020 11:47:47 GMT
Server: waitress
Set-Cookie: access_token_cookie=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly; Path=/
Set-Cookie: csrf_access_token=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; Path=/
Set-Cookie: refresh_token_cookie=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly; Path=/
Set-Cookie: csrf_refresh_token=; Expires=Thu, 01-Jan-1970 00:00:00 GMT; Path=/

{"meta_data":{"message":"Successfully logged out"}}
Roles

Available from Allure Docker Service version 2.13.7

SECURITY_USER & SECURITY_PASS env vars are used to define the ADMIN user credentials who will have access to every endpoint. Also, there is another kind of user just with enough access to check the reports, this is the VIEWER user.

You can add this kind of user using SECURITY_VIEWER_USER & SECURITY_VIEWER_PASS env variables Docker Compose example:

    environment:
      SECURITY_USER: "my_username"
      SECURITY_PASS: "my_password"
      SECURITY_VIEWER_USER: "view_user"
      SECURITY_VIEWER_PASS: "view_pass"
      SECURITY_ENABLED: 1

Note:

  • Always you need to define the ADMIN user.
  • SECURITY_USER & SECURITY_VIEWER_USER always need to be different.
  • Check Allure API to see what endpoints are exclusively for the ADMIN role.
Make Viewer endpoints public

Available from Allure Docker Service version 2.13.8 If you only want to protect the Admin endpoints and make public the viewer endpoints, then you can use the environment variable MAKE_VIEWER_ENDPOINTS_PUBLIC to make accessible the endpoints:

Docker Compose example:

    environment:
      SECURITY_USER: "my_username"
      SECURITY_PASS: "my_password"
      SECURITY_ENABLED: 1
      MAKE_VIEWER_ENDPOINTS_PUBLIC: 1

Note:

  • With MAKE_VIEWER_ENDPOINTS_PUBLIC enabled, your viewer user (if you have someone defined) won't have effect.
Scripts
./send_results_security.sh
python send_results_security.py

Multi-instance Setup

Available from Allure Docker Service version 2.18.0 If you wish to use a setup with multiple instances, you will need to set JWT_SECRET_KEY env variables. Otherwise, requests may respond with Invalid Token - Signature verification failed.

Add Custom URL Prefix

Available from Allure Docker Service version 2.13.5

Configure an url prefix if your deployment requires it (e.g. reverse proxy with nginx)

    environment:
      URL_PREFIX: "/my-prefix"

With this configuration you can request the API in this way too:

curl http://localhost:5050/my-prefix/allure-docker-service/version

Here's an example config for nginx where allure is the name of the docker container

server {
    listen 443 ssl;
    ssl_certificate     /certificate.cer;
    ssl_certificate_key /certificate.key;
    location /my-prefix/ {
        proxy_pass http://allure:5050;
        proxy_set_header  Host $host;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  X-Forwarded-Host $server_name;
    }
}

NOTE:

  • This feature is not supported when DEV_MODE is enabled.

Optimize Storage

Available from Allure Docker Service version 2.13.7

---EXPERIMENTAL FEATURE---

When Allure generates reports, commonly created these files per report:

projects
   |-- default
   |   |-- results
   |   |-- reports
   |   |   |-- latest
   |   |   |   |-- data
   |   |   |   |-- export
   |   |   |   |-- history
   |   |   |   |-- plugins
   |   |   |   |-- widgets
   |   |   |   |-- favicon.icon
   |   |   |   |-- index.html
   |   |   |   |-- app.js
   |   |   |   |-- styles.css
   |   |   |-- ..

The heaviest files are app.js & styles.css. They never changed their content. When you enable the option OPTIMIZE_STORAGE those files are not stored in your reports directory, but they are consumed from a common location inside the container.

Docker Compose example:

    environment:
      OPTIMIZE_STORAGE: 1

Using this feature, your storage consumption will be reduce drastically.

NOTE:

  • This feature doesn't have a warranty to work with reports generated with different Allure native versions. For example, if any code is removed from app.js or styles.css (from a newer version of the native Allure application) that you need to render your reports generated with previous versions, your report couldn't be rendered, you will see a javascript error finding for a component that doesn't exist anymore.

Export Native Full Report

Available from Allure Docker Service version 2.13.1

You can export the native full report using the endpoint GET /report/export Allure API.

Customize Emailable Report

Available from Allure Docker Service version 2.12.1

You can render and export the emailable report using the endpoints GET /emailable-report/render and GET ​/emailable-report​/export Allure API.

Override CSS

By default this report template is using Bootstrap css. If you want to override the css, just you need to pass the enviroment variable EMAILABLE_REPORT_CSS_CDN. Docker Compose example:

    environment:
      EMAILABLE_REPORT_CSS_CDN: "https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/sketchy/bootstrap.css"

You can use all these themes: https://bootswatch.com/ or any other boostrap css like https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.css

Override title

If you want override the title of the Emailable Report, just you need to pass the environment variable EMAILABLE_REPORT_TITLE.

    environment:
      EMAILABLE_REPORT_TITLE: "My Title"

Override server link

Functionality Deprecated

  • Currently the latest version resolves the host automatically.

If you want the Emailable Report to redirect to your Allure server, just you need to pass the environment variable SERVER_URL.

    environment:
      SERVER_URL: "http://my-domain.com/allure-docker-service/latest-report"

Develop a new template

If you want to develop a new template, create a local directory (my-template as example) with a file named default.html. In that file you can create your own html template, you can use as guide this example: allure-docker-api/templates/default.html using Jinja syntax. Don't rename your local template, always the file must be named default.html.

Mount that directory to the container like in the example and pass the environment variable FLASK_DEBUG with value 1. This variable will allow you to use hot reloading, you can update the content of default.html locally and use the endpoint emailable-report/render (Allure API) to see your changes applied in the browser.

    environment:
      FLASK_DEBUG: 1
    volumes:
    - ${PWD}/my-template:/app/allure-docker-api/templates

Allure Customized Plugins

If you want to use your own Allure plugins you can mount your plugin directory

    environment:
      ...
    volumes:
    - ${PWD}/my-plugin:/allure/plugins/my-plugin

References:

Allure Options

Some frameworks/adaptors don't support allure properties to set up links for Tracker Management Systems or Issue/Bug Trackers. In that case you need to set up ALLURE_OPTS environment variable:

  • For Allure1 (XML results)
    environment:
      CHECK_RESULTS_EVERY_SECONDS: 1
      ALLURE_OPTS: "-Dallure.tests.management.pattern=https://example.org/tms/%s -Dallure.issues.tracker.pattern=https://example.org/issue/%s"
  • For Allure2 (JSON results). Generally it's not necessary to do this because the properties are configured it in the adaptor/framework and stored in allure-results directory. The properties format is different:
allure.link.mylink.pattern=https://example.org/mylink/{}
allure.link.issue.pattern=https://example.org/issue/{}
allure.link.tms.pattern=https://example.org/tms/{}

Reference:

SUPPORT

Gitter

Gitter

DOCKER GENERATION (Usage for developers)

Install Docker

sudo apt-get update
sudo apt install -y docker.io

If you want to use docker without sudo, read following links:

Develop locally with Docker-Compose

docker-compose -f docker-compose-dev.yml up --build

Build image

docker build -t allure-release -f docker-custom/Dockerfile.bionic-custom --build-arg ALLURE_RELEASE=2.27.0 .

Run container

docker run -d  -p 5050:5050 allure-release

See active containers

docker container ls

Access to container

docker exec -it ${CONTAINER_ID} bash

Access to logs

docker exec -it ${CONTAINER_ID} tail -f log

Remove all containers

docker container rm $(docker container ls -a -q) -f

Remove all images

docker image rm $(docker image ls -a -q)

Remove all stopped containers

docker ps -q -f status=exited | xargs docker rm

Remove all dangling images

docker images -f dangling=true | xargs docker rmi

Register tagged image (Example)

docker login
docker tag allure-release frankescobar/allure-docker-service:${PUBLIC_TAG}
docker push frankescobar/allure-docker-service

Register latest image (Example)

docker tag allure-release frankescobar/allure-docker-service:latest
docker push frankescobar/allure-docker-service

Download latest image registered (Example)

docker run -d  -p 5050:5050 frankescobar/allure-docker-service

Download specific tagged image registered (Example)

docker run -d -p 5050:5050 frankescobar/allure-docker-service:2.27.0

allure-docker-service's People

Contributors

abhidp avatar apulverizer avatar avin avatar blbaker3 avatar daniel-jimenezgarcia-ow avatar fescobar avatar horodchukanton avatar lazytesting avatar raymondmouthaan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

allure-docker-service's Issues

Help, not work api

I use an example from the documentation(allure-docker-service/allure-docker-api-usage/), I specified only the address of my server(allureServer = 'http://.194..24:5050')
Error returned
RESPONSE: { "meta_data": { "message": "local variable 'f' referenced before assignment" } } STATUS: 400
Tell me how to decide in which direction to look for the problem

Add endpoint to export report data (zip)

I have a specific need for an endpoint to export report data.

I work with many (many) different teams on the same mobile app and I want to aggregate all test results from each team... but I want to create views for each test cycle separated by app version.

What happens in my reality:

  1. we create a new app version (eg 1.0)
  2. teams starting testing
  3. when tests are done, we release the app
  4. we create the next app version (eg 2.0)
  5. teams starting testing and so on.

In my case, it would be very helpful if I could export each report data after tests are done. With this service, I will save report data on s3 bucket and clean the container for the new test cycle (new version).

What do you think? I can explain in more details if needed.

Thanks.

Every 10 seconds >> allure_1 | 127.0.0.1 - - [09/Jun/2020 21:39:47] "GET / HTTP/1.1" 200 -

Every 10 sends i see in docker logs this massage:

allure_1                    | 127.0.0.1 - - [09/Jun/2020 21:39:27] "GET / HTTP/1.1" 200 -
allure_1                    | 127.0.0.1 - - [09/Jun/2020 21:39:37] "GET / HTTP/1.1" 200 -
allure_1                    | 127.0.0.1 - - [09/Jun/2020 21:39:47] "GET / HTTP/1.1" 200 -
allure_1                    | 127.0.0.1 - - [09/Jun/2020 21:39:57] "GET / HTTP/1.1" 200 -
allure_1                    | 127.0.0.1 - - [09/Jun/2020 21:40:07] "GET / HTTP/1.1" 200 -

Му docker-compose config:

  allure:
    image: "frankescobar/allure-docker-service"
    environment:
      CHECK_RESULTS_EVERY_SECONDS: NONE
      KEEP_HISTORY: "TRUE"
      KEEP_HISTORY_LATEST: 20
      SERVER_URL: "http://localhost:5050/latest-report"
    ports:
      - "5050:5050"
    volumes:
      - ./allure-results:/app/allure-results
      - ./allure-reports:/app/default-reports

That is this? How i can switch off this message?

Make executor counter customizable

Hello,

In current implementation executor counter is updating automatically starting from #1
Can you, please, make an update to /generate-report request with new parameter like ?build_number={integer}.

Also make this number a part of the URL to the report:
/projects/ui-test/reports/{build_number}/index.html

In case of automatic report generation this number will be generated automatically, as it is in current version. But if generate report by API request - allow adding custom build number.

executor00

It is useful in cases when we want to link a build number from CI/CD which triggered tests with the report version in Allure.

Thanks in advance.

[proposal] Multi-Architectures support

Besides the plugin #36 , i really would like help to build Docker Manifest lists for your project to support multiple architectures (amd64, arm and arm64) for allure-docker-service. This means allure-docker-service also can be deployed on for example a Raspberry PI or PINE64. And is usable in a Docker Swarm with multi-arch nodes.

If you are interested in this and you wouldn't mind to use TravisCI as build server, to automatically build and publish the images to your Docker repo, please let me know :-).

In that case i'll do a PR with my solution.

Cheers,
Ray

Allure report unknown

I downloaded container today. Immediately after running the container all is alright.
The command was:
docker run --user="$(id -u):$(id -g)" -p 5050:5050 -e CHECK_RESULTS_EVERY_SECONDS=3 -e KEEP_HISTORY=1
-v ${PWD}/allure-results:/app/allure-results
frankescobar/all

--user="$(id -u):$(id -g)" - is because my boss install ubuntu with root for me firstly.

But after a first auto-detect of a new allure results on page of report (/allure-docker-service/projects/default/reports/latest/index.html) - ALLURE REPORT UNKNOWN.

Log of container:
"Detecting results changes for PROJECT_ID: default
Automatic Execution in Progress for PROJECT_ID: default...
Creating history on results directory for PROJECT_ID: default ...
mkdir: cannot create directory ‘/app/allure-docker-api/static/projects/default/results/history’: No such file or directory
Copying history from previous results...
cp: cannot create directory '/app/allure-docker-api/static/projects/default/results/history': No such file or directory
Creating executor.json for PROJECT_ID: default
/app/generateAllureReport.sh: line 57: /app/allure-docker-api/static/projects/default/results/executor.json: No such file or directory
Generating report for PROJECT_ID: default
Report successfully generated to /app/allure-docker-api/static/projects/default/reports/latest
Storing report history for PROJECT_ID: default
BUILD_ORDER:2
Status: 200"

Duplicate history trends

It seems like the history trend is invalid.

Here is a simple repro case using the sample data:

  1. In the allure-api-usage directory call python send_results.py
  2. In the hosted api run generate-report on the default project

After a single test run I'm seeing a trend chart like:

Notice there are two entries for #1 this seems invalid.

Running allure server allure-results-example/ locally renders it like:
image
which is what I expect to see.

It seems like the history is getting duplicated somehow.

Logs:

Starting reporting_allure_1 ... done
Attaching to reporting_allure_1
allure_1  | Not checking results automatically
allure_1  | ALLURE_VERSION: 2.13.4
allure_1  | Generating default report
allure_1  | ls: cannot access '/app/allure-docker-api/static/projects/default/reports': No such file or directory
allure_1  | Creating results directory for PROJECT_ID: default
allure_1  | Creating executor.json for PROJECT_ID: default
allure_1  | Generating report for PROJECT_ID: default
allure_1  | Report successfully generated to /app/allure-docker-api/static/projects/default/reports/latest
allure_1  | Status: 200
allure_1  | 2020-07-27 17:27:33.819:INFO::main: Logging initialized @699ms to org.eclipse.jetty.util.log.StdErrLog
allure_1  | Creating history on results directory for PROJECT_ID: default ...
allure_1  | Copying history from previous results...
allure_1  | Status: 200

This is my compose file:

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

Support URL_PREFIX

Useful for reverse proxy configuration like NGINX

    environment:
      URL_PREFIX: "/reporting"

add report summary to emailable report template

Hi can we please add a report summary to the emailable report template (default.html), similar to what is on the dashboard of the allure report.

Ideally you want the following:

  1. Test Case percentage passed overall
  2. Total number of Test cases Passed
  3. Total number of Test cases Failed
  4. Total number of test cases Broken/Skipped (if possible to do this)

Thanks

Upload results on server

My tests are executed on Gitlab CI with node image and I wish use this docker image like server to generate report and to keep history execution.
But how can I upload my results on this server from my job on Gitlab? I didn't see API for that, maybe another way to do that. Can you help me?
thanks

generateAllureReport.sh fails when no. of allure-results files increases

When the test cases increases, the resulting number of files in allure-results keeps of increasing.
Before generating new report. Allure deletes the old reports using allure generate --clean

Deleting 1000s of files at one go gives out this error:

Detecting new results...
Generating report
Report successfully generated to allure-report
Detecting new results...
/app/checkAllureResultsFiles.sh: line 24: /app/generateAllureReport.sh: Argument list too long
/app/checkAllureResultsFiles.sh: line 26: /bin/sleep: Argument list too long
/app/checkAllureResultsFiles.sh: line 20: /bin/ls: Argument list too long
Detecting new results...
Generating report
Report successfully generated to allure-report
Detecting new results...
/app/checkAllureResultsFiles.sh: line 24: /app/generateAllureReport.sh: Argument list too long
/app/checkAllureResultsFiles.sh: line 26: /bin/sleep: Argument list too long
/app/checkAllureResultsFiles.sh: line 20: /bin/ls: Argument list too long
Detecting new results...
Generating report
Report successfully generated to allure-report
Detecting new results...
/app/checkAllureResultsFiles.sh: line 24: /app/generateAllureReport.sh: Argument list too long
/app/checkAllureResultsFiles.sh: line 26: /bin/sleep: Argument list too long
/app/checkAllureResultsFiles.sh: line 20: /bin/ls: Argument list too long

Resolution: According to me, before running allure generate --clean in generateAllureReport.sh you should delete the existing files in allure-results using the resolution given here

Allure-maven-docker-plugin

hi @fescobar,

First of all, very nice to see a Docker project for Allure Reporting 👍 .

I took the opportunity to create an initially working Allure maven docker plugin for it. This plugin publishes the allure results in base64 encoding to a given Docker api.

For example http://<your_docker_server_ip>:5050/send-results.

This makes it possible to publish the results of test directly to your allure-docker-service right after unit test and/or integration tests.

Greets,
Ray

container runs as root user

The docker container is run with the root user. The kubernetes platform where I wanted to deploy this service prohibits containers from running as root user, logging in with some low-privileged user instead. This leads to some directories being inaccessible (/app/allure-report/history for example) and therefore the app can't function fully.
I believe it is considered more secure to not run as root (which is probably also why the platform is prohibiting it)

Infinite loop + 100% CPU if CHECK_RESULTS_EVERY_SECONDS: NONE

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
26147 root 20 0 19720 3208 2948 R 100,0 0,0 0:09.91 checkAllureResu

CHECK_RESULTS_EVERY_SECONDS: 3600 works fine

if [ "$CHECK_RESULTS_EVERY_SECONDS" == "NONE" ] || [ "$CHECK_RESULTS_EVERY_SECONDS" == "none" ]; then
echo "Not checking results automatically"
while true ; do continue ; done
fi

Test results are duplicated

I use the send_results.py to update the result to allure server. But I found the test result are duplicated not override for some of tests. I have to clean results every time. How can it determine if it's the same test?
Capture

Add ability to navigate between build results in Trends

Hello,

When I have a report with results from 2 or more builds I am unable to navigate between these builds by clicking on column in Trends. For Example I want to open the previous report but it's impossible.
As I know, such feature exists in Jenkins plugin for Allure report.

Please let me know if it possible to implement this in your version of Allure report.

Thanks in advance.

allure history

docker logs -f allure_allure_1

Creating history on results directory...
mkdir: cannot create directory ‘/app/allure-results/history’: Permission denied
Copying history from previous results...
cp: cannot create directory '/app/allure-results/history': Permission denied
Generating report

Fix log message: Server started at <http://172.31.0.11:4040/>. Press <Ctrl+C> to exit

But i can't open http://192.168.16.11:4040/
localhost:5050 will be correct

allure_1 | Not checking results automatically
allure_1 | ALLURE_VERSION: 2.13.3
allure_1 | Opening existing report
allure_1 | Cleaning results for PROJECT_ID: default
allure_1 | Starting web server...
allure_1 | Creating history on results directory for PROJECT_ID: default ...
allure_1 | Copying history from previous results...
allure_1 | Creating executor.json for PROJECT_ID: default
allure_1 | Generating report for PROJECT_ID: default
allure_1 | 2020-06-16 13:32:11.991:INFO::main: Logging initialized @4421ms to org.eclipse.jetty.util.log.StdErrLog
allure_1 | Can not open browser because this capability is not supported on your platform. You can use the link below to open the report manually.
allure_1 | Server started at http://172.31.0.11:4040/. Press <Ctrl+C> to exit
allure_1 | Report successfully generated to /app/allure-docker-api/static/projects/default/reports/latest
allure_1 | Status: 200

allure:
image: "frankescobar/allure-docker-service"
environment:
CHECK_RESULTS_EVERY_SECONDS: NONE
KEEP_HISTORY: "TRUE"
KEEP_HISTORY_LATEST: 20
SERVER_URL: "http://localhost:5050/latest-report"
volumes:
- ./allure-results:/app/allure-results
- ./allure-reports:/app/default-reports
ports:
- "5050:5050"
- "4040:4040"

GET /generate-report - Returns report url

Returns report_url for having bidirectional traceability.

{
   "data":{
      "allure_results_files":[
         "any_file.json"
      ],
      "report_url":"http://localhost:5050/projects/default/reports/5/index.html"
   },
   "meta_data":{
      "message":"Report successfully generated for project_id 'default'"
   }
}

UI Layer

We need a UI that allows us navigates reports for different projects and gives us a way to authentication.

Query: Add authentication to the report

Hosting this report in a container would make it available to everyone with the URL as it doesn't have any authentication method. We use Google cloud to host our service. Could you please advice what should be done to add authentication to it?

Allure-docker-service Python3

Hi Frank,

Like we discussed earlier - current images are base on Python 2.7, which has end-of-life at 01/01/2020.

I took the opportunity to build the images on Python 3 and I think the api works very nicely. Please have a look at my Allure-Docker-Service images and feel free to test them.

Let me know how they work for you and I'll PR the changes I made.

Greets,
Ray

How to check specified test round result?

I running the allure server docker in multiple projects version, the scenario is:

project id: my-project-id

Run test with total test cases = 10, and all test cases failed, then publish the allure-results directory to allure server by API call (for example, CURL or shell script), and then generate the test report by the API call (by CURL or shell script, etc.).
Then the first report in allure-server is available with URL:
http://localhost:5050/allure-docker-service/projects/my-project-id/reports/1/index.html#

The report will show all the test cases are failed, it is expected.

Run the test again that the test cases executed in step 2 that total is 10, and got the test result that all 10 test cases are passed.
Then publish the allure-results to allure-server` and generate the report by API, then we will get the second test report:
http://localhost:5050/allure-docker-service/projects/my-project-id/reports/2/index.html#

Then open the second report,
Expect:
the report displaying of this round's test information should be shown all test cases are passed.
Actually:
the report displays the testing information is aggregative testing information from all history report, so the report display failed cases that aggregate from the report history that did by step 2.

For example, below it is my the 10th round test report
image

the report list many test case failures and others passes.

actually, in the 10th round of the testing, only one test case executed and failed, the test case is below:
image

when I open this test round's report: http://192.168.1.80:5050/allure-docker-service/projects/my-project-id/reports/10/index.html#suites
I only care which test case failed in this round of test (melco.limo.LimoBookingDailyLimitTest #testADTFeatureForPatron), I don't care other round's test failed and passed (melco.limo.LimoBookingDailyLimitTest#afterMethod, actually this failed case happened in the 1st test round, fixed already), I only care about this test round's test result (pass and fail, most focus on failure).

would like to know is it possible to only display the single history report without aggregation? the url is: http://localhost:5050/allure-docker-service/projects/[project_id]reports/[history_id]/index.html#

and then the latest report of the project displays the aggregation of the test report history:
http://localhost:5050/allure-docker-service/projects/[project_id]reports/latest/index.html#

I know we can check the test case history from the tab History in the test case detail, but it is hard to debug when my current test has some test case failed to need to check the failure details.

Thanks.

15/Aug/2020 05:39:54] \"GET / HTTP/1.1\" 303 - 14 0.028 0.304\n"

hola que tal.
estoy haciendo un deployment de odoo en un cluster de kubernetes, y veo que en el log aparece la comprobación de estado 303.
15/Aug/2020 05:39:54] "GET / HTTP/1.1" 303 - 14 0.028 0.304\n"
que es lo que tengo que hacer para que me resuelva con un estado 200?
si yo configuro un LB sobre este workload, este si responde OK!, pero si lo quiero hacer con un "nodeport" el pods en el que esta corriendo resuelve con un estado HTTP 303, en lugar de un HTTP 200:
root@server01: curl -i 10.40.0.20:8069

HTTP/1.0 303 SEE OTHER

Content-Type: text/html; charset=utf-8
Content-Length: 215
Location: http://10.40.0.20:8069/web
Set-Cookie: session_id=81d12c47a0c23032c346cdb9fc1f05dd8ca1bca1; Expires=Fri, 13-Nov-2020 05:05:26 GMT; Max-Age=7776000; HttpOnly; Path=/
Server: Werkzeug/0.14.1 Python/3.7.3
Date: Sat, 15 Aug 2020 05:05:26 GMT

<title>Redirecting...</title>

Redirecting...

You should be redirected automatically to target URL: /web. If not click the link

Project Name in Report Title

Hi,

Currently html page for individual project has default title "Allure Report ".
Can it be customized to inclue project name in the title ?

Too many files causes the logging and the shell scripts to crash

When there are too many files (Over 50K, generated by 3000 tests in 5 - 10 runs) in the allure-results folder, the clean-results and clean-history APIs fail

Cleaning results
/app/cleanAllureResults.sh: line 5: /usr/bin/find: Argument list too long

I think it's unwise to expect even linux to run through these many files, but is there any way this can be sorted ?

Is it possible that the files can be batched into multiple folders?

Secondly, as the number of files increase in the folder, the response logging with list of file names becomes overbearing.
The web services have to transfer too much data to return a list of 10,000 plus filenames as response.

If this needs to be returned, there should be an env variable controlling the verbose response.
Will it make sense to only reply the count of the files present ? Which then falls back to the issue mentioned above listing so many files almost crashes the python process with memory overflow.

Permission denied /app/generateAllureReport.sh:

So when i use Single Project - Docker Compose

docker-compose up -d allure

in docker logs i see error

/app/generateAllureReport.sh: line 56: /app/allure-docker-api/static/projects/default/results/executor.json: Permission denied
Retrying call http://localhost:5050/allure-docker-service/emailable-report/render?project_id=default in 2 seconds
Could not generate report
java.nio.file.AccessDeniedException: /app/allure-docker-api/static/projects/default/reports/latest
at java.base/sun.nio.fs.UnixException.translateToIOException(Unknown Source)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(Unknown Source)
at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(Unknown Source)
at java.base/java.nio.file.Files.createDirectory(Unknown Source)
at java.base/java.nio.file.Files.createAndCheckIsDirectory(Unknown Source)
at java.base/java.nio.file.Files.createDirectories(Unknown Source)
at io.qameta.allure.CommonJsonAggregator.aggregate(CommonJsonAggregator.java:51)
at io.qameta.allure.CompositeAggregator.aggregate(CompositeAggregator.java:43)
at io.qameta.allure.ReportGenerator.aggregate(ReportGenerator.java:53)
at io.qameta.allure.ReportGenerator.generate(ReportGenerator.java:70)
at io.qameta.allure.ReportGenerator.generate(ReportGenerator.java:58)
at io.qameta.allure.Commands.generate(Commands.java:104)
at io.qameta.allure.CommandLine.run(CommandLine.java:152)
at io.qameta.allure.CommandLine$$Lambda$9/00000000AC39C980.get(Unknown Source)
at java.base/java.util.Optional.orElseGet(Unknown Source)
at io.qameta.allure.CommandLine.main(CommandLine.java:88)
ls: cannot access '/app/allure-docker-api/static/projects/default/reports/latest': No such file or directory
ls: cannot access '/app/allure-docker-api/static/projects/default/reports/*': No such file or directory

Support multipart/form-data --> POST /send-results

To avoid encoding files in base64, it would be good if we implement "multipart/form-data" to load the files directly. Like this:

curl -X POST 'http://localhost:5050/send-results?project_id=default' -H 'Content-Type: multipart/form-data' -F 'files[]=@/my-dir/allure-results/my-file-01.json' -F 'files[]=@/my-dir/allure-results/my-file-02.json' -ik

Emailable Report

I will implement the emailable report.

  • Custom reports
  • Getting reports from API (zip and html)

Question.How json reporting?

A little confused. And how to generate a report only in json, because the html page is formed as a standard. Is there any kind of ready-made solution just a bunch (formation and sending).

Why files are sand and saved in format .bin ?

Good day! Rewrote the script from Python to Groovy, send reports to the server,
but attachments do not appear, if you upload them they are in .bin format. Tell me the pictures do not need to be encrypted when sending?
image
image

task sendReports {
    group "Work Allure Server api"
    description "send results test in remote server"
    doLast {
        File f = new File("${project.buildDir}/allure-results");
        if (f.exists() && f.isDirectory()) {
            def request = new Request()
            f.eachFile {
                Reports files = new Reports(
                        file_name: it.name,
                        content_base64: it.text.bytes.encodeBase64()
                )
                request.results.add(files)
            }
            def req = new URL(gradle.allureServer+"/send-results").openConnection()
            req.setRequestMethod("POST")
            req.setRequestProperty("Content-Type", "application/json; charset=UTF-8")
            req.setDoOutput(true)
            req.getOutputStream().write(JsonOutput.toJson(request).getBytes("UTF-8"))
            logger.quiet "Status code: ${req.getResponseCode()}"
            def resp = new JsonSlurper().parseText(req.getInputStream().getText())
            logger.quiet "Response: ${resp}"
        } else {
            logger.quiet "Not folder: ${project.buildDir}/allure-results"
        }
    }
}

class Request {
    List<Reports> results = new LinkedList<>()
}
class Reports {
    String file_name
    String content_base64
}

app/generateAllureReport.sh: line 56: /app/allure-docker-api/static/projects/default/results/executor.json: Permission denied

Latest docker image gives below errors
allure_1 | /app/generateAllureReport.sh: line 56: /app/allure-docker-api/static/projects/default/results/executor.json: Permission denied
cp: cannot create directory '/app/allure-docker-api/static/projects/default/results/history': Permission denied

Its NOT reloading when new results generating.I have to restart the service to see new results.
I'm using Ubuntu 18.04

below is my docker-compose.yml
version: '3'
services:
allure:
image: "frankescobar/allure-docker-service"
environment:
CHECK_RESULTS_EVERY_SECONDS: 1
KEEP_HISTORY: "TRUE"
ports:
- "4040:4040"
- "5050:5050"
volumes:
- ./allure-results:/app/allure-results

Add a documentation on how to implement allure-docker-service into existing project

Hi,
Is it possible to add step-by-step instruction for 'dummies' of how to implement allure-docker-service into existing project? You made a great work here, but unfortunately my lack of technical skills doesn't allow me to integrate this service into my project and all the examples that are provided are made for example projects, which are differs from testing setup.

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.