Skip to content

test: Make time-system into a global singleton to simplify its use and plumbing, and avoid multi-time-system test confusion.#5708

Merged
jmarantz merged 26 commits intoenvoyproxy:masterfrom
jmarantz:test-time-global
Jan 29, 2019
Merged

test: Make time-system into a global singleton to simplify its use and plumbing, and avoid multi-time-system test confusion.#5708
jmarantz merged 26 commits intoenvoyproxy:masterfrom
jmarantz:test-time-global

Conversation

@jmarantz
Copy link
Contributor

@jmarantz jmarantz commented Jan 24, 2019

Description: There are three variants of the time-system derivation we use in tests: TestTimeSystem: TestRealTimeSystem, SimulatedTimeSystem, and MockTimeSystem (used in only one test). We want to avoid having more than one of these live at a time in a test, as that is hard to reason about. IMO this should ideally be done by plumbing them through the call-stack, but this is impossible to do with our pattern of 0-arg constructor Mocks. So we use Test::Global to manage a reference-counted time-system, which is released and cleared after each test-method.

The drawback of this approach is that constructing a TimeSystem has side effects in that it initializes a global singleton, which is then picked up by mock structures (Dispatcher, Server, FactoryContext) at first use. I don't love this situation but adding constructor-args to Mocks is a significant amount of work and a change in pattern.

The benefit is that this ensures with an ASSERT that no more than one TimeSystem is instantiated at a time.

This breaks out step 1 from #5660 .

Risk Level: low: mainly a risk of comprehension in the test system due to the side effects.
Testing: //test/...
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
… template & subclass.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title WiP test: Make time-system into a global singleton to simplify it and avoid multi-time-system test confusion. test: Make time-system into a global singleton to simplify it and avoid multi-time-system test confusion. Jan 25, 2019
…Multi-threaded time-system creation really does not work.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: coverage (failed build)

🐱

Caused by: a #5708 (comment) was created by @jmarantz.

see: more, trace.

… on coverage.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
…essages.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz requested a review from sesmith177 January 25, 2019 20:22
@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: mac (failed build)

🐱

Caused by: a #5708 (comment) was created by @jmarantz.

see: more, trace.

and not the helper.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz jmarantz changed the title test: Make time-system into a global singleton to simplify it and avoid multi-time-system test confusion. test: Make time-system into a global singleton to simplify its use and plumbing, and avoid multi-time-system test confusion. Jan 26, 2019
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #5708 (comment) was created by @jmarantz.

see: more, trace.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Contributor Author

/retest

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
dnoe
dnoe previously approved these changes Jan 28, 2019
…with it.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
dnoe
dnoe previously approved these changes Jan 28, 2019
Copy link
Contributor

@dnoe dnoe left a comment

Choose a reason for hiding this comment

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

Nice, this bit of doc is a perfect overview. Thanks!

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #5708 (comment) was created by @jmarantz.

see: more, trace.

@jmarantz
Copy link
Contributor Author

@ggreenway can you give this a senior-committer review? Thanks!

@jmarantz jmarantz requested a review from ggreenway January 29, 2019 00:27
Copy link
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

Just one grammar nit, then I think it's good to go. Feel free to merge without me seeing it again.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
@jmarantz
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #5708 (comment) was created by @jmarantz.

see: more, trace.

@jmarantz jmarantz merged commit 197acd8 into envoyproxy:master Jan 29, 2019
@jmarantz jmarantz deleted the test-time-global branch January 29, 2019 04:35
danzh2010 pushed a commit to danzh2010/envoy that referenced this pull request Jan 31, 2019
…d plumbing, and avoid multi-time-system test confusion. (envoyproxy#5708)

* Enforce TimeSystem being a true singleton. Share delagation logic via template & subclass.
* Add description in test/README.md of the time-system and how to test with it.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
jmarantz added a commit to jmarantz/envoy-filter-example that referenced this pull request Mar 1, 2019
…est-scoped singleton introduced in envoyproxy/envoy#5708

Signed-off-by: Joshua Marantz <jmarantz@google.com>
dnoe pushed a commit to envoyproxy/envoy-filter-example that referenced this pull request Mar 1, 2019
…est-scoped singleton introduced in envoyproxy/envoy#5708 (#79)

This constructor no longer makes sense in the context of the global test-scoped singleton introduced in envoyproxy/envoy#5708 (#79)

Signed-off-by: Joshua Marantz <jmarantz@google.com>
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
…d plumbing, and avoid multi-time-system test confusion. (envoyproxy#5708)

* Enforce TimeSystem being a true singleton. Share delagation logic via template & subclass.
* Add description in test/README.md of the time-system and how to test with it.

Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Fred Douglas <fredlas@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