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

Test main loop #6

Merged
merged 5 commits into from
Jun 6, 2024
Merged

Test main loop #6

merged 5 commits into from
Jun 6, 2024

Conversation

msf
Copy link
Contributor

@msf msf commented Jun 5, 2024

Obvious, creating tests found bugs and forced some changes :-)

but at least we validate some basic cases

@msf msf requested review from vegarsti and helanto June 5, 2024 15:38
@msf msf changed the base branch from main to step-3-main-control June 5, 2024 15:38
Copy link
Member

@vegarsti vegarsti left a comment

Choose a reason for hiding this comment

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

Great!

ingester.Run(context.Background(), &wg)
go func() {
defer wg.Done()
err := ingester.Run(context.Background(), cfg.BlockHeight, 0 /* maxCount */)
Copy link
Member

Choose a reason for hiding this comment

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

I didn't realize /* */ was valid in Go!

@@ -12,7 +11,8 @@ import (
)

type Ingester interface {
Run(ctx context.Context, wg *sync.WaitGroup) error
// Run starts the ingester and blocks until the context is cancelled or maxCount blocks are ingested
Run(ctx context.Context, startBlockNumber, maxCount int64) error
Copy link
Member

@vegarsti vegarsti Jun 5, 2024

Choose a reason for hiding this comment

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

maxCount 🤔 EDIT: Nevermind, tests made it clear why we want this

inFlightChan := make(chan models.RPCBlock, i.cfg.MaxBatchSize)
defer close(inFlightChan)

var err error

startBlockNumber := i.cfg.StartBlockHeight
if startBlockNumber <= 0 {
if startBlockNumber < 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Good! We do indeed want block 0

"github.com/stretchr/testify/require"
)

func TestBlockConsumptionLoopErrors(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

It's not immediately clear to me what this test is testing. Is it testing that we exit the function cleanly under these scenarios + what blocks have been ingested? Or am I misunderstanding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test is bogus right now, because I realized (while trying to get this test any decent) that the logic I created is just bad...

The problem is:

  • we should be able to cancel execution (using the context) and have a good understanding if the execution was smooth, flaky, or we were under a busted scenario.
  • for example, with everything broken, I think there should be an early return and just abort execution ? or should we just stay alive and keep trying?
  • if execution is flaky, we should still consume blocks, but skip some, right ?

in short, this test just shows we're a bit confused on what to expect from the test.

}
for _, testcase := range testcases {
t.Run(testcase, func(t *testing.T) {
t.Skip("not implemented")
Copy link
Member

Choose a reason for hiding this comment

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

Add a TODO?

}

func TestRunLoop(t *testing.T) {
t.Skip("not implemented")
func TestRunLoopBaseCase(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice

@msf msf changed the base branch from step-3-main-control to main June 6, 2024 09:24
@msf msf merged commit 423f955 into main Jun 6, 2024
1 check passed
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