-
Notifications
You must be signed in to change notification settings - Fork 94
Adaptive Load fake time source #491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dubious90
merged 40 commits into
envoyproxy:master
from
eric846:adaptive-rps-fake-time-source
Aug 27, 2020
Merged
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
8ea442d
Merge pull request #5 from envoyproxy/master
eric846 5ac755a
Merge pull request #6 from envoyproxy/master
eric846 b8c25a5
Merge pull request #7 from envoyproxy/master
eric846 1c19c68
initial commit
eric846 7050686
fix comments
eric846 0776563
fix format
eric846 16fd8f6
rename adaptive_rps to adaptive_load
eric846 c383010
add field_selector in example
eric846 6e1a483
fix example comment
eric846 4ef1140
fix format
eric846 4111bf4
add support for fault injection headers
eric846 871a959
replace linear and binary search with exponential search
eric846 1fd77c1
add InputVariableSetter mechanism
eric846 edc36b2
add input variable setter to build file
eric846 4d0364e
fix syntax errors
eric846 aed6d94
rename samples/adaptive_rps
eric846 d9ae87d
improve comments, change step controller initial value from int64 to …
eric846 a05a6f5
add proto validation rules, fix comments, make rps the default input_…
eric846 8cd4d21
fix comment wording
eric846 d814a96
simplify protos, add defaults, specify required or optional
eric846 5f5a885
add missing newline
eric846 7e20a78
Kick CI
eric846 9048267
simplify protos
eric846 306c0ec
fix format
eric846 d33f543
fix some optional field comments and rules
eric846 442cca9
Merge pull request #10 from envoyproxy/master
eric846 677b783
add Nighthawk status field in BenchmarkResult as nested nighthawk.cli…
eric846 cefb366
switch to standard Envoy plugin config proto, add prefix to internal …
eric846 f3684df
Merge remote-tracking branch 'upstream/master' into adaptive-rps-protos2
eric846 5463051
create headers
eric846 46e0e25
fix format
eric846 f634642
use docstring format
eric846 3c39faa
fix typos in comments
eric846 b9c8f2b
split build target, get rid of ostream, change InputValueSetter to us…
eric846 5fc4db4
remove nested namespace, remove redundant _include in target names
eric846 64e7852
merge from upstream
eric846 12807f1
Merge remote-tracking branch 'upstream/master' into adaptive-rps-headers
eric846 e8e960f
merge from upstream
eric846 78ed3b7
initial commit - fake time source
eric846 13b5dc2
move from test/adaptive_load to test/common
eric846 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #include "test/adaptive_load/fake_time_source.h" | ||
|
|
||
| namespace Nighthawk { | ||
|
|
||
| Envoy::SystemTime FakeIncrementingMonotonicTimeSource::systemTime() { | ||
| Envoy::SystemTime epoch; | ||
| return epoch; | ||
| } | ||
|
|
||
| Envoy::MonotonicTime FakeIncrementingMonotonicTimeSource::monotonicTime() { | ||
| Envoy::MonotonicTime epoch; | ||
| Envoy::MonotonicTime result = epoch + std::chrono::seconds(seconds_since_epoch_); | ||
| ++seconds_since_epoch_; | ||
| return result; | ||
| } | ||
|
|
||
| } // namespace Nighthawk | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/common/time.h" | ||
|
|
||
| namespace Nighthawk { | ||
| /** | ||
| * Fake time source that ticks 1 second on every query, starting from the Unix epoch. Supports only | ||
| * monotonicTime(). | ||
| */ | ||
| class FakeIncrementingMonotonicTimeSource : public Envoy::TimeSource { | ||
| public: | ||
| /** | ||
| * Not supported. | ||
| * | ||
| * @return Envoy::SystemTime Fixed value of the Unix epoch. | ||
| */ | ||
| Envoy::SystemTime systemTime() override; | ||
| /** | ||
| * Ticks forward 1 second on each call. | ||
| * | ||
| * @return Envoy::MonotonicTime Fake time value. | ||
| */ | ||
| Envoy::MonotonicTime monotonicTime() override; | ||
|
|
||
| private: | ||
| int seconds_since_epoch_{0}; | ||
| }; | ||
|
|
||
| } // namespace Nighthawk |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #include "test/adaptive_load/fake_time_source.h" | ||
|
|
||
| #include "gtest/gtest.h" | ||
|
|
||
| namespace Nighthawk { | ||
| namespace { | ||
|
|
||
| TEST(FakeIncrementingMonotonicTimeSource, SystemTimeAlwaysReturnsEpoch) { | ||
| FakeIncrementingMonotonicTimeSource time_source; | ||
| Envoy::SystemTime epoch; | ||
| EXPECT_EQ(time_source.systemTime(), epoch); | ||
| EXPECT_EQ(time_source.systemTime(), epoch); | ||
| } | ||
|
|
||
| TEST(FakeIncrementingMonotonicTimeSource, MonotonicTimeStartsFromEpoch) { | ||
| FakeIncrementingMonotonicTimeSource time_source; | ||
| Envoy::MonotonicTime epoch; | ||
| Envoy::MonotonicTime time = time_source.monotonicTime(); | ||
| EXPECT_EQ(std::chrono::duration_cast<std::chrono::seconds>(time - epoch).count(), 0); | ||
| } | ||
|
|
||
| TEST(FakeIncrementingMonotonicTimeSource, MonotonicTimeIncrementsOneSecondPerCall) { | ||
| FakeIncrementingMonotonicTimeSource time_source; | ||
| Envoy::MonotonicTime time1 = time_source.monotonicTime(); | ||
| Envoy::MonotonicTime time2 = time_source.monotonicTime(); | ||
| Envoy::MonotonicTime time3 = time_source.monotonicTime(); | ||
| EXPECT_EQ(std::chrono::duration_cast<std::chrono::seconds>(time2 - time1).count(), 1); | ||
| EXPECT_EQ(std::chrono::duration_cast<std::chrono::seconds>(time3 - time2).count(), 1); | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace Nighthawk |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry, I was looking at this in the context of
ThreadSafeMonoticTimeSourcewhich might also be coming up, to see where this ended up in terms of physical location. I wonder if instead of placing this undertest/adaptive_load/, moving it into a shared directory liketest/common/would be possible?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
('common' might not be the best name actually, but imho this ends up in a place where in terms of directory layout this and a new non-test time source would both end up with a consistent location,
test/fooandsource/foo)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. Holding off on merging until Eric weighs in on where this should live.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to
test/common.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of
test/common?source/commontest/adaptive_loadsince a fake time source has nothing to do with adaptive load.test/.test/test_commonlooks like something we are forced to have by Envoy precedent but didn't make sense for other Nighthawk stuff?ThreadSafeMonotonicTimeSourceand could be used from them if it made sense.If we rearrange the whole
test/directory later, we can easily eliminatetest/commonif there's an alternative.