Skip to content

Commit dd1c6c5

Browse files
stevewalton28travis-ci
andauthored
Integrating with maven central and adding some simple metrics (#47)
* 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 <[email protected]>
1 parent 3245986 commit dd1c6c5

File tree

22 files changed

+760
-193
lines changed

22 files changed

+760
-193
lines changed

.travis.settings.xml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,26 @@
44
http://maven.apache.org/xsd/settings-1.0.0.xsd">
55

66
<activeProfiles>
7-
<activeProfile>github</activeProfile>
7+
<activeProfile>ossrh</activeProfile>
88
</activeProfiles>
99

1010
<profiles>
1111
<profile>
12-
<id>github</id>
13-
<repositories>
14-
<repository>
15-
<id>central</id>
16-
<url>https://repo1.maven.org/maven2</url>
17-
<releases><enabled>true</enabled></releases>
18-
<snapshots><enabled>false</enabled></snapshots>
19-
</repository>
20-
<repository>
21-
<id>github</id>
22-
<name>GitHub OWNER Apache Maven Packages</name>
23-
<url>https://maven.pkg.github.com/digital-delivery-academy/selenium-pom-framework</url>
24-
</repository>
25-
</repositories>
12+
<id>ossrh</id>
13+
<activation>
14+
<activeByDefault>true</activeByDefault>
15+
</activation>
16+
<properties>
17+
<gpg.passphrase>${GPG_PASSPHRASE}</gpg.passphrase>
18+
</properties>
2619
</profile>
2720
</profiles>
2821

2922
<servers>
3023
<server>
31-
<id>github</id>
24+
<id>ossrh</id>
3225
<username>stevewalton28</username>
33-
<password>${env.GITHUB_PACKAGE_DEPLOY_TOKEN}</password>
26+
<password>${SONATYPE_PASSWORD}</password>
3427
</server>
3528
</servers>
3629
</settings>

.travis.yml

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
11
dist: trusty
2-
32
language: java
4-
53
jdk:
6-
- openjdk12
7-
4+
- openjdk12
85
cache:
96
directories:
10-
- $HOME/.m2
11-
7+
- "$HOME/.m2"
128
before_script:
13-
- "export DISPLAY=:99.0"
14-
- "sh -e /etc/init.d/xvfb start"
15-
- sleep 3 # give xvfb some time to start
16-
9+
- export DISPLAY=:99.0
10+
- sh -e /etc/init.d/xvfb start
11+
- sleep 3
1712
before_install:
18-
- "cp .travis.settings.xml $HOME/.m2/settings.xml"
19-
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
20-
- google-chrome-stable --remote-debugging-port=9222 http://localhost &
21-
- chmod ugo+x scripts/publish-javadocs-to-github-pages.sh
22-
13+
- openssl aes-256-cbc -K $encrypted_25a884814f46_key -iv $encrypted_25a884814f46_iv
14+
-in deployment/signingkey.asc.enc -out deployment/signingkey.asc -d
15+
- cp .travis.settings.xml $HOME/.m2/settings.xml
16+
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile
17+
--background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
18+
- google-chrome-stable --remote-debugging-port=9222 http://localhost &
19+
- chmod ugo+x scripts/publish-javadocs-to-github-pages.sh
2320
addons:
2421
firefox: latest
25-
2622
install:
27-
- mvn clean install -Dmaven.javadoc.skip=true -B -V
28-
23+
- mvn clean install -Dmaven.javadoc.skip=true -B -V
24+
after_success:
25+
- gpg2 --keyring=$TRAVIS_BUILD_DIR/pubring.gpg --no-default-keyring --import deployment/signingkey.asc
26+
- gpg2 --allow-secret-key-import --keyring=$TRAVIS_BUILD_DIR/secring.gpg --no-default-keyring
27+
--import deployment/signingkey.asc
28+
- mvn clean deploy -Dgpg.executable=gpg2 -Dgpg.keyname=5F84CD1775351968CABF0B0D779D2423E1D24D89
29+
-Dgpg.passphrase=$GPG_PASSPHRASE -Dgpg.publicKeyring=$TRAVIS_BUILD_DIR/pubring.gpg -Dgpg.secretKeyring=$TRAVIS_BUILD_DIR/secring.gpg
2930
deploy:
30-
- provider: script
31-
script: mvn deploy -DskipTests -Dregistry=https://maven.pkg.github.com/digital-delivery-academy -Dtoken=$GITHUB_PACKAGE_DEPLOY_TOKEN
32-
on:
33-
tags: true
34-
- provider: script
35-
script: mvn test com.gavinmogan:codacy-maven-plugin:coverage -DcoverageReportFile=target/site/jacoco/jacoco.xml -DprojectToken=$CODACY_PROJECT_TOKEN -DapiToken=$CODACY_API_TOKEN
36-
on:
37-
branch: master
38-
- provider: script
39-
script: bash scripts/publish-javadocs-to-github-pages.sh
40-
on:
41-
tags: true
31+
- provider: script
32+
script: mvn test com.gavinmogan:codacy-maven-plugin:coverage -DcoverageReportFile=target/site/jacoco/jacoco.xml
33+
-DprojectToken=$CODACY_PROJECT_TOKEN -DapiToken=$CODACY_API_TOKEN
34+
on:
35+
branch: master
36+
- provider: script
37+
script: bash scripts/publish-javadocs-to-github-pages.sh
38+
on:
39+
tags: true
40+
- provider: script
41+
script:
42+
- mvn release:prepare
43+
- mvn release:perform
44+
on:
45+
tags: true
46+
env:
47+
global:
48+
- secure: cM73yz9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OcDct3WlQBow9u2OfhSpAnLBg3bUN2QzMtdZ2ZQNVieNI1tIYRnnwOV/hy0WYS7VOu0vWNP3XXNByWVoiweQhwvpRELjjMxgLWJ8TQhPXJ1qISLws2YvHbffDFG4ysGx4LsccfevTSt5EA8zuz6kRUzcQspWnmdSgQ/gX0Ruzi/S1wHwhFr+j7ulpTM5diWLb75f5u33UGvCF312EQpuKCQ9HNXBN/k5IZnUN1BoiH53/xdAfnqwKLcNbmRR47eq6GuPE0p3Vuz5GMG8ZU=
50+
- secure: EPf05A7CuUj6gtIIg722Pq30P+huDmOvz7g2KVfi1YWwQpvryT6cH4KJky7MLegKXJ3kn8UwNCW8vU76VZcUiIYPg0WLsxXOu6gDMsDfnm2XX69uyIJTNw6Q2pfd8dKmJomZFRoIs5AD9hjU0iukVRL/Wlq3eU4NLFfToPLsv5NbckW1IjPYCvlVTUviyhACr+veDX8wIADEtQoqD4KxUnYqS0IZjFJwWGngIYe+YX4lW+qU3IIsuHxOCivkESkMQci2/eL8/gNqKbF8EFza2rzaDuJdaBj2etTxH6UoAJ0P9ZzsY0Kku7rVDSjqg5zZ5mo/OsQLCPkuXf/MKCUp4oJ8z2wxcEXe5YIO9G8S3sNaLIAQNLTwjfGFBP9YVWhZng1OBdLvh8+/r3kuPlilEu7H4M8iQ5zl9iV4SiguLOzcbV0hDm6F2UnUhvUwy8PJoDKVXJjW7PbYMBwGKnOu7QFG7LrLVCM7zORHfg+iu317yFdZLF+Jn+mBu5WGY+Jgr3rJnkgC7s5mQ+KKrWeFc/fZirykC8RbCkuss5KeQvkIiLtExvHP/1jPld/mhM2ItfCR6REVwHCN7zBYK56S8fa+oxT4ozc2p6Ked/F+QrrS0LekWcS0QnWYD5/Bp0iJVjL1HMv0vOKJimbmSf2athuFGA1gkTpBPKG7opSZf58=

README.md

Lines changed: 85 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
99
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1010

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

1313
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.
1414

@@ -20,13 +20,12 @@ You'll find no junk (hopefully) here, but it's a fairly opinionated approach:
2020
- 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)
2121
- There's an externalised (and overridable) configuration system, based on JSON
2222
- We handle providing JUnit (we use version 5), Selenium and Hamcrest (for writing good assertions)
23+
- The framework is instrumented to measure execution time of internals, and these metrics are available via JMX or Graphite.
2324
- 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.
24-
- We have a (developing) open roadmap in GitHub Issues (click the Issues tab to see what we have so far)
25+
- We have a (developing) open road map in GitHub Issues (click the Issues tab to see what we have so far)
2526

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

