Skip to content

config: subscription factory dependency injection.#7200

Merged
htuch merged 13 commits intoenvoyproxy:masterfrom
htuch:inject-subscription-factory-2
Jun 11, 2019
Merged

config: subscription factory dependency injection.#7200
htuch merged 13 commits intoenvoyproxy:masterfrom
htuch:inject-subscription-factory-2

Conversation

@htuch
Copy link
Copy Markdown
Member

@htuch htuch commented Jun 7, 2019

While working on TDS, it became apparent that the xDS subscription tests are a bit conflated today,
since they include both testing of the xDS resource specific subscription and also things like the
REST fetcher, etc. This is because the subscription factory is a static, rather than a mockable
dependency of subscriptions. This PR transforms subscription factory to an instance object.

The PR is quite massive, but it has big pay-off in terms of reducing the boiler plate in xDS tests,
separating concerns and making it easier to add new xDS types. Given the recent additions of SRDS,
VHDS, TDS and FCDS, this seems worth it.

A number of xDS tests have been modified to work with the new pattern. Some tests and properties
that are orthogonally tested in subscription_factory_test or the gRPC/REST subscription tests are no
longer tested in the resource specified tests.

Some general absl::string_view goodness plumbing was also needed due to the new string_view-based
interface.

Risk level: Medium
Testing: Modified a number of resource specified xDS unit tests.

Relates to #6708.

Signed-off-by: Harvey Tuch htuch@google.com

While working on TDS, it became apparent that the xDS subscription tests are a bit conflated today,
since they include both testing of the xDS resource specific subscription and also things like the
REST fetcher, etc. This is because the subscription factory is a static, rather than a mockable
dependency of subscriptions. This PR transforms subscription factory to an instance object.

The PR is quite massive, but it has big pay-off in terms of reducing the boiler plate in xDS tests,
separating concerns and making it easier to add new xDS types. Given the recent additions of SRDS,
VHDS, TDS and FCDS, this seems worth it.

A number of xDS tests have been modified to work with the new pattern. Some tests and properties
that are orthogonally tested in subscription_factory_test or the gRPC/REST subscription tests are no
longer tested in the resource specified tests.

Some general absl::string_view goodness plumbing was also needed due to the new string_view-based
interface.

Risk level: Low
Testing: Modified a number of resource specified xDS unit tests.

Relates to envoyproxy#6708.

Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch htuch requested review from lizan and zuercher as code owners June 7, 2019 04:30
@htuch htuch requested review from fredlas and mattklein123 and removed request for zuercher June 7, 2019 04:30
@htuch
Copy link
Copy Markdown
Member Author

htuch commented Jun 7, 2019

@fredlas @dmitri-d @AndresGuedez @silentdai this is the cleanup PR that should make adding new xDS a bit easier.

Signed-off-by: Harvey Tuch <htuch@google.com>
Copy link
Copy Markdown
Contributor

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

Thank you so much for simplifying the code!
I might be the first beneficiary.

htuch added 3 commits June 7, 2019 10:27
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
Copy link
Copy Markdown
Member

@lizan lizan left a comment

Choose a reason for hiding this comment

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

Nice! just one nit.

}

// Tests that defining an invalid cluster in the SRDS config results in an error.
TEST_F(ScopedRdsTest, UnknownCluster) {
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.

Hmm, this is no longer the case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This validation is done by the subscription factory and tested at https://github.com/envoyproxy/envoy/blob/master/test/common/config/subscription_factory_test.cc#L313. It's not really possible to test this with a mock subscription factory as a result.

fredlas
fredlas previously approved these changes Jun 10, 2019
Copy link
Copy Markdown
Contributor

@fredlas fredlas left a comment

Choose a reason for hiding this comment

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

All looks good, and in particular the various calls of subscriptionFromConfigSource are much cleaner. Very nice!

htuch added 3 commits June 10, 2019 18:28
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
htuch added 5 commits June 10, 2019 18:57
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch
Copy link
Copy Markdown
Member Author

htuch commented Jun 11, 2019

@lizan looks like clang_tidy is now passing; if you could approve, I'll merge when CI passes.

@htuch htuch merged commit b3f848d into envoyproxy:master Jun 11, 2019
@htuch htuch deleted the inject-subscription-factory-2 branch June 11, 2019 20:23
htuch added a commit to htuch/envoy that referenced this pull request Aug 7, 2019
…/dynamic config.

As per envoyproxy#6651, this PR plumbs in CLI options to allow independent control over static/dynamic unknown
field validation.

The defaults are the same for static as today (strict) and for dynamic we are by default permissive.
This permits easy rollout of new API minor versions, including those related to security fixes.

Fixes a regression that occurred in envoyproxy#7200 where strict/permissive checking CLI options were
inverted.

Risk level: Low (strictly more permissive by default)
Testing: additional unit and integration tests added, exercising both permissive/strict checking
  over various parts of the API (bootstrap, listeners, clusters, xDS, network filters, etc).

Fixes envoyproxy#6651

Signed-off-by: Harvey Tuch <htuch@google.com>
htuch added a commit that referenced this pull request Aug 19, 2019
…/dynamic config. (#7857)

As per #6651, this PR plumbs in CLI options to allow independent control over static/dynamic unknown
field validation.

The defaults are the same for static as today (strict) and for dynamic we are by default permissive.
This permits easy rollout of new API minor versions, including those related to security fixes.

Fixes a regression that occurred in #7200 where strict/permissive checking CLI options were
inverted.

As per #6818, added stats/warning for any unknown fields encountered.

Risk level: Low (strictly more permissive by default)
Testing: additional unit and integration tests added, exercising both permissive/strict checking
over various parts of the API (bootstrap, listeners, clusters, xDS, network filters, etc).

Fixes #6651
Fixed #6818

Signed-off-by: Harvey Tuch <htuch@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants