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

WebSocket tests are flaky #246

Open
benmanns opened this issue Sep 26, 2024 · 0 comments
Open

WebSocket tests are flaky #246

benmanns opened this issue Sep 26, 2024 · 0 comments

Comments

@benmanns
Copy link
Contributor

When working on #244 and #245, I noticed that the tests can fail successfully if no messages are produced.

@test "websocket-connector-test" {
    count=1
    echo "Starting consumer on topic $TOPIC"
    sleep 13

    fluvio consume -B -d $TOPIC | while read input; do
        expected="Hello, Fluvio! - $count"
        echo $input = $expected
        [ "$input" = "$expected" ]
        count=$(($count + 1))
        if [ $count -eq 10 ]; then
            break;
        fi
    done

}

If fluvio consume -B -d $TOPIC produced no lines, nothing gets tested. I tested a new method that I think works pretty well:

@test "websocket-connector-test" {
    count=1
    echo "Starting consumer on topic $TOPIC"
    sleep 13

    expected=<<EOF
Hello, Fluvio! - 1
Hello, Fluvio! - 2
Hello, Fluvio! - 3
Hello, Fluvio! - 4
Hello, Fluvio! - 5
Hello, Fluvio! - 6
Hello, Fluvio! - 7
Hello, Fluvio! - 8
Hello, Fluvio! - 9
Hello, Fluvio! - 10
EOF

    run fluvio consume -B -d $TOPIC

    [[ $output = $expected* ]]
}

I check against $expected as a prefix because the tests tend to exit and re-run which duplicates the output.

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

No branches or pull requests

1 participant