Skip to content

Add "no-duration" to facilitate infinite load generation#366

Merged
mum4k merged 7 commits intoenvoyproxy:masterfrom
oschaaf:infinite-execution-duration
Jun 18, 2020
Merged

Add "no-duration" to facilitate infinite load generation#366
mum4k merged 7 commits intoenvoyproxy:masterfrom
oschaaf:infinite-execution-duration

Conversation

@oschaaf
Copy link
Copy Markdown
Member

@oschaaf oschaaf commented Jun 16, 2020

Adds --no-duration, which will be treated as a request to infinitely
continue load generation. Other default predicates will still exist, so
execution may still stop when connection failures or error response codes
are observed.

This leaves some small tech debt:

Fixes #333

Signed-off-by: Otto van der Schaaf oschaaf@we-amp.com

With this, --duration 0 will be treated as a request to infinitely
execute. Other default predicates will still exist, to execution
may stop when connection failures or error response codes are
observed.

This leaves some small tech debt:

- We shouldn't need to create a foo root termination predicate
- We need test coverage, but that's much to add once
  envoyproxy#280 or envoyproxy#344 goes in

Fixes envoyproxy#333

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf oschaaf added P1 waiting-for-review A PR waiting for a review. labels Jun 16, 2020
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Jun 16, 2020

/cc @howardjohn

@oschaaf oschaaf changed the title Treat zero-valued --duration flag as infine Treat zero-valued --duration flag as infinite Jun 16, 2020
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf oschaaf requested a review from howardjohn June 16, 2020 22:32
howardjohn
howardjohn previously approved these changes Jun 16, 2020
Copy link
Copy Markdown

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

Not sure about the code but the user facing changes are what I pictured. Thanks!

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
oschaaf added 2 commits June 17, 2020 12:24
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
once we can have good means to test this.

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
time_source, options_.duration(), scheduled_starting_time);
TerminationPredicate* current_predicate = duration_predicate.get();
TerminationPredicatePtr root_predicate = std::make_unique<NullTerminationPredicateImpl>();
if (options_.duration() > 0s) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This may be a bit surprising to unaware users. Especially if zero is the default.

Additionally what would happen in the gRPC world if we send a request to the NH server with an infinite duration and how will the client terminate such a run and get the results? The same question likely applies to local runs - how do we terminate and get results?

Do we want to do some or all of the following?
a) print out on the screen + log saying that this is a run with an infinite duration and an instruction of how to terminate it.
b) should we use -1 instead of zero to avoid the "runs infinitely by default" situation? It would also help to make this change backwards compatible.
c) should we improve the documentation of the option indicating how does one terminate an infinite run and get results?

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 may be a bit surprising to unaware users. Especially if zero is the default.

Our default duration actually is 5 seconds, but that gets defined elsewhere in the options implementation header. That part doesn't change in this PR.

Additionally what would happen in the gRPC world if we send a request to the NH server with an infinite duration and how will the client terminate such a run and get the results? The same question likely applies to local runs - how do we terminate and get results?

For local runs, there's no way to terminate (gracefully) today. But this PR purposely didn't worry about that, as the feature was requested in a context where results are irrelevant. So this PR helps by proving a way to just generate infinite load.
The gRPC service would behave identical.

However, I did have similar thoughts before starting on this, so I also added a follow up to that teaches the CLI about handling signals and wires through a way for ProcessImpl to quickly and gracefully exit and yield results. RemoteProcessImpl still has a TODO for that, but the path I had in mind there would send a gRPC message to request cancellation of the currently active ProcessImpl over there, which would then be propagated to the active ProcessImpl running within this service -- if any (we can only have a single one active at a time today).

Do we want to do some or all of the following?
a) print out on the screen + log saying that this is a run with an infinite duration and an instruction of how to terminate it.

Right now the CLI will print that execution will target 0 seconds via an informational log line. I will make that print out "infinite" instead.

b) should we use -1 instead of zero to avoid the "runs infinitely by default" situation? It would also help to make this change backwards compatible.

Alternatively, we could also try to add an explicit --no-duration flag, and make this value an internal detail. If we back out the current change, zero would be suitable for that, as we guard against that value being set by the user. I can go either way.

c) should we improve the documentation of the option indicating how does one terminate an infinite run and get results?
That probably belongs in the follow up I mentioned above?

TerminationPredicate* current_predicate = duration_predicate.get();
TerminationPredicatePtr root_predicate = std::make_unique<NullTerminationPredicateImpl>();
if (options_.duration() > 0s) {
root_predicate = std::make_unique<DurationTerminationPredicateImpl>(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Readability wise - it may be better to have an explicit if<->else rather then set a value and modify it after. The latter may confuse the reader if they don't notice the modification under the if statement.

Consider (pseudo code):
root_predicate = NULL
if (finite_run) {
root_predicate = TerminateAt...
} else {
root_predicate = NeverTerminate
}

};

/**
* Predicate which always returns the passed in termination status.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Doesn't seem to accept any parameters, does the doc comment need an update?

@@ -41,7 +41,7 @@ COVERAGE_VALUE=${COVERAGE_VALUE%?}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we (for now) add a TODO pointing to an issue about the missing test coverage? Not sure if this is the right file, so feel free to add it in the appropriate location.

@mum4k mum4k added waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. and removed waiting-for-review A PR waiting for a review. labels Jun 17, 2020
@mum4k mum4k self-requested a review June 17, 2020 20:29
@mum4k mum4k self-assigned this Jun 17, 2020
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@oschaaf
Copy link
Copy Markdown
Member Author

oschaaf commented Jun 18, 2020

@mum4k Comments addressed in f3a7ee8. As proposed on Slack, that commit changes this PR to use --no-duration instead of a magical value.

@oschaaf oschaaf added waiting-for-review A PR waiting for a review. and removed waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. labels Jun 18, 2020
Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
@mum4k mum4k added waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. and removed waiting-for-review A PR waiting for a review. labels Jun 18, 2020
@oschaaf oschaaf changed the title Treat zero-valued --duration flag as infinite Add "no-duration" to facilitate infinite load generation Jun 18, 2020
@mum4k mum4k merged commit e23a861 into envoyproxy:master Jun 18, 2020
oschaaf added a commit to oschaaf/nighthawk that referenced this pull request Jun 24, 2020
In envoyproxy#366 we had to lower the coverage threshold as that PR didn't come
with the means to easily cover testing with infinite excecution
durations. Now that we have signal handling in place, we can easily
pull this off.

Fixes envoyproxy#370

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
mum4k pushed a commit that referenced this pull request Jun 25, 2020
…384)

In #366 we had to lower the coverage threshold as that PR didn't come
with the means to easily cover testing with infinite excecution
durations. Now that we have signal handling in place, we can easily
pull this off.

Fixes #370

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
wjuan-AFK pushed a commit to wjuan-AFK/nighthawk that referenced this pull request Jul 14, 2020
…nvoyproxy#384)

In envoyproxy#366 we had to lower the coverage threshold as that PR didn't come
with the means to easily cover testing with infinite excecution
durations. Now that we have signal handling in place, we can easily
pull this off.

Fixes envoyproxy#370

Signed-off-by: Otto van der Schaaf <oschaaf@we-amp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 waiting-for-changes A PR waiting for comments to be resolved and changes to be applied.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow --duration=0 or infinite duration

3 participants