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

Display error banner when Reports server returns status code ≠ 2xx #1608

Merged
merged 40 commits into from
Mar 19, 2021

Conversation

vincent-psarga
Copy link
Contributor

@vincent-psarga vincent-psarga commented Mar 9, 2021

Other Cucumber implementations display the content send by the server upon failure. For example, with Cucumber ruby:

$ CUCUMBER_PUBLISH_TOKEN=plop bundle exec cucumber features/docs/getting_started.feature
WARNING: Nokogiri was built against LibXML version 2.9.10, but has dynamically loaded 2.9.4
Using the default profile...
........

2 scenarios (2 passed)
8 steps (8 passed)
0m0.023s
┌──────────────────────────────────────────────────────────────┐
│ Invalid CUCUMBER_PUBLISH_TOKEN: plop                         │
│ Go to https://reports.cucumber.io/profile to get your token. │
└──────────────────────────────────────────────────────────────┘
Traceback (most recent call last):
	1: from /Users/vincent.pretre/dev/open-source/cucumber-ruby-meta/cucumber-ruby/lib/cucumber/formatter/io.rb:40:in `block (3 levels) in new'
/Users/vincent.pretre/dev/open-source/cucumber-ruby-meta/cucumber-ruby/lib/cucumber/formatter/http_io.rb:79:in `close': request to https://messages.cucumber.io/api/reports failed with status 401 (StandardError)

This is an attempt to get the same behavior in cucumber-js

TODO:

  • Add a example of what's excepted
  • Display the server response
  • Fail when the server does not return 2xx
  • Solve the null line displayed above the banner

Update scenario to ensure cucumber execution fails if the server returned an error
@vincent-psarga vincent-psarga changed the title Do not fail when report server returns error Display error banner when Reports server returns status code ≠ 2xx Mar 10, 2021
@vincent-psarga
Copy link
Contributor Author

Seems to work fine now (except for the 'null' line that I have to fix)

CUCUMBER_PUBLISH_TOKEN=plop node ./bin/cucumber-js features/plop.feature
1 scenario (1 passed)
0 steps
0m00.016s (executing steps: 0m00.008s)
null
┌──────────────────────────────────────────────────────────────┐
│ Invalid CUCUMBER_PUBLISH_TOKEN: plop                         │
│ Go to https://reports.cucumber.io/profile to get your token. │
└──────────────────────────────────────────────────────────────┘


/Users/vincent.pretre/dev/open-source/cucumber-js/src/formatter/http_stream.ts:93
              new Error(`${method} ${url} returned status ${res.statusCode}`)
              ^
Error: GET https://messages.cucumber.io/api/reports returned status 401
    at IncomingMessage.<anonymous> (/Users/vincent.pretre/dev/open-source/cucumber-js/src/formatter/http_stream.ts:93:15)
    at IncomingMessage.emit (events.js:326:22)
    at IncomingMessage.EventEmitter.emit (domain.js:483:12)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

@coveralls
Copy link

coveralls commented Mar 10, 2021

Coverage Status

Coverage increased (+0.5%) to 98.575% when pulling 2e744ae on do-not-fail-when-report-server-returns-error into 4811647 on master.

@vincent-psarga vincent-psarga marked this pull request as ready for review March 11, 2021 09:08
@vincent-psarga
Copy link
Contributor Author

The build is not really stable (I managed to get it green by relaunching - and after it failed again).

Apparently that comes from some tests I have added and the way the stream errors are handled. I'm going to dig a bit more into that (although the solution I have in mind is not that beautiful to be honest :D )

@aslakhellesoy
Copy link
Contributor

@vincent-psarga are the non-deterministic tests new tests in this PR? I can help have a look at this.

@davidjgoss
Copy link
Contributor

The flaky tests I think started from the original change where publish support was added per #1457

I tried a few things a while ago but hit a bit of a wall tbh.

@vincent-psarga
Copy link
Contributor Author

@vincent-psarga are the non-deterministic tests new tests in this PR? I can help have a look at this.

At least from what I see, it's the test that I've introduced which is flaky. I'm looking at a way to not spawn Cucumber in order to fix this (worked fine with Ruby getting rid of spawning, so I give a try)

@aurelien-reeves
Copy link
Contributor

Just tried to remove the delays in the server
The error went back

So it seems the combination of the delays, and the ports, stabilized the tests.

Aslak Hellesøy and others added 2 commits March 16, 2021 11:40
@aurelien-reeves
Copy link
Contributor

aurelien-reeves commented Mar 16, 2021

@vincent-psarga @aslakhellesoy @vincentcapicotto Beside the race condition / inconsistent test, something still need to be done before merging that PR?

@aurelien-reeves
Copy link
Contributor

@davidjgoss do you have any new feedback regarding that PR?
We would like to merge it and release it.

I plan to open a new PR dedicated to the inconsistent test once that one is merged.

@davidjgoss
Copy link
Contributor

@aurelien-reeves I'll review this morning, thanks for the nudge!

Copy link
Contributor

@davidjgoss davidjgoss left a comment

Choose a reason for hiding this comment

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

LGTM

features/publish.feature Show resolved Hide resolved
@aurelien-reeves aurelien-reeves merged commit d845e32 into master Mar 19, 2021
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.

6 participants