@@ -47,71 +46,107 @@ submit an issue ticket.
4746
## Documentation
4847

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

5251
## Example checks/project
5352

5453
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.
5554

5655
## Usage
5756

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

6059
```
6160
<dependency>
6261
<groupId>uk.co.evoco</groupId>
6362
<artifactId>selenium-pom-framework</artifactId>
64-
<version>1.0.1</version>
63+
<version>1.0.7</version>
6564
</dependency>
6665
```
6766

68-
You need to tell Maven how to access GitHub packages. So you need to edit your `settings.xml`.
67+
**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.
68+
- You can see historic releases in the Packages tab above
69+
- 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)
6970

70-
Typically you can do this by looking in `~/.m2/settings.xml`. You will need a GitHub Personal Access Token, which
71-
you can do here (once you're logged in): https://github.com/settings/tokens
71+
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.
7272

73-
An example configuration (`settings.xml`) would be:
73+
## Instrumentation and metrics
74+
The framework is instrumented with Dropwizard Metrics which has two reporters; JMX and Graphite.
75+
76+
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.
77+
From `jconsole` you will need to open `MBeans` and then `metrics` to see the metrics that are being produced.
78+
79+
**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.
80+
81+
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.
82+
83+
**Note:** Obviously you have to have `docker` installed. I'm sure you can Google that :)
84+
85+
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
86+
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:
87+
88+
`docker network create graphite_grafana`
89+
90+
Then we need to grab `graphite`:
91+
92+
```
93+
docker run -d \
94+
--name graphite \
95+
--restart=always \
96+
--net graphite_grafana \
97+
-p 80:80 \
98+
-p 2003-2004:2003-2004 \
99+
-p 2023-2024:2023-2024 \
100+
-p 8125:8125/udp \
101+
-p 8126:8126 \
102+
graphiteapp/graphite-statsd
103+
```
104+
105+
And finally we need to grab `grafana`:
106+
107+
`docker run -d --name=grafana -p 3000:3000 --net graphite_grafana grafana/grafana`
108+
109+
Once all of these commands have finished if you run `docker ps` you should end up with something like the following:
110+
111+
```
112+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
113+
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
114+
ed8a7fcdbfc3 grafana/grafana "/run.sh" 2 minutes ago Up 2 minutes 0.0.0.0:3000->3000/tcp grafana
115+
```
116+
117+
Now open up a browser window and get the two web interfaces loaded up:
118+
119+
Graphite: http://localhost:80
120+
121+
Grafana: http://localhost:3000
122+
123+
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".
124+
Then select "Graphite" from the list of sources.
125+
126+
Give an appropriate name (selenium-pom-framework for example). The following fields and values follow:
127+
128+
```
129+
URL: http://graphite:80
130+
```
131+
132+
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
133+
where your tests are going slowly.
134+
135+
There's a sample dashboard in this repo in `grafana-dashboard-examples/sample-dashboard.json` that you can import to get started.
136+
137+
If you're deploying this else where (i.e. not locally) you can configure connection details in the configuration object (see below).
74138

75139
```
76-
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77-
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
78-
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
79-
http://maven.apache.org/xsd/settings-1.0.0.xsd">
80-
81-
<activeProfiles>
82-
<activeProfile>github</activeProfile>
83-
</activeProfiles>
84-
85-
<profiles>
86-
<profile>
87-
<id>github</id>
88-
<repositories>
89-
<repository>
90-
<id>central</id>
91-
<url>https://repo1.maven.org/maven2</url>
92-
<releases>
93-
<enabled>true</enabled>
94-
</releases>
95-
<snapshots>
96-
<enabled>false</enabled>
97-
</snapshots>
98-
</repository>
99-
<repository>
100-
<id>github</id>
101-
<name>GitHub OWNER Apache Maven Packages</name>
102-
<url>https://maven.pkg.github.com/digital-delivery-academy/selenium-pom-framework</url>
103-
</repository>
104-
</repositories>
105-
</profile>
106-
</profiles>
107-
<servers>
108-
<server>
109-
<id>github</id>
110-
<username>GITHUB_USERNAME</username>
111-
<password>GITHUB_PERSONAL_ACCESS_TOKEN_FOR_PACKAGES</password>
112-
</server>
113-
</servers>
114-
</settings>
140+
"metrics": {
141+
"jmx": {
142+
"enabled": false
143+
},
144+
"graphite": {
145+
"enabled": true,
146+
"host": "localhost",
147+
"port": 2003
148+
}
149+
}
115150
```
116151

117152
## References/thanks

deployment/signingkey.asc.enc

3.56 KB
Binary file not shown.

0 commit comments

Comments
 (0)