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

Add E2E Testing for NFT SDK #148

Merged
merged 11 commits into from
Jun 23, 2022
Merged

Add E2E Testing for NFT SDK #148

merged 11 commits into from
Jun 23, 2022

Conversation

figintern
Copy link
Contributor

@figintern figintern commented May 17, 2022

#146

  1. Refactor record-tester to use go-api-client

  2. After record-tester finishes ->

  • Wait for Asset to be available
  • Run transcode task on that asset
  • Wait for transcoding asset to complete
  • Run export task on transcoded asset
  • Wait for export to complete
  • Check that IPFS link is available on export task

Testing locally:

~/livepeer/stream-tester % make
~/livepeer/stream-tester % ./build/recordtester -api-token 29b59cfa-3006-48b7-a5fd-fbd07073372e  -file https://storage.googleapis.com/lp_testharness_assets/bbb_sunflower_1080p_30fps_normal_2min.mp4 -test-dur 4m -continuous-test 15s -vod -stream-health true
...
I0517 04:09:47.721283   45384 recordtester_app.go:306] Record testing done, waiting for Asset to be available
I0517 04:09:47.721300   45384 recordtester_app.go:316] Waiting 30s for asset, elapsed=0s
I0517 04:10:18.172198   45384 recordtester_app.go:316] Waiting 30s for asset, elapsed=30s
I0517 04:10:48.666966   45384 recordtester_app.go:316] Waiting 30s for asset, elapsed=1m0s
I0517 04:11:19.198480   45384 recordtester_app.go:316] Waiting 30s for asset, elapsed=1m30s
I0517 04:11:50.226989   45384 recordtester_app.go:348] Asset is available id=56904bbd-46c2-4bc9-9d6a-874442340b22, transcoding taskId=cb594fd5-197c-4769-b1f8-27984623c66d outputAssetId=7b526a4e-4d28-40c7-a224-b8699c4695c9
I0517 04:11:50.227012   45384 recordtester_app.go:353] Waiting 15s for transcode output asset id=7b526a4e-4d28-40c7-a224-b8699c4695c9, elapsed=0s
I0517 04:12:06.143579   45384 recordtester_app.go:384] Transcode output asset id=7b526a4e-4d28-40c7-a224-b8699c4695c9 ready, exporting, taskId=1a51823c-3186-4330-a3a5-121335cacbad
I0517 04:12:06.143610   45384 recordtester_app.go:389] Waiting 5s for asset id=7b526a4e-4d28-40c7-a224-b8699c4695c9 to be exported, elapsed=0s
I0517 04:12:11.562321   45384 recordtester_app.go:403] Export success, task id=1a51823c-3186-4330-a3a5-121335cacbad ipfs link=https://ipfs.livepeer.com/ipfs/QmfPT1LxgpP1achTWECXkghTRqb3j7iifJSLDp4ergqSK2
I0517 04:12:11.562350   45384 recordtester_app.go:409] Done

go-api-client PR: livepeer/go-api-client#7

@figintern figintern requested a review from a team as a code owner May 17, 2022 10:45
@figintern figintern self-assigned this May 17, 2022
@figintern figintern force-pushed the tq/e2e_testing_nft_sdk branch from b8f0b32 to 7740e40 Compare May 17, 2022 10:53
@figintern figintern force-pushed the tq/e2e_testing_nft_sdk branch 3 times, most recently from bf777d1 to 6ccc921 Compare May 17, 2022 11:13
Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

The overall logic here looks good! The only bigger issue is that, even though I think I suggested that myself, I'm actually having second thoughts about including all these tests in the record-tester flow. I believe most if not all of the logic here will be the same anyway, the only difference is that I think we should have a separate command/tester just for that.

The main reasons for that are:

  • Including these tests in the same flow will introduce a big pause between test streams. There's a whole minute until a recording starts being processed to become an asset, so I expect that to add at least 5 minutes before new livestreams are made. This will increase our time for getting an alert when a region goes down.
  • Our recordings (and probably transcoding) output is not deterministic. This means that by exporting the transcoded recording to IPFS, we are going to create a new file every time. Piñata storage is preeetty expensive (I think 5x the price of an S3), so I think this bill could grow pretty quickly. We already pay thousands of dollars a month for old test recordings saved on Google S3, on Piñata it's gonna 📈. We could either find some way to unpin the file after the test is done, but I think it will be simpler if we just always export the same file to IPFS.

