Skip to content

Add blue/green conformance test#1460

Merged
google-prow-robot merged 4 commits intoknative:masterfrom
jonjohnsonjr:bluegreen
Jul 4, 2018
Merged

Add blue/green conformance test#1460
google-prow-robot merged 4 commits intoknative:masterfrom
jonjohnsonjr:bluegreen

Conversation

@jonjohnsonjr
Copy link
Copy Markdown
Contributor

Fixes #1416

Based on #1458

The test:

  • Create config pointing first image.
  • Get the revision name, this is the blue revision.
  • Update the config, pointing to second image.
  • Get the revision name, this is the green revision.
  • Create a Route that points 50/50 to blue and green revision.
  • Spin up goroutines to make 100 requests against:
    1. blue revision
    2. green revision
    3. route
  • For 1/2, assert that each request is handled by the appropriate image.
  • For 3, assert that we get a reasonable distribution of responses (at worst 25/75 split).

This has exposed some less-than-perfect performance. Many requests return 404s :(

@google-prow-robot google-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 3, 2018
@jonjohnsonjr
Copy link
Copy Markdown
Contributor Author

/assign @mattmoor

@jonjohnsonjr
Copy link
Copy Markdown
Contributor Author

Sample output.

$ go test -v -tags=e2e -count=1 ./test/conformance/ -run TestBlueGreenRoute
info	logging/config.go:80	Successfully created the logger.	{"knative.dev/jsonconfig": "{\n\t  \"level\": \"info\",\n\t  \"encoding\": \"console\",\n\t  \"outputPaths\": [\"stdout\"],\n\t  \"errorOutputPaths\": [\"stderr\"],\n\t  \"encoderConfig\": {\n\t    \"messageKey\": \"message\",\n\t\t\t\"levelKey\": \"level\",\n\t\t\t\"nameKey\": \"logger\",\n\t\t\t\"callerKey\": \"caller\",\n\t\t\t\"messageKey\": \"msg\",\n      \"stacktraceKey\": \"stacktrace\",\n      \"lineEnding\": \"\",\n      \"levelEncoder\": \"\",\n      \"timeEncoder\": \"\",\n      \"durationEncoder\": \"\",\n      \"callerEncoder\": \"\"\n\t  }\n\t}"}
info	logging/config.go:81	Logging level set to info
=== RUN   TestBlueGreenRoute
info	TestBlueGreenRoute	test/crd.go:141	Seeding rand.Rand with 1530634217046958506
info	TestBlueGreenRoute	conformance/blue_green_test.go:130	Creating a Configuration
info	TestBlueGreenRoute	conformance/blue_green_test.go:137	The Configuration will be updated with the name of the Revision once it is created
info	TestBlueGreenRoute	conformance/blue_green_test.go:143	Updating the Configuration to use a different image
info	TestBlueGreenRoute	conformance/blue_green_test.go:152	Since the Configuration was updated a new Revision will be created and the Configuration will be updated
info	TestBlueGreenRoute	conformance/blue_green_test.go:159	Waiting for revision "prodcmkcssxv-00001" to be ready
info	TestBlueGreenRoute	conformance/blue_green_test.go:163	Waiting for revision "prodcmkcssxv-00002" to be ready
info	TestBlueGreenRoute	conformance/blue_green_test.go:172	Creating a Route
info	TestBlueGreenRoute	conformance/blue_green_test.go:177	When the Route reports as Ready, everything should be ready.
info	TestBlueGreenRoute	conformance/blue_green_test.go:61	Polling pizzaplanetewmqkvyp.pizzaplanet.example.com until we get a 200
info	TestBlueGreenRoute	conformance/blue_green_test.go:61	Polling green.pizzaplanetewmqkvyp.pizzaplanet.example.com until we get a 200
info	TestBlueGreenRoute	conformance/blue_green_test.go:61	Polling blue.pizzaplanetewmqkvyp.pizzaplanet.example.com until we get a 200
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	conformance/blue_green_test.go:66	Performing 100 concurrent requests to green.pizzaplanetewmqkvyp.pizzaplanet.example.com
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	test/request.go:170	Retrying for code 404
info	TestBlueGreenRoute	conformance/blue_green_test.go:66	Performing 100 concurrent requests to pizzaplanetewmqkvyp.pizzaplanet.example.com
info	TestBlueGreenRoute	conformance/blue_green_test.go:66	Performing 100 concurrent requests to blue.pizzaplanetewmqkvyp.pizzaplanet.example.com
info	TestBlueGreenRoute	conformance/blue_green_test.go:106	wanted at least 100, got 100 requests for green.pizzaplanetewmqkvyp.pizzaplanet.example.com
info	TestBlueGreenRoute	conformance/blue_green_test.go:106	wanted at least 25, got 42 requests for pizzaplanetewmqkvyp.pizzaplanet.example.com
info	TestBlueGreenRoute	conformance/blue_green_test.go:106	wanted at least 25, got 58 requests for pizzaplanetewmqkvyp.pizzaplanet.example.com
info	TestBlueGreenRoute	conformance/blue_green_test.go:106	wanted at least 100, got 100 requests for blue.pizzaplanetewmqkvyp.pizzaplanet.example.com
--- PASS: TestBlueGreenRoute (13.40s)
PASS
ok  	github.com/knative/serving/test/conformance	13.409s

Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super cool, thanks for putting this together.
🎉

Comment thread test/request.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is expected to implement a particular interface, I'd recommend using this pattern to assert that:

var _ Interface = (*SpoofingClient)(nil)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closest I found is http.Roundtripper, but I'm not sure if implementing that would make this easier or harder to use. WDYT?

Comment thread test/request.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use http.StatusNotFound and other http constants in place of hardcoding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread test/request.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same not for http.MethodGet

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread test/request.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this encapsulation (which is good) loses something by being in the same file as other stuff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment about using http constants throughout this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ is a context.Context

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check err

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_ is a context.Context

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we hoist 100 and 25% to constants to make them easier to vary?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Contributor

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is pretty cool - most of my confusion with this initially was about #1458 - generally i am excited about these changes :D

i really think we should start some docs on what each conformance test is for - and/or use an elaborate docstring for each test explaining the test case it is covering - if we don't start now this will be painful to add later

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like this interface a lot, i think it's really slick and pretty easy to understand what's going on!

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz add name to TODO or issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tcnghia help

Comment thread test/request.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am nervous about adding middleware - i think middleware tends to be hard to reason about and make debugging more difficult

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. I will leave this as a TODO for now, but I think it's possible to do this in an acceptable way by just function wrapping.

We'll need to do something like it for #1298

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a lot going on in this function, I think we could use some docs explaining what's going on at least

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can has more comments explaining the details here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@google-prow-robot google-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 3, 2018
@jonjohnsonjr
Copy link
Copy Markdown
Contributor Author

/assign @tcnghia

I TODO(you)'d you a few places, can you take a look?

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooo nice update, i like the percentage

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒

Comment thread test/conformance/blue_green_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not quite clear to me why this is called "recording" checker?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a bad abstraction, I have eradicated it. Thanks.

That is:

* Create config pointing first image.
* Get the revision name, this is the blue revision.
* Update the config, pointing to second image.
* Get the revision name, this is the green revision.
* Create a Route that points 50/50 to blue and green revision.
* Spin up goroutines to make 100 requests against:
  1. blue revision
  2. green revision
  3. route
* For 1/2, assert that each request is handled by the appropriate image.
* For 3, assert that we get a reasonable distribution of responses (at worst 25/75 split).
@google-prow-robot google-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 3, 2018
@jonjohnsonjr
Copy link
Copy Markdown
Contributor Author

@bobcatfish up for another round? 😀

I refactored some things such that I find them much more legible, LMK if you think it could be improved any further.

i really think we should start some docs on what each conformance test is for - and/or use an elaborate docstring for each test explaining the test case it is covering - if we don't start now this will be painful to add later

I've added a small comment to the blue/green test. Happy to change it if you had something else in mind.

Comment thread test/adding_tests.md Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

har har

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL @jonjohnsonjr is evil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine 🙄

@jonjohnsonjr
Copy link
Copy Markdown
Contributor Author

@mattmoor @bobcatfish this is now 100% free of greek alphabet and evil.

RFAL 😅

Copy link
Copy Markdown
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 4, 2018
@google-prow-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jonjohnsonjr, mattmoor

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-prow-robot google-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 4, 2018
@google-prow-robot google-prow-robot merged commit a2a85e6 into knative:master Jul 4, 2018
@jonjohnsonjr jonjohnsonjr deleted the bluegreen branch July 4, 2018 16:38
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/knative-serving that referenced this pull request Oct 3, 2025
…e-v1.18

[release-v1.18] Update OWNERS file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants