Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
da7f24a
Remove singletons for time-sources and inject them instead.
jmarantz Aug 16, 2018
7d59de4
checkpoint with more stuff compiling, a few tests still fail due to c…
jmarantz Aug 16, 2018
10422d4
checkpoinging: all of //test/common/... compiles, 4 tests still fail …
jmarantz Aug 16, 2018
282307f
//test/common/... all pass.
jmarantz Aug 16, 2018
fa5c8c8
More of //test/... builds, some of it works.
jmarantz Aug 17, 2018
8d67f55
All tests compiling and working.
jmarantz Aug 17, 2018
c9a7d62
More comments and TODOs.
jmarantz Aug 17, 2018
2d9f2aa
Pass the TimeSource into the WorkerFactory's ctor rather than into Wo…
jmarantz Aug 17, 2018
1a84061
Fix race found in coverage tests due to order of destruction. Uncomme…
jmarantz Aug 17, 2018
eb2347e
Don't bother using a whole TimeSource for TokenBucketImpl -- all it n…
jmarantz Aug 17, 2018
21ac418
More API cleanups and TODOs.
jmarantz Aug 17, 2018
0a2514c
Kick CI
jmarantz Aug 17, 2018
c642dbc
Merge branch 'master' into inject-time-source
jmarantz Aug 22, 2018
646a500
formatting.
jmarantz Aug 22, 2018
e65a754
Add comment about preserving entropy in the future, when we move to m…
jmarantz Aug 22, 2018
50dbb33
Merge branch 'master' into inject-time-source
jmarantz Aug 22, 2018
c1f0dba
Add check_format for instantiating time-sources in a new source file …
jmarantz Aug 22, 2018
5338985
Address review comments.
jmarantz Aug 23, 2018
edba780
Revert "Address review comments."
jmarantz Aug 23, 2018
be44f2d
Address review comments.
jmarantz Aug 23, 2018
1488d58
Kick CI
jmarantz Aug 23, 2018
44d880d
Merge branch 'master' into inject-time-source
jmarantz Aug 23, 2018
416917f
Address review comments.
jmarantz Aug 23, 2018
c33f66c
Merge branch 'inject-time-source' into limit-prod-timesource
jmarantz Aug 23, 2018
6d9fac6
Rename 'TestTime' to 'RealTestTime' and add TODO to change all tests …
jmarantz Aug 23, 2018
8855c5a
Merge branch 'inject-time-source' into limit-prod-timesource
jmarantz Aug 23, 2018
46ad91d
replace RealTestTime with DangerousDeprecatedTestTime
jmarantz Aug 24, 2018
692a23c
Merge branch 'master' into limit-prod-timesource
jmarantz Aug 24, 2018
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
18 changes: 18 additions & 0 deletions tools/check_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
GOOGLE_PROTOBUF_WHITELIST = ("ci/prebuilt", "source/common/protobuf", "api/test")
REPOSITORIES_BZL = "bazel/repositories.bzl"

# Files matching these exact names can reference prod time. These include the class
# definitions for prod time, the construction of them in main(), and perf annotation.
# For now it includes the validation server but that really should be injected too.
PROD_TIME_WHITELIST = ('./source/common/common/utility.h',
'./source/exe/main_common.cc',
'./source/exe/main_common.h',
'./source/server/config_validation/server.cc',
'./source/common/common/perf_annotation.h')

CLANG_FORMAT_PATH = os.getenv("CLANG_FORMAT", "clang-format-6.0")
BUILDIFIER_PATH = os.getenv("BUILDIFIER_BIN", "$GOPATH/bin/buildifier")
ENVOY_BUILD_FIXER_PATH = os.path.join(
Expand Down Expand Up @@ -65,6 +74,12 @@ def whitelistedForProtobufDeps(file_path):
return (file_path.endswith(PROTO_SUFFIX) or file_path.endswith(REPOSITORIES_BZL) or \
any(path_segment in file_path for path_segment in GOOGLE_PROTOBUF_WHITELIST))

# Production time sources should not be instantiated in the source, except for a few
# 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 whitelistedForProdTime(file_path):
return file_path in PROD_TIME_WHITELIST or file_path.startswith('./test/')

def findSubstringAndReturnError(pattern, file_path, error_message):
with open(file_path) as f:
text = f.read()
Expand Down Expand Up @@ -145,6 +160,9 @@ def checkSourceLine(line, file_path, reportError):
# comments, for example this one.
reportError("Don't use <mutex> or <condition_variable*>, switch to "
"Thread::MutexBasicLockable in source/common/common/thread.h")
if not whitelistedForProdTime(file_path):
if 'ProdSystemTimeSource' in line or 'ProdMonotonicTimeSource' in line:
reportError("Don't reference real-time sources from production code; use injection")

def checkBuildLine(line, file_path, reportError):
if not whitelistedForProtobufDeps(file_path) and '"protobuf"' in line:
Expand Down
8 changes: 8 additions & 0 deletions tools/check_format_test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ def checkFileExpectingOK(filename):
"Don't use <mutex> or <condition_variable*>")
errors += fixFileExpectingFailure("condition_variable_any.cc",
"Don't use <mutex> or <condition_variable*>")
errors += fixFileExpectingFailure(
"prod_system_time.cc", "Don't reference real-time sources from production code; use injection")
errors += fixFileExpectingFailure(
"prod_monotonic_time.cc", "Don't reference real-time sources from production code; use injection")

errors += fixFileExpectingNoChange("ok_file.cc")

Expand All @@ -163,6 +167,10 @@ def checkFileExpectingOK(filename):
errors += checkFileExpectingError("bad_envoy_build_sys_ref.BUILD",
"Superfluous '@envoy//' prefix")
errors += checkFileExpectingError("proto_format.proto", "clang-format check failed")
errors += checkFileExpectingError(
"prod_system_time.cc", "Don't reference real-time sources from production code; use injection")
errors += checkFileExpectingError(
"prod_monotonic_time.cc", "Don't reference real-time sources from production code; use injection")

errors += checkFileExpectingOK("ok_file.cc")

Expand Down
4 changes: 4 additions & 0 deletions tools/testdata/check_format/prod_monotonic_time.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int foo() {
ProdSystemTimeSource system_time;
ProdMonotonicTimeSource monotonic_time;
}
3 changes: 3 additions & 0 deletions tools/testdata/check_format/prod_system_time.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int foo() {
ProdMonotonicTimeSource monotonic_time;
}