So a simpler VOD (NFT) specific tester could work like:

  • Start from the same video file as record-tester
  • Import that to an asset 1
  • Try transcoding that to another asset 2
  • Try exporting the asset 1 (not asset 2) to IPFS
  • Make sure all that works
  • Success, sleep and try again in a few (just like continuous_record_tester here)

Let's talk more about this next week! I'll bring it up on our planning and we can talk about it ad-hoc or schedule additional meetings to go through it as well.

cmd/recordtester/recordtester.go Outdated Show resolved Hide resolved
cmd/recordtester/recordtester.go Outdated Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Outdated Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Outdated Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Outdated Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Outdated Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Outdated Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Outdated Show resolved Hide resolved
Comment on lines 387 to 386
wait_interval = 5 * time.Second
elapsed_time = 0 * time.Second
for {
Copy link
Member

Choose a reason for hiding this comment

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

For these wait intervals, you should also consider using a time.Ticker instead for go-ishness. e.g.

Suggested change
wait_interval = 5 * time.Second
elapsed_time = 0 * time.Second
for {
ticker := time.NewTicker(5 * time.Second)
for range ticker {
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will follow-up with this

return 0, err
}

task, err := rt.lapi.GetTask(exportTask.ID)
Copy link
Member

Choose a reason for hiding this comment

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

We should probably use the same mechanism to wait for both the asset transcode task as well as the asset export task. This means that in both cases we can just wait for the task and get the asset in the end of the process, instead of polling for the task as you did on the transcode case.

You could use this as an example and create a similar helper here that you can re-use: https://github.com/livepeer/video-nft/blob/main/src/minter.ts#L480

With a separate helper that only waits for a task (which can be in the go-api-client lib as well sine it's a pretty common logic), the logic here should become a little cleaner as well.

@figintern figintern force-pushed the tq/e2e_testing_nft_sdk branch 7 times, most recently from 721b3ae to e797a25 Compare June 13, 2022 10:07
cmd/recordtester/recordtester.go Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Outdated Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Outdated Show resolved Hide resolved
@figintern figintern force-pushed the tq/e2e_testing_nft_sdk branch from e797a25 to 6511b62 Compare June 17, 2022 02:45
@figintern figintern force-pushed the tq/e2e_testing_nft_sdk branch from 939b137 to db0989f Compare June 17, 2022 05:33
Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

LGTM!

cmd/recordtester/recordtester.go Show resolved Hide resolved
internal/app/recordtester/recordtester_app.go Show resolved Hide resolved
internal/app/vodtester/continuous_vod_tester.go Outdated Show resolved Hide resolved
internal/app/vodtester/continuous_vod_tester.go Outdated Show resolved Hide resolved
internal/app/vodtester/continuous_vod_tester.go Outdated Show resolved Hide resolved
internal/app/vodtester/vodtester_app.go Outdated Show resolved Hide resolved
Comment on lines 159 to 161
func (rt *vodTester) Clean() {
// TODO
}
Copy link
Member

Choose a reason for hiding this comment

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

Instead of having this clean function, you could simply do a defer api.DeleteAsset(asset.ID) after every asset you created on the test routine above.

We probably don't want to infinitely stack up the account with so many assets from these tests. Although we won't be really deleting the files from cloud storage nor even the objects from DB anyway 🤷
So it's more not to pollute the API responses/dashboard than for any concrete resource optimization.

Copy link
Contributor Author

@figintern figintern Jun 23, 2022

Choose a reason for hiding this comment

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

Will follow-up with this, need to add DeleteAsset to go-api-client

internal/app/vodtester/vodtester_app.go Outdated Show resolved Hide resolved
internal/app/vodtester/continuous_vod_tester.go Outdated Show resolved Hide resolved
internal/app/vodtester/continuous_vod_tester.go Outdated Show resolved Hide resolved
@figintern figintern merged commit adbe3a0 into master Jun 23, 2022
@hjpotter92 hjpotter92 deleted the tq/e2e_testing_nft_sdk branch August 25, 2022 05:54
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.

3 participants