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

services/horizon: Update integration tests to use MANUAL_CLOSE #3167

Merged
merged 1 commit into from
Oct 28, 2020

Conversation

2opremio
Copy link
Contributor

@2opremio 2opremio commented Oct 28, 2020

What

Use Core's MANUAL_CLOSE mode in integration tests so that we don't have to wait for ledgers to be closed (we close them explicitly).

Why

It considerably reduces the execution time of integration tests (From ~13min to ~5min).

Also, it paves the way for enabling integration tests for Captive Core (#3153) and contributes towards #3037 .

Known limitations

We are changing the timing in which the production network operates, which makes the tests deviate from a production scenario.

@2opremio 2opremio requested a review from a team October 28, 2020 10:39
@cla-bot cla-bot bot added the cla: yes label Oct 28, 2020
Use Core's `MANUAL_CLOSE` mode in integration tests so that we don't
have to wait for ledgers to be closed (we close them explicitly).

This paves the way for enabling integration tests for Captive Core.
@2opremio 2opremio force-pushed the integration-manual-close branch from 3016153 to cccbe0b Compare October 28, 2020 10:43
Copy link
Contributor

@bartekn bartekn left a comment

Choose a reason for hiding this comment

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

Awesome!

// blocks until the transaction is in a closed ledger
go func() {
// This sleep is ugly, but a better approach would probably require
// instrumenting Horizon to tell us when the transaction was sent to core.
Copy link
Contributor

@bartekn bartekn Oct 28, 2020

Choose a reason for hiding this comment

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

Nit: we can start 2 go routines:

  • First one with SubmitTransactionXDR that will write to unbuffered channel when done.
  • Second that closes core ledgers in an infinite loop with a select statement with 2 cases: a) time.After, b) on a unbuffered channel from previous point.

This way when submission is done, second go routine will escape (unbuffered channel), but if not it will close another ledger after some time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ops, I saw this after merging. I will incorporate it later, thanks.

Comment on lines +642 to +644
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
return i.cclient.ManualClose(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Logging can be helpful with debugging.

Suggested change
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
return i.cclient.ManualClose(ctx)
i.t.Log("Closing ledger manually...")
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
return i.cclient.ManualClose(ctx)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note taken, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants