Skip to content

Commit

Permalink
test: improve test and ci performance (#3135)
Browse files Browse the repository at this point in the history
* test: improve test performance

* run coverage case only when needed
  • Loading branch information
Uzlopak committed Apr 19, 2024
1 parent f90c161 commit 501f4fa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ jobs:
run: npm ls --all
continue-on-error: true

- name: Run tests
- name: Run tests with coverage
id: coverage
if: inputs.runs-on == 'ubuntu-latest' && inputs.node-version == 20
run: npm run coverage:ci
env:
CI: true
NODE_V8_COVERAGE: ./coverage/tmp

- name: Run tests
if: steps.coverage.outcome == 'skipped'
run: npm run test:javascript
env:
CI: true

- name: Coverage Report
if: inputs.runs-on == 'ubuntu-latest' && inputs.node-version == 20
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4.1.1
Expand Down
1 change: 1 addition & 0 deletions test/client-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ test('request dump', async (t) => {
t = tspl(t, { plan: 3 })

const server = createServer((req, res) => {
res.shouldKeepAlive = false
res.setHeader('content-length', 5)
res.end('hello')
})
Expand Down
1 change: 1 addition & 0 deletions test/content-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ test('request streaming with Readable.from(buf)', async (t) => {
test('request DELETE, content-length=0, with body', async (t) => {
t = tspl(t, { plan: 5 })
const server = createServer((req, res) => {
res.shouldKeepAlive = false
res.end()
})
server.on('request', (req, res) => {
Expand Down
12 changes: 7 additions & 5 deletions test/issue-803.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ const { createServer } = require('node:http')

test('https://github.com/nodejs/undici/issues/803', { timeout: 60000 }, async (t) => {
t = tspl(t, { plan: 2 })

const SIZE = 5900373096
const chunkSize = 65536
const parts = (SIZE / chunkSize) | 0
const lastPartSize = SIZE % chunkSize
const chunk = Buffer.allocUnsafe(chunkSize)

const server = createServer(async (req, res) => {
const chunkSize = res.writableHighWaterMark << 5
const parts = (SIZE / chunkSize) | 0
const lastPartSize = SIZE % chunkSize
const chunk = Buffer.allocUnsafe(chunkSize)

res.shouldKeepAlive = false
res.setHeader('content-length', SIZE)
let i = 0

while (i++ < parts) {
if (res.write(chunk) === false) {
await once(res, 'drain')
Expand Down

0 comments on commit 501f4fa

Please sign in to comment.