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

tests: Fix devmode test #5334

Merged
merged 11 commits into from
Apr 26, 2023
Merged

Conversation

Eric-Warehime
Copy link
Contributor

@Eric-Warehime Eric-Warehime commented Apr 24, 2023

Summary

Re-enables this devmode test.

Closes #3267 (though I've not been able to see the slow/flakiness happen). It's possible that re-enabling this will just cause nightlies to fail periodically, but the nightly run I did has not failed in this way yet.

We should keep an eye on the nightlies and see if this is still causing flakiness.

Test Plan

Ran nightly tests on this to validate that the test passes on them (since it will be skipped during regular per-PR CI runs).

Here is the resulting run: https://app.circleci.com/pipelines/github/algorand/go-algorand/13978/workflows/ba87d853-cec2-4473-86f4-c7fdd65caa66

The one failure in that is from an unrelated issues relating to running the nightly tests on a fork branch.

@Eric-Warehime Eric-Warehime marked this pull request as ready for review April 24, 2023 23:06
Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

Looks promising, but after around 10 minutes hunting for the log that shows the that devmode_test.go ran I couldn't find it. Would you mind providing a link?

(I started my search with the link you previously provided: https://app.circleci.com/pipelines/github/algorand/go-algorand/13978/workflows/ba87d853-cec2-4473-86f4-c7fdd65caa66)

Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

Looking good - I think the test run is reported on this line: https://app.circleci.com/pipelines/github/algorand/go-algorand/13978/workflows/ba87d853-cec2-4473-86f4-c7fdd65caa66/jobs/227972/parallel-runs/2?filterBy=ALL&invite=true#step-114-453

I can't really tell if this test will be flaky or not based on one run, but it looks okay here (executed within 15.78 seconds, whereas the test will fail after ~19 seconds).

Also I'm not sure if waiting 8 seconds for 2 transaction confirmations is enough to differentiate dev mode from a normal network (or whether this will be future proof if block times get faster)?

Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

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

Per live discussion: we can avoid the timing issue by using the new round offset feature. This should allow the test to run without sleeping and verify that transactions were created with devmode.

Comment on lines 76 to 77
// Without transactions there should be no rounds even after a normal confirmation time.
time.Sleep(10 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about removing the second phase of this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems fine to me.

require.Equal(t, round-1, uint64(txn.Txn.Txn.FirstValid))
newBlk, err := fixture.AlgodClient.Block(round)
require.NoError(t, err)
newBlkSeconds, _ := math.Modf(newBlk.Block["ts"].(float64))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason to prefer math.Modf(...) over int(...) here?

Copy link
Contributor

Choose a reason for hiding this comment

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

On my local machine, removing math.Modf seems to do the same thing and passes the checks:

Suggested change
newBlkSeconds, _ := math.Modf(newBlk.Block["ts"].(float64))
newBlkSeconds, _ := newBlk.Block["ts"].(float64)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

None that I know of.

newBlk, err := fixture.AlgodClient.Block(round)
require.NoError(t, err)
newBlkSeconds, _ := math.Modf(newBlk.Block["ts"].(float64))
require.GreaterOrEqual(t, time.Unix(int64(newBlkSeconds), 0), startTime.Add(1_000_000*time.Second))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this deterministic now?

Suggested change
require.GreaterOrEqual(t, time.Unix(int64(newBlkSeconds), 0), startTime.Add(1_000_000*time.Second))
require.Equal(t, time.Unix(int64(newBlkSeconds), 0), startTime.Add(1_000_000*time.Second))

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 think we need to keep it greater than or equal because the offset is just added to the clock time. So two separate txns 1 second apart could have block times 1_000_001 seconds apart if the offset is 1_000_000.

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be added to the previous block time, so I'm pretty sure this is deterministic.

@algochoi correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true @winder . The current test needs to be modified so that the initial seconds or startTime is updated inside the loop. The second iteration will make the delta 2 million seconds so the equal will fail the second 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.

Done.

Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

LGTM - I'm not sure if this was run on CI (since the short flag is up), but the test passes locally

require.Equal(t, round-1, uint64(txn.Txn.Txn.FirstValid))
newBlk, err := fixture.AlgodClient.Block(round)
require.NoError(t, err)
newBlkSeconds, _ := math.Modf(newBlk.Block["ts"].(float64))
Copy link
Contributor

Choose a reason for hiding this comment

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

On my local machine, removing math.Modf seems to do the same thing and passes the checks:

Suggested change
newBlkSeconds, _ := math.Modf(newBlk.Block["ts"].(float64))
newBlkSeconds, _ := newBlk.Block["ts"].(float64)

test/e2e-go/features/devmode/devmode_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

thanks!!

@tzaffi
Copy link
Contributor

tzaffi commented Apr 26, 2023

Lgtm

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

Successfully merging this pull request may close these issues.

Fix Slow DevMode Test (TestDevMode)
4 participants