Skip to content

Commit

Permalink
☀️ Distributed Test Reporting (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sérgio Martins authored Dec 27, 2020
1 parent 694910e commit fa784bc
Show file tree
Hide file tree
Showing 37 changed files with 733 additions and 85 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Need help with ui-automation-bootstrap
name: Need help with test-automation-bootstrap
about: Ask a general how-to question.
title: ''
labels: 'type: triage/discussion'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ target/
*.iml
/reports/ExtentReport.html
/.vscode
secrets/
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center">UI Automation Bootstrap</h1>
<h1 align="center">Test Automation Bootstrap</h1>

<div align="center">

Expand All @@ -7,27 +7,27 @@
<br>

<img src="https://img.shields.io/static/v1?label=%F0%9F%8C%9F&message=If%20Useful&style=style=flat&color=BC4E99" alt="stars"/>
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/stargazers"><img src="https://img.shields.io/github/stars/sergiomartins8/ui-automation-bootstrap" alt="stars"/></a>
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/network/members"><img src="https://img.shields.io/github/forks/sergiomartins8/ui-automation-bootstrap" alt="forks"/></a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/stargazers"><img src="https://img.shields.io/github/stars/sergiomartins8/test-automation-bootstrap" alt="stars"/></a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/network/members"><img src="https://img.shields.io/github/forks/sergiomartins8/test-automation-bootstrap" alt="forks"/></a>
<a href="https://www.linkedin.com/in/sergiomartins8/"><img src="https://img.shields.io/badge/-sergiomartins8-blue?logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/sergiomartins8/" alt="linkedin"/></a>

<i>An awesome test automation framework template to jumpstart your projects!</i>
<i>A template to jumpstart test automation frameworks</i>

<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/releases"><img src="https://img.shields.io/github/v/release/sergiomartins8/ui-automation-bootstrap" alt="releases"/></a>
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/actions?query=workflow%3Arelease"><img src="https://github.com/sergiomartins8/ui-automation-bootstrap/workflows/release/badge.svg" alt="Release build"/></a>
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/issues"><img src="https://img.shields.io/github/issues/sergiomartins8/ui-automation-bootstrap" alt="issues"/></a>
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/sergiomartins8/ui-automation-bootstrap" alt="contributors"></a>
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/blob/master/LICENSE"><img src="https://img.shields.io/github/license/sergiomartins8/ui-automation-bootstrap" alt="license"/></a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/releases"><img src="https://img.shields.io/github/v/release/sergiomartins8/test-automation-bootstrap" alt="releases"/></a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/actions?query=workflow%3Arelease"><img src="https://github.com/sergiomartins8/test-automation-bootstrap/workflows/release/badge.svg" alt="Release build"/></a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/issues"><img src="https://img.shields.io/github/issues/sergiomartins8/test-automation-bootstrap" alt="issues"/></a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/sergiomartins8/test-automation-bootstrap" alt="contributors"></a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/blob/master/LICENSE"><img src="https://img.shields.io/github/license/sergiomartins8/test-automation-bootstrap" alt="license"/></a>

<p>
<a href="docs/documentation.md"><strong>Explore the docs »</strong></a>
<br />
<br />
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/issues">Ask Question</a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/issues">Ask Question</a>
·
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/issues">Report Bug</a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/issues">Report Bug</a>
·
<a href="https://github.com/sergiomartins8/ui-automation-bootstrap/issues">Request Feature</a>
<a href="https://github.com/sergiomartins8/test-automation-bootstrap/issues">Request Feature</a>
</p>

</div>
Expand All @@ -38,33 +38,32 @@
* [Changelog](#changelog)
* [Contributing](#contributing)

## What does a _ui-automation-bootstrap_ test look like?
## What does a _test-automation-bootstrap_ test look like?
```java
@Test
@Mock(clazz = MockExampleModel.class)
public void shouldPerformSearchSuccessfully() {
open("http://google.com");
open("https://google.com");

googleSearchPage
.searchComponent()
.searchFor("mock");

googleResultsPage
.searchFor("mock")
.searchComponent()
.self()
.shouldHave(value("mock"));
}
```

## About
A simple and effective template to quickstart any ui test automation framework in no time!
A simple and effective template to quickstart any test automation framework in no time.

##### Using the goods of
* _[Selenide](https://github.com/selenide/selenide)_ - A selenium wrapper for concise UI tests
* _[ExtentReports](https://extentreports.com/)_ - Provides full test reports. Takes screenshots upon test failure by default
* _[SonarQube](https://www.sonarqube.org/)_ 🐳 - A static analysis tool
* _[SeleniumGrid](https://github.com/SeleniumHQ/docker-selenium)_ 🐳 - Allows to scale the test execution as well as providing the required browser types
* _[Checkstyle](https://maven.apache.org/plugins/maven-checkstyle-plugin/)_ - Code linter
* _[ELK Stack](https://www.elastic.co/blog/elastic-stack-7-10-1-released)_ 🐳 - Enables distributed log aggregation and visualization

> _🐳 stands for dockerized_
Expand All @@ -85,4 +84,4 @@ Available [here](/docs/CHANGELOG.md).
## Contributing
Open source from the first commit ✨

Dive into ui-automation-bootstrap's [contribution guide](docs/CONTRIBUTING.md).
Dive into test-automation-bootstrap's [contribution guide](docs/CONTRIBUTING.md).
32 changes: 16 additions & 16 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
## Change Log

### v1.6.1 (2020/07/02 08:53 +00:00)
- [#29](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/29) 🐛 Fix logback configuration to default package (#29) (@sergiomartins8)
- [#29](https://github.com/sergiomartins8/test-automation-bootstrap/pull/29) 🐛 Fix logback configuration to default package (#29) (@sergiomartins8)

### v1.6.0 (2020/06/22 18:02 +00:00)
- [#27](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/27) ⬆️ Upgrade to selenide:5.12.2 (#27) (@sergiomartins8)
- [#27](https://github.com/sergiomartins8/test-automation-bootstrap/pull/27) ⬆️ Upgrade to selenide:5.12.2 (#27) (@sergiomartins8)

### v1.5.0 (2020/05/26 10:16 +00:00)
- [#26](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/26) ⬆️ Upgrade to selenide:5.12.1 (#26) (@sergiomartins8)
- [#25](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/25) 🔥 Revamp structure (#25) (@sergiomartins8)
- [#26](https://github.com/sergiomartins8/test-automation-bootstrap/pull/26) ⬆️ Upgrade to selenide:5.12.1 (#26) (@sergiomartins8)
- [#25](https://github.com/sergiomartins8/test-automation-bootstrap/pull/25) 🔥 Revamp structure (#25) (@sergiomartins8)

### v1.4.0 (2020/05/24 14:38 +00:00)
- [#24](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/24) ☀️ Travis Integration (#24) (@sergiomartins8)
- [#24](https://github.com/sergiomartins8/test-automation-bootstrap/pull/24) ☀️ Travis Integration (#24) (@sergiomartins8)

### v1.3.0 (2020/05/21 08:32 +00:00)
- [#23](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/23) ☀️ Jenkins Integration (#23) (@sergiomartins8)
- [#22](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/22) 🤖 Revamp CI/CD pipelines (#22) (@sergiomartins8)
- [#23](https://github.com/sergiomartins8/test-automation-bootstrap/pull/23) ☀️ Jenkins Integration (#23) (@sergiomartins8)
- [#22](https://github.com/sergiomartins8/test-automation-bootstrap/pull/22) 🤖 Revamp CI/CD pipelines (#22) (@sergiomartins8)

### v1.2.0 (2020/05/11 15:28 +00:00)
- [#21](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/21) ✅ Refactor test examples (#21) (@sergiomartins8)
- [#21](https://github.com/sergiomartins8/test-automation-bootstrap/pull/21) ✅ Refactor test examples (#21) (@sergiomartins8)

### v1.1.0 (2020/05/09 17:49 +00:00)
- [#20](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/20) 🐛 Fix firefox integration tests (#20) (@sergiomartins8)
- [#20](https://github.com/sergiomartins8/test-automation-bootstrap/pull/20) 🐛 Fix firefox integration tests (#20) (@sergiomartins8)

### v1.0.0 (2020/05/06 06:59 +00:00)
- [#18](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/18) ☀️ Moving to archetype (#18) (@sergiomartins8)
- [#16](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/16) 🤖 Github actions CI (#16) (Sérgio Martins)
- [#15](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/15) CI/CD - github actions (#15) (Sérgio Martins)
- [#13](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/13) revamp current system properties management (#13) (Sérgio Martins)
- [#10](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/10) revamp mock listener and mock model (#10) (Sérgio Martins)
- [#8](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/8) Upgrade Extent Reports to version 4 (#8) (Sérgio Martins)
- [#7](https://github.com/sergiomartins8/ui-automation-bootstrap/pull/7) add browser to system properties (#7) (Sérgio Martins)
- [#18](https://github.com/sergiomartins8/test-automation-bootstrap/pull/18) ☀️ Moving to archetype (#18) (@sergiomartins8)
- [#16](https://github.com/sergiomartins8/test-automation-bootstrap/pull/16) 🤖 Github actions CI (#16) (Sérgio Martins)
- [#15](https://github.com/sergiomartins8/test-automation-bootstrap/pull/15) CI/CD - github actions (#15) (Sérgio Martins)
- [#13](https://github.com/sergiomartins8/test-automation-bootstrap/pull/13) revamp current system properties management (#13) (Sérgio Martins)
- [#10](https://github.com/sergiomartins8/test-automation-bootstrap/pull/10) revamp mock listener and mock model (#10) (Sérgio Martins)
- [#8](https://github.com/sergiomartins8/test-automation-bootstrap/pull/8) Upgrade Extent Reports to version 4 (#8) (Sérgio Martins)
- [#7](https://github.com/sergiomartins8/test-automation-bootstrap/pull/7) add browser to system properties (#7) (Sérgio Martins)
14 changes: 7 additions & 7 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
👍🎉 First off, thanks for taking the time to contribute! 🎉👍

The following is a set of guidelines for contributing to ui-automation-bootstrap.
The following is a set of guidelines for contributing to test-automation-bootstrap.
These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

#### Table of contents
Expand All @@ -18,21 +18,21 @@ These are mostly guidelines, not rules. Use your best judgment, and feel free to

## I just have a question!

Questions and/or discussions are tracked as [issues](https://github.com/sergiomartins8/ui-automation-bootstrap/issues).
Fill in [the template](../.github/ISSUE_TEMPLATE/need-help-with-ui-automation-bootstrap.md).
Questions and/or discussions are tracked as [issues](https://github.com/sergiomartins8/test-automation-bootstrap/issues).
Fill in [the template](../.github/ISSUE_TEMPLATE/need-help-with-test-automation-bootstrap.md).

## How can I contribute?

### Reporting bugs

Bug reports are tracked as [issues](https://github.com/sergiomartins8/ui-automation-bootstrap/issues).
Bug reports are tracked as [issues](https://github.com/sergiomartins8/test-automation-bootstrap/issues).
Fill in [the template](../.github/ISSUE_TEMPLATE/bug_report.md), the information it asks for helps to resolve issues faster.

> **Note:** If you find a **closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one.
### Suggesting Enhancements

Enhancement suggestions are tracked as [issues](https://github.com/sergiomartins8/ui-automation-bootstrap/issues).
Enhancement suggestions are tracked as [issues](https://github.com/sergiomartins8/test-automation-bootstrap/issues).
Fill in [the template](../.github/ISSUE_TEMPLATE/enhancement.md), including the steps that you imagine you would take if the feature you're requesting existed.

### Your first code contribution
Expand All @@ -46,9 +46,9 @@ Unsure where to begin contributing? You can start by looking for **utils** metho

The process described here has several goals:

- Maintain ui-automation-bootstrap's quality
- Maintain test-automation-bootstrap's quality
- Fix problems that are important to users
- Engage the community in working toward the best possible ui automation template ✨
- Engage the community in working toward the best possible test automation template ✨
- Enable a sustainable system for maintaining and review contributions

Please follow these steps to have your contribution considered:
Expand Down
76 changes: 72 additions & 4 deletions docs/documentation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The following is a set of guidelines and documentation to better experience the ui-automation-bootstrap's features.
The following is a set of guidelines and documentation to better experience the test-automation-bootstrap's features.
These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

#### Table of contents
Expand All @@ -18,8 +18,10 @@ These are mostly guidelines, not rules. Use your best judgment, and feel free to

[Jenkins](#jenkins-)

[ELK Stack](#elk-stack)

## POM - the Page Object Model
The *ui-automation-bootstrap* uses the Page Object Model (**POM**) (https://martinfowler.com/bliki/PageObject.html) to structure code.
The *test-automation-bootstrap* uses the Page Object Model (**POM**) (https://martinfowler.com/bliki/PageObject.html) to structure code.

![](img/structure.gif)

Expand All @@ -45,7 +47,7 @@ You can run tests in parallel, configuring your suite file or with system proper

##### Example
```shell script
$ mvn clean test -Dparallel=<method-name> -DthreadCount=<n-threads>
$ mvn clean test -Dparallel=<method-name> -Dthread.count=<n-threads>
```

## Extent Reports
Expand Down Expand Up @@ -125,7 +127,7 @@ $ mvn -B clean verify sonar:sonar \
```

## Jenkins 🤖
There is a [jenkinsfile](../Jenkinsfile) example available. Use it to get started. However, it might need some tailoring.
There is a [Jenkinsfile](../Jenkinsfile) example available. Use it to get started. However, it might need some tailoring.

##### Snippet
```groovy
Expand Down Expand Up @@ -155,3 +157,69 @@ podTemplate(label: "jenkins-slave-base-pod", serviceAccount: "jenkins", containe
```

> The example above uses Jenkins on Kubernetes. Follow this [article](https://medium.com/@sergiomartins8/highly-scalable-jenkins-on-minikube-8cc289a31850) to have a similar environment in no time!
>
> Furthermore, the source code for the base image is open source and available [here](https://github.com/sergiomartins8/jenkins-slave-base).
## ELK Stack

> Check out the related distributed test reporting article on [medium](https://medium.com/@sergiomartins8/distributed-test-reporting-using-elk-stack-97dd699d6bb4).
Elastic Stack (**ELK**) Docker Composition, preconfigured with **Security**, **Monitoring**, and **Tools**; Up with a Single Command.
Based on [Official Elastic Docker Images](https://www.docker.elastic.co/)

Stack Version: [7.10.1](https://www.elastic.co/blog/elastic-stack-7-10-1-released)
> You can change Elastic Stack version by setting `ELK_VERSION` in `.env` file and rebuild your images. Any version >= 7.0.0 is compatible with this template.
This allows you to build your own distributed test reporting dashboards using pie charts, timeline analysis, and all other kinds of desired visualizations.
The options are endless.

##### Example 1
![](img/elk_1.png)

##### Example 2
![](img/elk_2.png)

#### Requirements
- [Docker 17.05 or higher](https://docs.docker.com/install/)
- [Docker-Compose 3 or higher](https://docs.docker.com/compose/install/)
- 4GB RAM (For Windows and MacOS make sure Docker's VM has more than 4GB+ memory.)

#### Setup
1. Initialize Elasticsearch Keystore and TLS Self-Signed Certificates
```shell script
$ make setup
```
> **For Linux's docker hosts only**. By default virtual memory [is not enough](https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html) so run the next command as root `sysctl -w vm.max_map_count=262144`
1. Start Elastic Stack
```shell script
$ make elk <OR> $ docker-compose up -d
```
1. Visit Kibana at [https://localhost:5601](https://localhost:5601) or `https://<your_public_ip>:5601`

Default Username: `elastic`, Password: `kibana`

> - Notice that Kibana is configured to use HTTPS, so you'll need to write `https://` before `localhost:5601` in the browser.
> - Modify `.env` file for your needs, most importantly `ELASTIC_PASSWORD` that setup your superuser `elastic`'s password, `ELASTICSEARCH_HEAP` & `LOGSTASH_HEAP` for Elasticsearch & Logstash Heap Size.
Whatever your host (e.g AWS EC2, Azure, DigitalOcean, or on-premise server), once you expose your host to the network, ELK component will be accessible on their respective ports.

#### Setting Up Keystore
You can extend the Keystore generation script by adding keys to `./setup/keystore.sh` script. (e.g Add S3 Snapshot Repository Credentials)

To Re-generate Keystore:
```shell script
$ make keystore
```

#### Enable SSL on HTTP
By default, Transport Layer has SSL enabled as well as SSL on HTTP layer.

> ⚠️ Thus, as SSL on HTTP layer is enabled, it will require that all clients that connect to Elasticsearch have to configure SSL connection for HTTP, this includes all the current configured parts of the stack (e.g Logstash, Kibana, Curator, etc) plus any library/binding that connects to Elasticsearch from your application code.
In order to send out your logs to logstash use the [DistributedReportListener](../src/test/java/io/company/utils/listeners/DistributedReportListener.java) class.
It has a base implementation, but tailored it accordingly.

##### Example
```shell script
$ mvn clean test -Dlistener=${package}/utils/listeners/DistributedReportListener.java
```
Binary file added docs/img/elk_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/elk_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions elk-stack/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
COMPOSE_PROJECT_NAME=elastic
ELK_VERSION=7.10.1

#----------- Resources --------------------------#
ELASTICSEARCH_HEAP=256m
LOGSTASH_HEAP=256m

#----------- Hosts and Ports --------------------#
# To be able to further "de-compose" the compose files, get hostnames from environment variables instead.

ELASTICSEARCH_HOST=elasticsearch
ELASTICSEARCH_PORT=9200

KIBANA_HOST=kibana
KIBANA_PORT=5601

#----------- Credientals ------------------------#
# Username & Password for Admin Elasticsearch cluster.
# This is used to set the password at setup, and used by others to connect to Elasticsearch at runtime.
ELASTIC_USERNAME=elastic
ELASTIC_PASSWORD=kibana
AWS_ACCESS_KEY_ID=nottherealid
AWS_SECRET_ACCESS_KEY=notherealsecret

#----------- Cluster ----------------------------#
ELASTIC_CLUSTER_NAME=elastdocker-cluster
ELASTIC_INIT_MASTER_NODE=elastdocker-node-0
ELASTIC_NODE_NAME=elastdocker-node-0

# Hostnames of master eligble elasticsearch instances. (matches compose generated host name)
ELASTIC_DISCOVERY_SEEDS=elasticsearch
Loading

0 comments on commit fa784bc

Please sign in to comment.