Skip to content

What is resolve target url.sh

Tony Lawson edited this page Sep 12, 2019 · 1 revision

You may have noticed a script within the repo called resolve-target-url.sh. This page will explain what it is and why it's useful. The script can be found at /utilities/resolve-target-url.sh

The problem

UI Tests can be long running, and can take a while to get through them all for a given product.

Under normal conditions, this is fine. However, when there is an issue, it can take a while for the pipeline to complete and report the failures.

Where a deployment has failed, and the entire application is not running, this will mean that each test will attempt to run and it can take a long time for us to know about it.

This also has the added problem of taking up a build agent, meaning some other pipeline cannot be executed, meaning we could be blocking a different product from deploying.

The solution

Where the application is down, we know that all the tests will fail so there is little value in running them.

What if we can test that the application is running, and if it's not, skip the tests and just report the failure?

We do this by making a http request to the url, and expects a successful response.

If we get any other response, we know there is a problem.

This is what the script is doing, and we run it as a task ahead of the acceptance tests.

How the script works

The script is a .sh shell script, and you trigger it on the command line with at least 1 parameter.

The parameter the script expects are:

  1. Required: the URL, without the "https://" part - This script expects you to be using HTTPS

  2. Optional: If the application is using OAuth, the username

  3. Optional: If the application is using OAuth, the password

After handling these parameters, the script first prints out the IP of the machine running the script.

Then the script performs the HTTP request to the url inside a docker container.

The script finally checks for any error codes, and if it has one, then it prints the error and fails the pipeline.

Clone this wiki locally