Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
35b97a7
all tests working
jmarantz Jan 24, 2019
4ab3d4c
Merge branch 'master' into test-time-global
jmarantz Jan 24, 2019
43bcff1
cleanup
jmarantz Jan 24, 2019
43cf4ba
Enforce TimeSystem being a true singleton. Share delagation logic via…
jmarantz Jan 24, 2019
8ecee51
Removed some TimeProviders.
jmarantz Jan 24, 2019
d5d2c68
Remove rest of time-system providers.
jmarantz Jan 24, 2019
71cd01c
Merge branch 'master' into test-time-global
jmarantz Jan 24, 2019
9950c87
Clean up comments, add unit test.
jmarantz Jan 25, 2019
41a9341
Merge branch 'master' into test-time-global
jmarantz Jan 25, 2019
27037c7
Retain a context for sharing the time-system in the contention test. …
jmarantz Jan 25, 2019
ebc3115
Cleanup some superfluous declarations and commented-out code.
jmarantz Jan 25, 2019
5a12891
Remove expected-output string from EXPECT_DEATH, as it seemed to fail…
jmarantz Jan 25, 2019
00e8e27
Use EXPECT_DEATH_LOG_TO_STDERR which appears to work with assertion m…
jmarantz Jan 25, 2019
e14f910
format fix.
jmarantz Jan 25, 2019
7987eec
Merge branch 'master' into test-time-global
jmarantz Jan 25, 2019
52cfeb7
Change the commenting to encourage users to use SimulatedTimeSystem
jmarantz Jan 25, 2019
5f74b89
Merge branch 'master' into test-time-global
jmarantz Jan 25, 2019
0cc864f
Merge branch 'master' into test-time-global
jmarantz Jan 26, 2019
5024e2c
Merge branch 'master' into test-time-global
jmarantz Jan 28, 2019
70d4261
Convert ASSERT to RELEASE_ASSERT.
jmarantz Jan 28, 2019
25a8190
Merge branch 'master' into test-time-global
jmarantz Jan 28, 2019
4ab76c8
Add description in test/README.md of the time-system and how to test …
jmarantz Jan 28, 2019
6712708
grammar tweaks
jmarantz Jan 28, 2019
a35d223
Switch TODO to reference #4160
jmarantz Jan 28, 2019
32ce33e
Fix typos.
jmarantz Jan 28, 2019
d45dd4a
fix grammar error.
jmarantz Jan 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,31 @@ Examples:
EXPECT_THAT(response->headers(), IsSubsetOfHeaders(allowed_headers));
EXPECT_THAT(response->headers(), IsSupersetOfHeaders(required_headers));
```

## Controlling time in tests

In Envoy production code, time and timers are managed via
[`Event::TimeSystem`](https://github.com/envoyproxy/envoy/blob/master/include/envoy/event/timer.h),
which provides a mechanism for querying the time setting up time-based callbacks. Bypassing
Comment thread
jmarantz marked this conversation as resolved.
Outdated
this abstraction in Envoy code is flagged as a format violation in CI.

In tests we use a deriviation
Comment thread
jmarantz marked this conversation as resolved.
Outdated
[`Event::TestTimeSystem`](test_common/test_time_system.h) which adds the ability
to sleep or do a blocking timed wait on a condition variable. There are two
implementations of the `Event::TestTimeSystem` interface:
`Event::TestRealTimeSystem`, and `Event::SimulatedTimeSystem`. The latter is
recommended for all new tests, as it helps avoid flaky tests on slow machines.

Typically we do not want to have both real-time and simulated-time in the same
test; that could lead to hard-to-reproduce results. Thus both implementations
have a mechanism to enforce that only one of them can be instantiated at once.
A runtime assertion occurs if a `Event::TestRealTimeSystem` and
`Event::SimulatedTimeSystem` are instantiated at the same time. Once the
time-systems go out of scope, usually at the end of of a test method, the slate
Comment thread
jmarantz marked this conversation as resolved.
Outdated
is clean and a new test-method can use a different time system.

There is also `Event::GlobalTimeSystem`, which can be instantiated in shared
test infrastructure that wants to be agnostic to which `TimeSystem` is used in a
test. When no `TimeSystem` is instantiated in a test, the `Event::GlobalTimeSystem`
will lazy-initialize itself into a concrete `TimeSystem` -- currently this is
`TestRealTimeSystem` but will be changed in the future to `SimulatedTimeSystem`.
2 changes: 2 additions & 0 deletions tools/check_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ def whitelistedForProtobufDeps(file_path):
# specific cases. They should be passed down from where they are instantied to where
# they need to be used, e.g. through the ServerInstance, Dispatcher, or ClusterManager.
def whitelistedForRealTime(file_path):
if file_path.endswith(".md"):
return True
return file_path in REAL_TIME_WHITELIST


Expand Down