Allure report hosting using S3

Allure report hosting using S3

I have extensively utilised Allure reports over the past few years, drawn to its remarkable visual capabilities that significantly aid in comprehending complex test flows. However, a persistent challenge has been how to effectively host the report.

In this blog post, my focus will be on guiding you through the process of hosting Allure reports. As a prerequisite, it’s assumed that you are familiar with how Allure reports function and have the necessary setup. If you are new to Allure reports, you can quickly get started by using the sample API automation framework outlined in my previous article.

Generating allure report

Typically, a test run generates an allure-results directory that looks like this –

And subsequently, you can generate an Allure report using allure command line like this –

allure generate allure-results --clean -o allure-report

This generates an allure-report directory with numerous sub-directories –

To open the report, simply right click on index.html and open it in your favourite browser –

However, it’s a bit tricky since there are multiple subdirectories, and an index.html file. Accessing the index.html file requires having all the subdirectories, making it challenging to easily share the report with stakeholders.

Generating single file allure html report

The good news is Allure now offers a simple command-line option for creating a single index.html file:

allure generate --clean --single-file

Once you run this, you will see allure-report directory with a single index.html file –

This makes sharing the report a breeze and opens up additional possibilities, like uploading these files to S3 and sharing links with stakeholders for easy viewing.

Allure report in S3 solution

Here’s a straightforward solution for this –

Create a dedicated AWS S3 bucket with specific bucket policies to grant access only to relevant applications (via gateway endpoint) or users. Set an object expiry for the bucket, determining the number of days before the report is automatically deleted. In this case, we’ve configured it for 100 days.

Additionally, implement a transition lifecycle for efficient cost management by transitioning files to different storage classes. In the solution here, files transition from Standard to Infrequent access after 30 days and from Infrequent access to Glacier Instant Retrieval after 60 days.

Execute the test automation suite either on a local computer or via a CI tool like Jenkins, generating a single HTML report after the tests. Post-execution, send the Allure report to the designated bucket.

Share links to these reports with the relevant stakeholders for easy access and review.

Create S3 bucket and host allure report
Here is a simple Cloudformation template to create the S3 bucket – S3Stack.yml

Please be aware that the template includes an AllowedIPAddress parameter, allowing you to specify your IP address for testing purposes. However, when implementing this solution, it’s advisable to consider alternative methods, such as allowing access via a gateway endpoint or restricting access to specific users or a CIDR range.

Once the S3 bucket creation process is complete, you’ll have a bucket that resembles the following:

To upload a report to the S3 bucket, you can utilise the AWS Command Line Interface (CLI) to copy files from the machine or CI tool where the tests are executed to the S3 bucket. Here is a sample command:

aws s3 cp 'allure-report/index.html' 's3://s3-bucket-allurereportbucket-62pkv6yqx6gp/report-030220240901.html'

The report will be stored in the S3 bucket as shown below:

Now you can use the Object URL to easily open the report –

Conclusion

In conclusion, using an S3 bucket is a great way to store and share test automation reports easily. With this method, we can store reports without depending on CI builds, and everyone can access them, not just locally. This solves the problem of sharing reports effectively. While this blog focuses on AWS S3, similar results could likely be achieved with Azure Blob Storage and Google Cloud Storage. This blog aims to give you the concept behind it all.

2 Comments
  • Dang Huy Nguyen
    Posted at 15:36h, 13 May Reply

    Seems like your bucket is public? Is it possible to limit the permission of the file i.e. only person who have read access to s3 bucket can view report in html format?

    • Prashant Mohapatra
      Posted at 10:10h, 28 June Reply

      Hi Dang,

      The example in the blog above is using a bucket which allows only specific IP address. However, as mentioned in the blog, it’s advisable to consider alternative methods for access.

      Regarding possibility to limit the permission of the file to people having access to S3 bucket, I will recommend this solution here:
      – You can create S3 bucket with bucket policy that allows the intended users/groups to access to bucket objects.
      – Share the report URL with intended users. For example URL: https://ap-southeast-2.console.aws.amazon.com/s3/object/bucket-name?prefix=test-report-name.html
      – The users will need to login to AWS console to access the link.

Leave a Reply

Discover more from Shine Solutions Group

Subscribe now to keep reading and get access to the full archive.

Continue reading