<commit_before>#!/bin/bash

. $(dirname $0)/../setup.sh

# This is a manual test because we can't guarantee that ISMDS will always have a stale cache result to begin the test
describe "Age header from ISMDS should be preserved by fastly, even if greater than max-age"

keep_headers "Age|X-Cache|X-Served-By|Server|Expires|Cache-Control"

function record_ismds() {
    record_curl -k "${origin_url}/host/26004E4DF73E808C/facets?by=shape+attributes+available+accessibility+offer+inventoryType+offerType+description&show=places&embed=description&unlock=&apikey=b462oi7fic6pehcdkzony5bxhe&apisecret=<KEY>" -H 'Pragma: no-cache' -H 'Origin: http://fastly-hackathon.tmdev.co' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: http://fastly-hackathon.tmdev.co/event/3F004EAECFB7BA10?fg=ism' -H 'Connection: keep-alive' --compressed
}

function record_fastly() {
    record_curl "${target_url}/host/26004E4DF73E808C/facets?by=shape+attributes+available+accessibility+offer+inventoryType+offerType+description&show=places&embed=description&unlock=&apikey=b462oi7fic6pehcdkzony5bxhe&apisecret=pquzpfrfz7zd2ylvtz3w5dtyse" -H 'Pragma: no-cache' -H 'Origin: http://fastly-hackathon.tmdev.co' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: http://fastly-hackathon.tmdev.co/event/3F004EAECFB7BA10?fg=ism' -H 'Connection: keep-alive' --compressed
}

it "captures Age of a stale ISMDS request (if Age is 1, repeat the test case manually 60 seconds later)"

record_fastly
stash_curl
record_ismds

expect_header Server; to_equal nginx
expect_header Age; to_be_greater_than 60
ismds_age=$(get_header Age)

it "compared to fastly request made just before, should preserve the Age header from ismds"

pop_curl

expect_header X-Cache; to_match MISS$
expect_header Age; to_be_between $((ismds_age - 1)) $((ismds_age + 1))

it "after 6 seconds, cache misses on a followup request but has the new Age header from ismds"

sleep 6
record_fastly
stash_curl<commit_msg>Re-word retry message on manual test<commit_after>#!/bin/bash

. $(dirname $0)/../setup.sh

# This is a manual test because we can't guarantee that ISMDS will always have a stale cache result to begin the test
describe "Age header from ISMDS should be preserved by fastly, even if greater than max-age"

keep_headers "Age|X-Cache|X-Served-By|Server|Expires|Cache-Control"

function record_ismds() {
    record_curl -k "${origin_url}/host/26004E4DF73E808C/facets?by=shape+attributes+available+accessibility+offer+inventoryType+offerType+description&show=places&embed=description&unlock=&apikey=b462oi7fic6pehcdkzony5bxhe&apisecret=<KEY>" -H 'Pragma: no-cache' -H 'Origin: http://fastly-hackathon.tmdev.co' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: http://fastly-hackathon.tmdev.co/event/3F004EAECFB7BA10?fg=ism' -H 'Connection: keep-alive' --compressed
}

function record_fastly() {
    record_curl "${target_url}/host/26004E4DF73E808C/facets?by=shape+attributes+available+accessibility+offer+inventoryType+offerType+description&show=places&embed=description&unlock=&apikey=b462oi7fic6pehcdkzony5bxhe&apisecret=<KEY>" -H 'Pragma: no-cache' -H 'Origin: http://fastly-hackathon.tmdev.co' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'Referer: http://fastly-hackathon.tmdev.co/event/3F004EAECFB7BA10?fg=ism' -H 'Connection: keep-alive' --compressed
}

it "captures Age of a stale ISMDS request (if Age is less than 60, repeat the test case later)"

record_fastly
stash_curl
record_ismds

expect_header Server; to_equal nginx
expect_header Age; to_be_greater_than 60
ismds_age=$(get_header Age)

it "compared to fastly request made just before, should preserve the Age header from ismds"

pop_curl

expect_header X-Cache; to_match MISS$
expect_header Age; to_be_between $((ismds_age - 1)) $((ismds_age + 1))

it "after 6 seconds, cache misses on a followup request but has the new Age header from ismds"

sleep 6
record_fastly
stash_curl
{'fraction_non_alphanumeric': 0.1307838580181703, 'fraction_numerical': 0.04965138390027467, 'mean_word_length': 5.724431818181818, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '821734', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1759, 'n_words': 425}