Cloudfront Integration Tests#4440
Conversation
There was a problem hiding this comment.
It looks like mock.jar is written by a chef recipe. Is this integration test something that can only be run on chef-manage instances (i.e. not my laptop?)
There was a problem hiding this comment.
It seems a little unusual to drop a file in ~ and run it from there; will this work in all of the test running environments that we might care about?
There was a problem hiding this comment.
- The integration test can run on your laptop, if Test Kitchen and Docker are installed locally. I've documented this in
cdo-varnish/README.md:
Running Tests
The integration tests run using Test Kitchen.
Seetest/cookbooks/varnish_test/README.mdfor more details.To test the cookbook, first make sure Docker is installed and running locally,
then run:
chef exec kitchen createto create the machine imagechef exec kitchen convergeto install Chef and converge the cookbook in the
platform environmentchef exec kitchen verifyto run the integration test suite
I can clarify this documentation to add that test-kitchen, kitchen-docker and berkshelf all need to be available to the Ruby environment (either installed globally via gem install test-kitchen, provided by Bundler through the provided Gemfile after a bundle install via bundle exec kitchen, or provided by ChefDK via chef exec kitchen).
- This will only work in the provisioned, isolated environment created by Test Kitchen. The actual
test_default.rbcode is run within the environment via Busser using the busser-minitest runner plugin, after the cookbooks and runlists specified in.kitchen.ymlhave been applied to the environment. This is all described in the Test Kitchen documentation.
Let me know if you have any suggestions on how to clarify any of these points within the documentation here.
|
My big top-level comment is that as an integration test this should test the integrated CloudFront + Varnish system we have in production, rather than testing them in isolation (e.g. CloudFront without Varnish). This would also let you test some of the functionality that is provided by Varnish but not Cloudfront like the language normalization. (Speaking of which: I would really like to see hard data on the language header diversity.) |
There was a problem hiding this comment.
This can be restored if the test is changed to hit CloudFront + Varnish.
There was a problem hiding this comment.
This test will succeed on a CloudFront + Varnish request only if we check the Varnish X-Varnish-Cache header for Hit, rather than the CloudFront X-Cache one. To distinguish this test as specifically checking the Varnish cache header, I'll add a new method assert_varnish_cache.
There was a problem hiding this comment.
That sounds fine. Or you could have a generic cache method that is happy
if either varnish or cloudfront gets a hit. (That way, if we make
CloudFront smarter down the road, the test doesn't break needlessly, since
we're still getting the desired hit.)
On Thu, Oct 8, 2015 at 4:53 PM, Will Jordan notifications@github.com
wrote:
In
cookbooks/cdo-varnish/test/integration/cloudfront/minitest/test_default.rb
#4440 (comment)
:
- assert_miss response
- assert_equal text_en, last_line(response)
Ensure that Vary response header is de-normalized
- assert_nil /X-Varnish-Accept-Language/.match(response)
- refute_nil /Accept-Language/.match(response)
- assert_hit proxy_request url, en
Ensure that language is separately cached
- fr = {'Accept-Language' => 'fr'}
- response = proxy_request url, fr
- assert_miss response
- assert_equal text_fr, last_line(response)
- assert_hit proxy_request url, fr
Language-header normalization not implemented in CloudFront.
This test will succeed on a CloudFront + Varnish request only if we check
the Varnish X-Varnish-Cache header for Hit, rather than the CloudFront
X-Cache one. To distinguish this test as specifically checking the
Varnish cache header, I'll add a new method assert_varnish_cache.—
Reply to this email directly or view it on GitHub
https://github.com/code-dot-org/code-dot-org/pull/4440/files#r41584705.
|
Done with my first pass. Thanks for doing this; it will be very valuable to have tests for this. |
|
Just to clarify, this |
|
However, I've separated the tests so that the |
|
Looking at the tests which are currently skipped, it seems like they don't On Thu, Oct 8, 2015 at 3:15 PM, Will Jordan notifications@github.com
|
This addon-PR adds CloudFront integration tests to the cdo-cloudfront work (PR #4207). It adds a new
cdo-varnishTest Kitchen test suitecloudfrontthat uses substantially the same test suite currently running against Varnish, with a few differences:ngrokto tunnellocalhost:80tocdo.ngrok.io, exposing the Varnish server at the public endpoint.https://integration-studio.code.org, usingcdo.ngrok.ioas its origin server.X-Cache: [Miss|Hit] from cloudfrontheaders instead of theX-Varnish-Cache: [Miss|Hit]headers returned by Varnish.Accept-Languageheader based on available languages, soAccept-Language: frandAccept-Language: da, x-random;q=0.8, fr;q=0.7would return the same cached response)A successful CircleCI integration test run can be found here. I've added the
NGROK_TOKENenvironment variable to the CircleCI configuration in order to configure the ngrok tunnel correctly.