akamai rspec
TRANSCRIPT
Akamai
● Content Delivery Network● Sits in front of your servers● Caches your content● Clients connect to edge node near them● Helps your site go fast
Rspec
● Ruby unit testing framework● Prefer pretty matchers over plain asserts
eg. expect(“foo”).to not_equal(“bar”)
Why use it?
● Check akamai config behaves how you expect● Catch regressions in akamai config● When akamai features do weird stuff
– Their WAF modifies behaviour in non enforcing
be_permanently_redirected_to
expect(old).to be_permanently_redirected_to(new)● Expect 301 redirect from old to new
be_temporarily_redirected_to
expect(old).to be_temporarily_redirected_to(new)
● Expect a 302 redirect from old to new
be_temporarily_redirected_to_with_trailing_slash
expect(old).to be_temporarily_redirected_to_with_trailing_slash(new)
● Like be_temporarily_redirected_to● Also expect the response location to have a '/' added
be_cacheable
expect(url).to be_cacheable● When akamai debug headers are supplied, X-
Check-Cacheable is yes
have_no_cache_set
response = RestClient.get(url)
expect(response).to have_no_cache_set ● Cache-control = no-cache
not_be_cached
expect(url).to not_be_cached● Requests the resource twice● Expect x_cache header to say cache miss● Expect response code to be 200
be_successful
response = RestClient.get(url)
expect(url).to be_successful
expect(response).to be_successful● Expect response code to be 200
be_served_from_origin
expect(url).to be_served_from_origin origin● Expect response code to be 200● Expect x_cache_key header to include origin
url
honour_origin_cache_headers
expect(url).to honour_origin_cache_headers origin● Check that akamai and origin cache headers
correspond● Takes in to account expected differences
be_forwarded_to_index
expect(url + “/” channel).to be_forwarded_to_index(channel)
● Expect response to have x-akamai-session-info● Expect AKA_PM_FWD_URL header to end in
channel● That means it's passing on the channel to origin● Response code is 200
be_tier_distributed
expect(response).to be_tier_distributed● Forces a cache miss (query string)● Checks that x_cache_remote header is set
have_cookie
expect(response).to have_cookie cookie● Expect the response to contain the specified
cookie
have_cp_code
expect(url).to have_cp_code(cp_code)● Cache key contains Content Provider Code● 200 response
Getting it
● Unfortunately, didn't manage to open source it in time
● Will be at github.com/realestate-com-au soon● Contributions wanted, especially tests and
documentation● Get in touch if you do use it