Skip to content
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

Network Server uplink fixes and improvements #912

Merged
merged 31 commits into from
Jul 3, 2019
Merged

Conversation

rvolosatovs
Copy link
Contributor

@rvolosatovs rvolosatovs commented Jul 2, 2019

Summary

Combination of
#872
#863
#858
#870
#860

Changes

See the PRs referenced above.

Notes for Reviewers

Preserved merges, rebased on top of master and added 3 minor commits to this:
64c6bb8
46e98fc
d6f77b1
c829d6c @htdvisser
3a8ae54 @johanstokking

@rvolosatovs rvolosatovs added the c/network server This is related to the Network Server label Jul 2, 2019
@rvolosatovs rvolosatovs added this to the July 2019 milestone Jul 2, 2019
@rvolosatovs rvolosatovs requested a review from johanstokking July 2, 2019 15:43
@rvolosatovs rvolosatovs requested a review from htdvisser as a code owner July 2, 2019 15:43
@rvolosatovs rvolosatovs self-assigned this Jul 2, 2019
johanstokking
johanstokking previously approved these changes Jul 2, 2019
Copy link
Member

@johanstokking johanstokking left a comment

Choose a reason for hiding this comment

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

Code LGTM

Did you test on metal? Like the Getting Started flow?

Also rebase branch and have merge commits removed before merging

@rvolosatovs
Copy link
Contributor Author

I originally preserved the merge commits on purpose, as mentioned in description.
The whole thing was tested on metal before event changes were made, but those only concern testing.

defer test.SetDefaultEventsPubSub(&test.MockEventPubSub{
PublishFunc: func(ev events.Event) {
switch name := ev.Name(); name {
case "gs.up.receive", "gs.down.tx.success", "gs.down.tx.fail", "gs.status.receive":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to refactor this into using the assertions in test package, but there are too many unhandled events published in the test script, so I adapted it in such a way.

Copy link
Member

Choose a reason for hiding this comment

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

What would be the preferred way instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Catch and assert all events published. (e.g. gs.gateway.{dis,}connect, gs.up.drop, etc.)

@rvolosatovs rvolosatovs added the blocking Another issue or pull request is waiting for this label Jul 3, 2019
@@ -664,9 +657,30 @@ func TestGatewayServer(t *testing.T) {
t.Run(tc.Name, func(t *testing.T) {
a := assertions.New(t)

testCtx := test.ContextWithT(test.Context(), t)
testCtx, cancel := context.WithTimeout(testCtx, 5*timeout)
Copy link
Member

Choose a reason for hiding this comment

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

What is the benefit of this?

Now if operation 1 takes longer than timeout, it passes on to operation 2 which may not have enough time to finish, causing the wrong part of the test to fatal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The time.After(timeout) was used in the select statement in order to prevent deadlocks, right? AFAIK there's no predefined time interval, within which an operation has to finish.
Given this, this approach achieves exactly the same goal as the old time.After(timeout), however not it's done on per-testcase basis, not per-operation.

  1. The ctx.Done() can be used not only by the test cases, but also by the functions, taking ctx (not relevant here, but is often the case in other tests)
  2. If an operation 1 took a bit longer than timeout, the test case should not fail IMO, it should continue execution, since the timeout value is just an arbitrary value we chose to avoid deadlocks.

Please note that the context timeout is 5*timeout, which seemed to approximate the worst-case timeout ceiling used in previous approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To address case you describe exactly: if operation 1 took longer than timeout, but succeeded, then the timeout value is too low

Copy link
Member

Choose a reason for hiding this comment

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

The time.After(timeout) was used in the select statement in order to prevent deadlocks, right?

No, it is used for testing timeouts of steps.

AFAIK there's no predefined time interval, within which an operation has to finish.

It's not about the time interval, it is about giving each step a certain time to finish.

Again, what is the benefit of a timeout context? I get the context cancellation part for the test, but simply not the timeout.

To address case you describe exactly: if operation 1 took longer than timeout, but succeeded, then the timeout value is too low

The problem is that if you have a timeout of 100 and you have 5 operations, that there's a timeout after 500, right? So if operation 1 takes 490, operation 2 is very unlikely to finish in the remaining 10, so it gives a "operation 2 timeout" error, while that is not the correct fatal.

defer test.SetDefaultEventsPubSub(&test.MockEventPubSub{
PublishFunc: func(ev events.Event) {
switch name := ev.Name(); name {
case "gs.up.receive", "gs.down.tx.success", "gs.down.tx.fail", "gs.status.receive":
Copy link
Member

Choose a reason for hiding this comment

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

What would be the preferred way instead?

@johanstokking johanstokking self-requested a review July 3, 2019 08:21
@johanstokking johanstokking dismissed their stale review July 3, 2019 09:07

GS changes

@rvolosatovs
Copy link
Contributor Author

rvolosatovs commented Jul 3, 2019

@johanstokking please see updated changes(f5b65d1)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 73.176% when pulling 54c3392 on feature/ns-uplink into 26427e9 on master.

@rvolosatovs rvolosatovs merged commit f1813e8 into master Jul 3, 2019
@rvolosatovs rvolosatovs deleted the feature/ns-uplink branch July 3, 2019 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocking Another issue or pull request is waiting for this c/network server This is related to the Network Server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants