renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
17.69k stars 2.33k forks source link

`getChangeLogJSON › supports github enterprise` test fails intermittently #11141

Closed ylemkimon closed 3 years ago

ylemkimon commented 3 years ago

How are you running Renovate?

N/A

Describe the bug

workers/pr/changelog/github › getChangeLogJSON › supports github enterprise and github enterprise changelog test fails intermittently, most of the time locally and sometimes on CI.

Relevant debug logs

 FAIL  lib/workers/pr/changelog/github.spec.ts (18.298 s, 160 MB heap size)
  ● workers/pr/changelog/github › getChangeLogJSON › supports github enterprise and github enterprise changelog

    thrown: "Exceeded timeout of 5000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

      156 |       ).toMatchSnapshot();
      157 |     });
    > 158 |     it('supports github enterprise and github enterprise changelog', async () => {
          |     ^
      159 |       hostRules.add({
      160 |         hostType: PLATFORM_TYPE_GITHUB,
      161 |         matchHost: 'https://github-enterprise.example.com/',

      at lib/workers/pr/changelog/github.spec.ts:158:5
      at lib/workers/pr/changelog/github.spec.ts:33:3
      at Object.<anonymous> (lib/workers/pr/changelog/github.spec.ts:32:1)

Have you created a minimal reproduction repository?

N/A

Additional context

It seems it hangs on addReleaseNotes(). Might it be making an actual request?

rarkins commented 3 years ago

We want all our tests to pass "offline" but sometimes in the past we've accidentally added tests which do real queries. I wondered if our nock net connect settings had avoided that though.

viceice commented 3 years ago

I'll check those tests. Net connect will only blocked for tests which are using our http test utils

viceice commented 3 years ago

Verified: no mock at all

https://github.com/renovatebot/renovate/blob/f00413c298ad63e1ff0bf03d4dba7c1db3ca5be4/lib/workers/pr/changelog/github.spec.ts#L1-L8

HonkingGoose commented 3 years ago

If I understand correctly, this issue is ready to start working on? As we have confirmed that there is no mock right now, where we should have a mock?

I think test failures should be a high priority, as flaky tests will annoy everybody, and reduce confidence in the tests.

Feel free to re-label if this is wrong. 😄

viceice commented 3 years ago

Classify as refactor as it's only relevant to tests.

viceice commented 3 years ago

This are the requests send by workers/pr/changelog/github.spec.ts

workers/pr/changelog/github getChangeLogJSON works without Github

nock('https://api.github.com:443', {"encodedQueryParams":true})
  .get('/repos/chalk/chalk/tags')
  .query({"per_page":"100"})
  .reply(401, {"message":"Bad credentials","documentation_url":"https://docs.github.com/rest"}, [
  'Server',
  'GitHub.com',
  'Date',
  'Mon, 09 Aug 2021 15:12:01 GMT',
  'Content-Type',
  'application/json; charset=utf-8',
  'Content-Length',
  '80',
  'X-GitHub-Media-Type',
  'github.v3; format=json',
  'X-RateLimit-Limit',
  '60',
  'X-RateLimit-Remaining',
  '0',
  'X-RateLimit-Reset',
  '1628524711',
  'X-RateLimit-Used',
  '106',
  'X-RateLimit-Resource',
  'core',
  'Access-Control-Expose-Headers',
  'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
  'Access-Control-Allow-Origin',
  '*',
  'Strict-Transport-Security',
  'max-age=31536000; includeSubdomains; preload',
  'X-Frame-Options',
  'deny',
  'X-Content-Type-Options',
  'nosniff',
  'X-XSS-Protection',
  '0',
  'Referrer-Policy',
  'origin-when-cross-origin, strict-origin-when-cross-origin',
  'Content-Security-Policy',
  "default-src 'none'",
  'Vary',
  'Accept-Encoding, Accept, X-Requested-With',
  'X-GitHub-Request-Id',
  'C1F1:7C9E:1848FE6:18DCB1F:611145C1',
  'connection',
  'close'
]);

----

They all fail silently with 401 and Bad credentials so #5699 simply added non functional tests 😕

renovate-release commented 3 years ago

:tada: This issue has been resolved in version 25.70.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: