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

test: improve test and ci performance #3135

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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