-
Notifications
You must be signed in to change notification settings - Fork 501
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
Conversation
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.
3016153
to
cccbe0b
Compare
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.
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. |
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.
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.
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.
Ops, I saw this after merging. I will incorporate it later, thanks.
ctx, cancel := context.WithTimeout(context.Background(), time.Second) | ||
defer cancel() | ||
return i.cclient.ManualClose(ctx) |
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.
Logging can be helpful with debugging.
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) |
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.
Note taken, thanks.
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.