All Projects → alphagov → Cdn Acceptance Tests

alphagov / Cdn Acceptance Tests

Licence: mit
CDN Acceptance Tests

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Cdn Acceptance Tests

publishing-api
API to publish content on GOV.UK
Stars: ✭ 29 (-36.96%)
Mutual labels:  govuk
panopticon
Retired. App that holds some of the content on GOV.UK
Stars: ✭ 17 (-63.04%)
Mutual labels:  govuk
Whitehall
Publishes government content on GOV.UK
Stars: ✭ 634 (+1278.26%)
Mutual labels:  govuk
content-data-api
Data warehouse that stores content and content metrics to help content owners measure and improve content on GOV.UK
Stars: ✭ 13 (-71.74%)
Mutual labels:  govuk
govuk crawler worker
A worker that will consume GOV.UK URLs from a message queue and crawl them, saving the output to disk
Stars: ✭ 17 (-63.04%)
Mutual labels:  govuk
govuk-taxonomy-supervised-learning
Auto-tag govuk content to the collated legacy taxonomies
Stars: ✭ 22 (-52.17%)
Mutual labels:  govuk
govuk-terraform-provisioning
**DEPRECATED** Terraform configuration and utilities to provision parts of the GOV.UK AWS Infrastructure
Stars: ✭ 17 (-63.04%)
Mutual labels:  govuk
Gds Sso
OmniAuth adapter to allow apps to sign in via GOV.UK signon
Stars: ✭ 21 (-54.35%)
Mutual labels:  govuk
government-frontend
Serves government pages on GOV.UK
Stars: ✭ 42 (-8.7%)
Mutual labels:  govuk
Govuk Aws
The GOV.UK repository for our Migration to AWS
Stars: ✭ 334 (+626.09%)
Mutual labels:  govuk
publisher
Publishes mainstream content on GOV.UK
Stars: ✭ 42 (-8.7%)
Mutual labels:  govuk
finder-frontend
Serves finder and search pages for GOV.UK
Stars: ✭ 15 (-67.39%)
Mutual labels:  govuk
need-o-tron
No description or website provided.
Stars: ✭ 35 (-23.91%)
Mutual labels:  govuk
slimmer
Templating Rack middleware, injects standard header/footer and GOV.UK Components
Stars: ✭ 30 (-34.78%)
Mutual labels:  govuk
Govuk Component Guide
A style guide for GOV.UK Components shared between applications
Stars: ✭ 16 (-65.22%)
Mutual labels:  govuk
collections
Serves GOV.UK navigation pages, browse, topic, step-by-steps & services and information pages.
Stars: ✭ 32 (-30.43%)
Mutual labels:  govuk
govuk publishing components
A gem to document and distribute frontend components for GOV.UK applications
Stars: ✭ 45 (-2.17%)
Mutual labels:  govuk
Calendars
Serves /bank-holidays and /when-do-the-clocks-change on GOV.UK
Stars: ✭ 39 (-15.22%)
Mutual labels:  govuk
Blinken
RETIRED. Superseded by https://github.com/alphagov/blinkenjs
Stars: ✭ 13 (-71.74%)
Mutual labels:  govuk
govuk-docker
GOV.UK development environment using Docker 🐳
Stars: ✭ 37 (-19.57%)
Mutual labels:  govuk

CDN Acceptance Tests

Acceptance tests for our Content Delivery Network(s).

These are written using Go's testing package because it provides a framework for running basic assertions and a rich HTTP client/server library.

Methodology

The single Go process acts as both the client and the origin server so that it can inspect the input and output of the CDN.

                   +---------+
         +-------> |         |---------+
         |         |   CDN   |         |
         | +-------|         | <-----+ |
         | |       +---------+       | |
         | |                         | |
 request-| |-response                | |
         | |                         | |
         | |   +-----------------+   | |
         | +-> |     go test     |---+ |
         |     |                 |     |
         +-----| client ¦ server | <---+
               +-----------------+

When testing a real CDN, the tests must be run on a server that the CDN can connect to.

It will not configure the CDN service for you; you'll need to do so, pointing it at the machine that will be running the tests.

For more information please see this post on the GDS Technology blog:

Running

You will need the Go 1.x runtime installed. To install this on OS X:

brew install go

To run all the tests:

go test -edgeHost cdn-vendor.example.com -vendor cdn-vendor

...where -edgeHost specifies the CDN edge.

To run a subset of tests based on a regex:

go test -edgeHost cdn-vendor.example.com -run 'Test(Cache|NoCache)' -vendor cdn-vendor

To see all available command-line options:

go test -usage

Adapting the tests to your own configuration

You may need to make some changes to adapt the tests to your specific configuration.

  • The tests disregard all HEAD requests as healthcheck probes. You may need to modify this or filter those on other HTTP request headers depending on how your edge sends healthcheck probes.

Writing tests

When writing new tests please be sure to:

  • group the test in a file with other tests of similar behaviour e.g. "custom failover"
  • use a consistent naming prefix for the functions that so that they can be run as a group e.g. func TestCustomFailover…(…)
  • always call ResetBackendsInOrder() at the beginning of each test to ensure that all of the backends are running and have their handlers reset from previous tests.
  • use the helpers such as NewUniqueEdgeGET() and RoundTripCheckError() which do a lot of the work, such as error checking, for you.
  • define static inputs such as "number of requests" or "time between requests" at the beginning of the test so that they're easy to locate. Use constants where possible to indicate that they won't be changed at runtime.

Mock CDN virtual machine

You can develop new tests against a Vagrant VM which uses Varnish to simulate a CDN. Nginx and stunnel are used to terminate/initiate TLS and inject headers.

               +---------------------------+
         +---> |        Vagrant VM         |-----+
         |     |                           |     |
         | +---| Nginx ¦ Varnish ¦ stunnel | <-+ |
         | |   +---------------------------+   | |
         | |                                   | |
 request-| |-response                          | |
         | |                                   | |
         | |        +-----------------+        | |
         | +------> |     go test     |--------+ |
         |          |                 |          |
         +----------| client ¦ server | <--------+
                    +-----------------+

You may need to modify the configuration of the VM in mock_cdn_config/ to account for new tests.

To bring up the VM and point the tests at it:

vagrant up && vagrant provision
go test -edgeHost 172.16.20.10 -skipVerifyTLS -vendor fastly

Please note that this is not a complete substitute for the real thing. You must test against a real CDN before submitting any pull requests.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].