Skip to content

Commit

Permalink
Integrating with maven central and adding some simple metrics (#47)
Browse files Browse the repository at this point in the history
* Integrating with maven central and adding some simple metrics

* Activating profile for oosrh

* forcing release test

* [maven-release-plugin] prepare release selenium-pom-framework-1.0.2

* [maven-release-plugin] prepare for next development iteration

* [maven-release-plugin] prepare release selenium-pom-framework-1.0.2

* Testing release

* Adding new deployment techniques

* Updating env var names

* Changes to pom and travis

* [maven-release-plugin] prepare release selenium-pom-framework-1.0.2

* [maven-release-plugin] prepare release selenium-pom-framework-1.0.2

* [maven-release-plugin] prepare release selenium-pom-framework-1.0.3

* [maven-release-plugin] prepare for next development iteration

* Bumping sonatype staging plugin version to latest

* Bumping stagung plugin

* [maven-release-plugin] prepare release selenium-pom-framework-1.0.4

* [maven-release-plugin] prepare for next development iteration

* Adding missing pom info

* [maven-release-plugin] prepare release selenium-pom-framework-1.0.6

* [maven-release-plugin] prepare for next development iteration

* [maven-release-plugin] prepare release selenium-pom-framework-1.0.7

* [maven-release-plugin] prepare for next development iteration

* README changes

* Adding contributors to pom.  Updating README with latest version info and how tos for the instrumetnation and metrics bits.  Adding configruation for metrics config.

* Adding new instrumetnation points

* Using graphite config from config file

* Fixing some codacy issues

* Fixing some codacy issues

Co-authored-by: travis-ci <travis@travis-ci.org>
  • Loading branch information
stevewalton28 and travis-ci authored Mar 28, 2020
1 parent 3245986 commit dd1c6c5
Show file tree
Hide file tree
Showing 22 changed files with 760 additions and 193 deletions.
27 changes: 10 additions & 17 deletions .travis.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,26 @@
http://maven.apache.org/xsd/settings-1.0.0.xsd">

<activeProfiles>
<activeProfile>github</activeProfile>
<activeProfile>ossrh</activeProfile>
</activeProfiles>

<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/digital-delivery-academy/selenium-pom-framework</url>
</repository>
</repositories>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.passphrase>${GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
<id>ossrh</id>
<username>stevewalton28</username>
<password>${env.GITHUB_PACKAGE_DEPLOY_TOKEN}</password>
<password>${SONATYPE_PASSWORD}</password>
</server>
</servers>
</settings>
69 changes: 39 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
dist: trusty

language: java

jdk:
- openjdk12

- openjdk12
cache:
directories:
- $HOME/.m2

- "$HOME/.m2"
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start

- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3
before_install:
- "cp .travis.settings.xml $HOME/.m2/settings.xml"
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
- google-chrome-stable --remote-debugging-port=9222 http://localhost &
- chmod ugo+x scripts/publish-javadocs-to-github-pages.sh

- openssl aes-256-cbc -K $encrypted_25a884814f46_key -iv $encrypted_25a884814f46_iv
-in deployment/signingkey.asc.enc -out deployment/signingkey.asc -d
- cp .travis.settings.xml $HOME/.m2/settings.xml
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile
--background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
- google-chrome-stable --remote-debugging-port=9222 http://localhost &
- chmod ugo+x scripts/publish-javadocs-to-github-pages.sh
addons:
firefox: latest

install:
- mvn clean install -Dmaven.javadoc.skip=true -B -V

- mvn clean install -Dmaven.javadoc.skip=true -B -V
after_success:
- gpg2 --keyring=$TRAVIS_BUILD_DIR/pubring.gpg --no-default-keyring --import deployment/signingkey.asc
- gpg2 --allow-secret-key-import --keyring=$TRAVIS_BUILD_DIR/secring.gpg --no-default-keyring
--import deployment/signingkey.asc
- mvn clean deploy -Dgpg.executable=gpg2 -Dgpg.keyname=5F84CD1775351968CABF0B0D779D2423E1D24D89
-Dgpg.passphrase=$GPG_PASSPHRASE -Dgpg.publicKeyring=$TRAVIS_BUILD_DIR/pubring.gpg -Dgpg.secretKeyring=$TRAVIS_BUILD_DIR/secring.gpg
deploy:
- provider: script
script: mvn deploy -DskipTests -Dregistry=https://maven.pkg.github.com/digital-delivery-academy -Dtoken=$GITHUB_PACKAGE_DEPLOY_TOKEN
on:
tags: true
- provider: script
script: mvn test com.gavinmogan:codacy-maven-plugin:coverage -DcoverageReportFile=target/site/jacoco/jacoco.xml -DprojectToken=$CODACY_PROJECT_TOKEN -DapiToken=$CODACY_API_TOKEN
on:
branch: master
- provider: script
script: bash scripts/publish-javadocs-to-github-pages.sh
on:
tags: true
- provider: script
script: mvn test com.gavinmogan:codacy-maven-plugin:coverage -DcoverageReportFile=target/site/jacoco/jacoco.xml
-DprojectToken=$CODACY_PROJECT_TOKEN -DapiToken=$CODACY_API_TOKEN
on:
branch: master
- provider: script
script: bash scripts/publish-javadocs-to-github-pages.sh
on:
tags: true
- provider: script
script:
- mvn release:prepare
- mvn release:perform
on:
tags: true
env:
global:
- secure: cM73yz9Rj/wlGB+iIKnerkMhOH6dwMw97e0eNN8qIaA3x6Wp9JGwLOkctQTkOB3HgTsaO6I6/eIWylb8bzdQhu08zZvEmAGr8MXSRNtQm5l2zdx4uovwp8VAr2DBFmk1uyOXErwqsTo7ofSkjDcjNN57XR28frFYAuYAqa0+M9hMC4PWkawI22k9LgLA8LtR0Yzkto8eH1bw74YPMXhjjBZ6b/BTUqAOkwWbGujUmLtT7VeEMxKGJwgyoCw2+UKRtdAU+/E0LCAU2DuxYTtn00Om7GDV5eXZu58s+mRLMRG2038U/Bam4dTy6ZNrKjHlR3l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fi1YWwQpvryT6cH4KJky7MLegKXJ3kn8UwNCW8vU76VZcUiIYPg0WLsxXOu6gDMsDfnm2XX69uyIJTNw6Q2pfd8dKmJomZFRoIs5AD9hjU0iukVRL/Wlq3eU4NLFfToPLsv5NbckW1IjPYCvlVTUviyhACr+veDX8wIADEtQoqD4KxUnYqS0IZjFJwWGngIYe+YX4lW+qU3IIsuHxOCivkESkMQci2/eL8/gNqKbF8EFza2rzaDuJdaBj2etTxH6UoAJ0P9ZzsY0Kku7rVDSjqg5zZ5mo/OsQLCPkuXf/MKCUp4oJ8z2wxcEXe5YIO9G8S3sNaLIAQNLTwjfGFBP9YVWhZng1OBdLvh8+/r3kuPlilEu7H4M8iQ5zl9iV4SiguLOzcbV0hDm6F2UnUhvUwy8PJoDKVXJjW7PbYMBwGKnOu7QFG7LrLVCM7zORHfg+iu317yFdZLF+Jn+mBu5WGY+Jgr3rJnkgC7s5mQ+KKrWeFc/fZirykC8RbCkuss5KeQvkIiLtExvHP/1jPld/mhM2ItfCR6REVwHCN7zBYK56S8fa+oxT4ozc2p6Ked/F+QrrS0LekWcS0QnWYD5/Bp0iJVjL1HMv0vOKJimbmSf2athuFGA1gkTpBPKG7opSZf58=
135 changes: 85 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<!-- ALL-CONTRIBUTORS-BADGE:END -->

**We've released version 1.0.0!**
**We've released version 1.0.0! And we've moved to Maven Central hosting and added instrumentation**

This toolkit is really a culmination of 10 years of working with teams building automated UI checks with Selenium. We've found time and again that we refactor or rewrite "frameworks" that wrap the entirity of the Selenium API (to little benefit). On top of this, we see so much brittle code that we wanted to put something out there that people could use and benefit from our experience. As a result, this toolkit provides an simple, lightweight (and well structured) way to launch, control and configure checks for Selenium/WebDriver in Java. It's a curation of all of the little libraries and fixes we've used over the years. So if you're at the start of your automation journey or you're just bored of writing the same "framework" over and over again, you're in the right place.

Expand All @@ -20,13 +20,12 @@ You'll find no junk (hopefully) here, but it's a fairly opinionated approach:
- We provide random test data generators from Mockneat (https://github.com/nomemory/mockneat) and UK Gov (https://github.com/dwp/nino-format-validation) as well as some of our own (for dates and stuff)
- There's an externalised (and overridable) configuration system, based on JSON
- We handle providing JUnit (we use version 5), Selenium and Hamcrest (for writing good assertions)
- The framework is instrumented to measure execution time of internals, and these metrics are available via JMX or Graphite.
- Our framework is unit and integration checked as well as monitored for code quality; we treat this as a production code base, not a second class citizen.
- We have a (developing) open roadmap in GitHub Issues (click the Issues tab to see what we have so far)
- We have a (developing) open road map in GitHub Issues (click the Issues tab to see what we have so far)

Coming soon:
- SauceLabs and BrowserStack configuration (issues #2 and #3).
- Instrumentation of the framework components to help visualise slow or under performing checks over time (issue #44).
- Published artefacts to Maven Central (so you can get the framework without a GitHub membership) (issue #27).
- Expand documentation and tutorials (issue #45)
- And lots more marked in the issues list: https://github.com/digital-delivery-academy/selenium-pom-framework/issues

Expand All @@ -47,71 +46,107 @@ submit an issue ticket.
## Documentation

- A full reference guide is here: https://github.com/digital-delivery-academy/selenium-pom-framework/wiki
- Technical reference documentation (javadocs) are here: https://digital-delivery-academy.github.io/selenium-pom-framework/javadoc-1.0.1
- Technical reference documentation (javadocs) are here: https://digital-delivery-academy.github.io/selenium-pom-framework/javadoc-1.0.7

## Example checks/project

See https://github.com/digital-delivery-academy/selenium-pom-example repository for an example of how to write Selenium checks using the Page Object Model. This repository uses this framework.

## Usage

Put this in your POM.xml.
This project is published to Maven Central, so you just need to put this in your POM.xml.

```
<dependency>
<groupId>uk.co.evoco</groupId>
<artifactId>selenium-pom-framework</artifactId>
<version>1.0.1</version>
<version>1.0.7</version>
</dependency>
```

You need to tell Maven how to access GitHub packages. So you need to edit your `settings.xml`.
**Note:** we used to publish releases to GitHub packages (which you can see if you click Packages above). This was restrictive because people HAD to have a GitHub account to use it, and had to mess around with their M2 settings. Maven Central was the right answer to this problem.
- You can see historic releases in the Packages tab above
- You can see all new releases on Maven Central here: https://search.maven.org/artifact/uk.co.evoco/selenium-pom-framework (we'll keep the Releases tab updated on this page, and we'll keep the latest version details in the README)

Typically you can do this by looking in `~/.m2/settings.xml`. You will need a GitHub Personal Access Token, which
you can do here (once you're logged in): https://github.com/settings/tokens
We skipped through a few minor versions setting up the Maven Central release, so there is no effective gap between 1.0.2 and 1.0.7.

An example configuration (`settings.xml`) would be:
## Instrumentation and metrics
The framework is instrumented with Dropwizard Metrics which has two reporters; JMX and Graphite.

To view the JMX reports, the JVM still needs to be running. You can access by running from a command line `jconsole` and then connecting to the JVM that is running the tests.
From `jconsole` you will need to open `MBeans` and then `metrics` to see the metrics that are being produced.

**Note:** We're probably going to remove JMX in coming releases because the nature of the framework is that it runs and then exits. When the container closes, the metrics go with it (unless we add something like Graphite to back it). We'll see. It'll be fine during debugging though. We'd recommend looking at the next bit about Graphite and Grafana.

Graphite is a much more powerful way to see performance of the framework over time, and to see where your tests are spending the most time. Here's some instructions about how to get started using Docker.

**Note:** Obviously you have to have `docker` installed. I'm sure you can Google that :)

We're going to setup `docker` containers for `graphite` which is essentially a cool way to track metrics over time and `grafana` which is a sexy way to visualise things and create some dashboards. We need to link these two containers so that they can access each other
and we're going to use the official containers from Graphite and Grafana themselves to get the latest versions. First up, we need a `docker` network:

`docker network create graphite_grafana`

Then we need to grab `graphite`:

```
docker run -d \
--name graphite \
--restart=always \
--net graphite_grafana \
-p 80:80 \
-p 2003-2004:2003-2004 \
-p 2023-2024:2023-2024 \
-p 8125:8125/udp \
-p 8126:8126 \
graphiteapp/graphite-statsd
```

And finally we need to grab `grafana`:

`docker run -d --name=grafana -p 3000:3000 --net graphite_grafana grafana/grafana`

Once all of these commands have finished if you run `docker ps` you should end up with something like the following:

```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
acbce542bd1f graphiteapp/graphite-statsd "/entrypoint" 4 seconds ago Up 4 seconds 0.0.0.0:80->80/tcp, 0.0.0.0:2003-2004->2003-2004/tcp, 2013-2014/tcp, 8080/tcp, 0.0.0.0:2023-2024->2023-2024/tcp, 0.0.0.0:8126->8126/tcp, 8125/tcp, 0.0.0.0:8125->8125/udp graphite
ed8a7fcdbfc3 grafana/grafana "/run.sh" 2 minutes ago Up 2 minutes 0.0.0.0:3000->3000/tcp grafana
```

Now open up a browser window and get the two web interfaces loaded up:

Graphite: http://localhost:80

Grafana: http://localhost:3000

Grafana is where we're going to do most of our work now. Let's set up the data source first. From the home page in Grafana click "Add data source".
Then select "Graphite" from the list of sources.

Give an appropriate name (selenium-pom-framework for example). The following fields and values follow:

```
URL: http://graphite:80
```

Click `Save & Test`. Everything should go green, and Graphite and Grafana should now be connected. Now you can run tests and all of the metrics will be put out to Graphite and you can create dashboards to see
where your tests are going slowly.

There's a sample dashboard in this repo in `grafana-dashboard-examples/sample-dashboard.json` that you can import to get started.

If you're deploying this else where (i.e. not locally) you can configure connection details in the configuration object (see below).

```
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/digital-delivery-academy/selenium-pom-framework</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>GITHUB_USERNAME</username>
<password>GITHUB_PERSONAL_ACCESS_TOKEN_FOR_PACKAGES</password>
</server>
</servers>
</settings>
"metrics": {
"jmx": {
"enabled": false
},
"graphite": {
"enabled": true,
"host": "localhost",
"port": 2003
}
}
```

## References/thanks
Expand Down
Binary file added deployment/signingkey.asc.enc
Binary file not shown.
Loading

0 comments on commit dd1c6c5

Please sign in to comment.