Skip to content

wasi: Test that pollables may be used multiple times#7763

Merged
elliottt merged 3 commits into
bytecodealliance:mainfrom
elliottt:trevor/pollable-reuse-test
Jan 10, 2024
Merged

wasi: Test that pollables may be used multiple times#7763
elliottt merged 3 commits into
bytecodealliance:mainfrom
elliottt:trevor/pollable-reuse-test

Conversation

@elliottt
Copy link
Copy Markdown
Member

@elliottt elliottt commented Jan 9, 2024

We didn't have a test that covered using a pollable multiple times in the test-programs, despite relying on that behavior in the preview1 adapter.

@elliottt
Copy link
Copy Markdown
Member Author

elliottt commented Jan 9, 2024

@pchickey and @guybedford, does this look like enough to have caused a test failure in the jco work?

@guybedford
Copy link
Copy Markdown
Contributor

guybedford commented Jan 9, 2024

Unfortunately I tried this in JCO and it is definitely passing, so I don't think this is capturing the case. JCO pollables will only ever resolve once as they are promise-based, after which they will be always-resolving. @elliottt let me know if I can help debug further at all.

stdout_pollable.block();
assert!(stdout_pollable.ready(), "after blocking, pollable is ready");

let n = stdout.check_write().unwrap() as usize;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps this should write until check write doesn't allow anymore writing to ensure it's hitting backpressure?

The issue here in JCO is that we don't have backpressure for stdout since Node.js doesn't support it (https://nodejs.org/docs/latest/api/process.html#a-note-on-process-io).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm working separately on a test that pipes stdout to stdin of another instantiation of the same component, and I think will give us a lot more control over how this test works. I'll ping you when it's ready :)

@elliottt elliottt force-pushed the trevor/pollable-reuse-test branch from 131aca3 to bd0d40a Compare January 10, 2024 01:07
@elliottt elliottt force-pushed the trevor/pollable-reuse-test branch from bd0d40a to cd1398b Compare January 10, 2024 01:09
@elliottt elliottt marked this pull request as ready for review January 10, 2024 01:09
@elliottt elliottt requested a review from a team as a code owner January 10, 2024 01:09
@elliottt elliottt requested review from guybedford and pchickey and removed request for a team, guybedford and pchickey January 10, 2024 01:09
Comment thread tests/all/piped_tests.rs
if !producer.success() {
// make sure the consumer gets killed off
if consumer.try_wait().is_err() {
consumer.kill().expect("Failed to kill consumer");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rather than kill the consumer, can we tell each the producer and consumer how many bytes or messages to send/expect total, so they can both exit gracefully once those conditions are met? this will also let us assert, in the consumer, that after everything expected is consumed, the pollable does not become ready "ever again" (poll with a 250ms timeout and call it good)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If the producer panics, we'll still want to kill the consumer. This was more about ensuring that we cleanup failures properly than anything else.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Additionally, consumed amount is something that we could compute in the individual piped tests, and I think would be easier to debug as an assertion failure in the consumer side.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

got it! sounds good.

Comment thread tests/all/piped_tests.rs
// Below here is mechanical: there should be one test for every binary in
// wasi-tests.
#[test]
fn piped_simple() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious why you chose to create a new prefix and test for these test programs and tests? or can we just make them part of the cli tests?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are slightly different, as they require two instances to be setup. I suppose they could be cli tests, but it seemed cleaner to separate them out, given that they have special run requirements.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

works for me

@elliottt elliottt added this pull request to the merge queue Jan 10, 2024
Merged via the queue into bytecodealliance:main with commit 536cf88 Jan 10, 2024
@elliottt elliottt deleted the trevor/pollable-reuse-test branch January 10, 2024 22:10
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