Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Dliu/pg browser #2

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
bc922a2
Changes for websockets and cursors
daniel-liu-bitio Feb 22, 2022
86558d2
Add pg browser
daniel-liu-bitio Feb 28, 2022
a8d4e8f
Clean up webpack config file
daniel-liu-bitio Feb 28, 2022
b22bd76
Merge branch 'master' into dliu/pg-browser
daniel-liu-bitio Feb 28, 2022
5346973
Fix yarn.lock
daniel-liu-bitio Feb 28, 2022
ab56adf
Modify pg tests
daniel-liu-bitio Mar 1, 2022
e0506b7
Update packages/pg-cursor/index.js
daniel-liu-bitio Mar 1, 2022
096c823
Comment clarifications
daniel-liu-bitio Mar 1, 2022
7fae74e
Remove yarn.loc
daniel-liu-bitio Mar 1, 2022
aa6fcf4
Fix pg test defaults and comment clarifications
daniel-liu-bitio Mar 1, 2022
e3adc69
Update packages/pg-cursor/index.js
daniel-liu-bitio Mar 2, 2022
db91f5b
Merge branch 'dliu/pg-browser' of https://github.com/daniel-liu-bitio…
daniel-liu-bitio Mar 2, 2022
70880de
Add comment to connection.end
daniel-liu-bitio Mar 2, 2022
7b6c17b
Add back original IP/hostname functionality
daniel-liu-bitio Mar 2, 2022
ff56d38
Add 130-tests.js back into test suite
daniel-liu-bitio Mar 2, 2022
42e05cc
Restore original integration/connection/test-helper
daniel-liu-bitio Mar 2, 2022
b58ec5c
Change some devDependencies back to dependencies
daniel-liu-bitio Mar 2, 2022
62dde3f
Remove status message logging
daniel-liu-bitio Mar 3, 2022
b55e00d
Fix stream placeholder logic
daniel-liu-bitio Mar 3, 2022
8462ab8
Send closing code + status on connection end
daniel-liu-bitio Mar 7, 2022
2f4a80d
Remove commented out original tests
daniel-liu-bitio Mar 9, 2022
f05b81c
Add simple performance test file
daniel-liu-bitio Mar 14, 2022
b7eae9d
Add cursor -> select example
daniel-liu-bitio Mar 14, 2022
d622ec7
Add yarn.lock
daniel-liu-bitio Mar 14, 2022
7b10504
Add messages.d.ts
daniel-liu-bitio Mar 14, 2022
e915f5d
recent
daniel-liu-bitio Mar 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove commented out original tests
  • Loading branch information
daniel-liu-bitio committed Mar 9, 2022
commit 2f4a80d48dc9a3e20108f9619655d5a0cdb5e2ed
89 changes: 0 additions & 89 deletions packages/pg/test/integration/client/connection-timeout-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,92 +85,3 @@ suite.test('expired connection timeout', (done) => {
.then(() => clearTimeout(timeoutId))
})
})

// 'use strict'
// const net = require('net')
// const buffers = require('../../test-buffers')
// const helper = require('./test-helper')

// const suite = new helper.Suite()

// const options = {
// host: 'localhost',
// port: Math.floor(Math.random() * 2000) + 2000,
// connectionTimeoutMillis: 2000,
// user: 'not',
// database: 'existing',
// }

// const serverWithConnectionTimeout = (port, timeout, callback) => {
// const sockets = new Set()

// const server = net.createServer((socket) => {
// sockets.add(socket)
// socket.once('end', () => sockets.delete(socket))

// socket.on('data', (data) => {
// // deny request for SSL
// if (data.length === 8) {
// socket.write(Buffer.from('N', 'utf8'))
// // consider all authentication requests as good
// } else if (!data[0]) {
// socket.write(buffers.authenticationOk())
// // send ReadyForQuery `timeout` ms after authentication
// setTimeout(() => socket.write(buffers.readyForQuery()), timeout).unref()
// // respond with our canned response
// } else {
// socket.write(buffers.readyForQuery())
// }
// })
// })

// let closing = false
// const closeServer = (done) => {
// if (closing) return
// closing = true

// server.close(done)
// for (const socket of sockets) {
// socket.destroy()
// }
// }

// server.listen(port, options.host, () => callback(closeServer))
// }

// suite.test('successful connection', (done) => {
// serverWithConnectionTimeout(options.port, 0, (closeServer) => {
// const timeoutId = setTimeout(() => {
// throw new Error('Client should have connected successfully but it did not.')
// }, 3000)

// const client = new helper.Client(options)
// client
// .connect()
// .then(() => client.end())
// .then(() => closeServer(done))
// .catch((err) => closeServer(() => done(err)))
// .then(() => clearTimeout(timeoutId))
// })
// })

// suite.test('expired connection timeout', (done) => {
// const opts = { ...options, port: 54322 }
// serverWithConnectionTimeout(opts.port, opts.connectionTimeoutMillis * 2, (closeServer) => {
// const timeoutId = setTimeout(() => {
// throw new Error('Client should have emitted an error but it did not.')
// }, 3000)

// const client = new helper.Client(opts)
// client
// .connect()
// .then(() => client.end())
// .then(() => closeServer(() => done(new Error('Connection timeout should have expired but it did not.'))))
// .catch((err) => {
// assert(err instanceof Error)
// assert(/timeout expired\s*/.test(err.message))
// closeServer(done)
// })
// .then(() => clearTimeout(timeoutId))
// })
// })
97 changes: 0 additions & 97 deletions packages/pg/test/integration/client/network-partition-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,100 +93,3 @@ suite.test('silent server', (done) => {
const silentServer = new Server()
testServer(silentServer, done)
})

// 'use strict'
// var buffers = require('../../test-buffers')
// var helper = require('./test-helper')
// var suite = new helper.Suite()

// var net = require('net')

// var Server = function (response) {
// this.server = undefined
// this.socket = undefined
// this.response = response
// }

// let port = 54321
// Server.prototype.start = function (cb) {
// // this is our fake postgres server
// // it responds with our specified response immediatley after receiving every buffer
// // this is sufficient into convincing the client its connectet to a valid backend
// // if we respond with a readyForQuery message
// this.server = net.createServer(
// function (socket) {
// this.socket = socket
// if (this.response) {
// this.socket.on(
// 'data',
// function (data) {
// // deny request for SSL
// if (data.length == 8) {
// this.socket.write(Buffer.from('N', 'utf8'))
// // consider all authentication requests as good
// } else if (!data[0]) {
// this.socket.write(buffers.authenticationOk())
// // respond with our canned response
// } else {
// this.socket.write(this.response)
// }
// }.bind(this)
// )
// }
// }.bind(this)
// )

// port = port + 1

// var options = {
// host: 'localhost',
// port: port,
// }
// this.server.listen(options.port, options.host, function () {
// cb(options)
// })
// }

// Server.prototype.drop = function () {
// this.socket.destroy()
// }

// Server.prototype.close = function (cb) {
// this.server.close(cb)
// }

// var testServer = function (server, cb) {
// // wait for our server to start
// server.start(function (options) {
// // connect a client to it
// var client = new helper.Client(options)
// client.connect().catch((err) => {
// console.log(err)
// assert(err instanceof Error)
// clearTimeout(timeoutId)
// server.close(cb)
// })

// server.server.on('connection', () => {
// // after 50 milliseconds, drop the client
// setTimeout(function () {
// server.drop()
// }, 50)
// })

// // blow up if we don't receive an error
// var timeoutId = setTimeout(function () {
// throw new Error('Client should have emitted an error but it did not.')
// }, 5000)
// })
// }

// suite.test('readyForQuery server', (done) => {
// const respondingServer = new Server(buffers.readyForQuery())
// testServer(respondingServer, done)
// })

// suite.test('silent server', (done) => {
// const silentServer = new Server()
// testServer(silentServer, done)
// })
9 changes: 0 additions & 9 deletions packages/pg/test/integration/client/promise-api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ suite.test('invalid uri rejects promise', (done) => {
})
})

// original:
// suite.test('invalid connection rejects promise', (done) => {
// const client = new pg.Client({ host: 'alksdjflaskdfj', port: 1234 })
// return client.connect().catch((e) => {
// assert(e instanceof Error)
// done()
// })
// })

suite.test('connected client does not reject promise after connection', (done) => {
const client = new pg.Client()
return client.connect().then(() => {
Expand Down
54 changes: 0 additions & 54 deletions packages/pg/test/integration/gh-issues/2079-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,57 +51,3 @@ suite.test('Non "S" response code allows event loop to exit', (done) => {
done()
})
})

// 'use strict'
// var helper = require('./../test-helper')
// var assert = require('assert')

// const suite = new helper.Suite()

// // makes a backend server that responds with a non 'S' ssl response buffer
// let makeTerminatingBackend = (byte) => {
// const { createServer } = require('net')

// const server = createServer((socket) => {
// // attach a listener so the socket can drain
// // https://www.postgresql.org/docs/9.3/protocol-message-formats.html
// socket.on('data', (buff) => {
// const code = buff.readInt32BE(4)
// // I don't see anything in the docs about 80877104
// // but libpq is sending it...
// if (code === 80877103 || code === 80877104) {
// const packet = Buffer.from(byte, 'utf-8')
// socket.write(packet)
// }
// })
// socket.on('close', () => {
// server.close()
// })
// })

// server.listen()
// const { port } = server.address()
// return port
// }

// suite.test('SSL connection error allows event loop to exit', (done) => {
// const port = makeTerminatingBackend('N')
// const client = new helper.pg.Client({ ssl: 'require', port, host: 'localhost' })
// // since there was a connection error the client's socket should be closed
// // and the event loop will have no refs and exit cleanly
// client.connect((err) => {
// assert(err instanceof Error)
// done()
// })
// })

// suite.test('Non "S" response code allows event loop to exit', (done) => {
// const port = makeTerminatingBackend('X')
// const client = new helper.pg.Client({ ssl: 'require', host: 'localhost', port })
// // since there was a connection error the client's socket should be closed
// // and the event loop will have no refs and exit cleanly
// client.connect((err) => {
// assert(err instanceof Error)
// done()
// })
// })
22 changes: 0 additions & 22 deletions packages/pg/test/unit/client/early-disconnect-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,3 @@ wss.on('listening', function () {
})
)
})

// 'use strict'
// var helper = require('./test-helper')
// var net = require('net')
// var pg = require('../../../lib/index.js')

// /* console.log() messages show up in `make test` output. TODO: fix it. */
// var server = net.createServer(function (c) {
// c.destroy()
// server.close()
// })

// server.listen(7777, function () {
// var client = new pg.Client('postgres://localhost:7777')
// client.connect(
// assert.calls(function (err) {
// console.log("ERROR IS "+err)
// assert(err)
// })
// )
// })

32 changes: 0 additions & 32 deletions packages/pg/test/unit/client/set-keepalives-tests.js

This file was deleted.

30 changes: 0 additions & 30 deletions packages/pg/test/unit/connection-parameters/creation-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,36 +118,6 @@ suite.test('do not double escape spaces', function () {
assert.equal(subject.database, 'post gres')
})

// suite.test('initializing with unix domain socket', function () {
// var subject = new ConnectionParameters('/var/run/')
// assert.ok(subject.isDomainSocket)
// assert.equal(subject.host, '/var/run/')
// assert.equal(subject.database, defaults.user)
// })

// suite.test('initializing with unix domain socket and a specific database, the simple way', function () {
// var subject = new ConnectionParameters('/var/run/ mydb')
// assert.ok(subject.isDomainSocket)
// assert.equal(subject.host, '/var/run/')
// assert.equal(subject.database, 'mydb')
// })

// suite.test('initializing with unix domain socket, the health way', function () {
// var subject = new ConnectionParameters('socket:/some path/?db=my[db]&encoding=utf8')
// assert.ok(subject.isDomainSocket)
// assert.equal(subject.host, '/some path/')
// assert.equal(subject.database, 'my[db]', 'must to be escaped and unescaped trough "my%5Bdb%5D"')
// assert.equal(subject.client_encoding, 'utf8')
// })

// suite.test('initializing with unix domain socket, the escaped health way', function () {
// var subject = new ConnectionParameters('socket:/some%20path/?db=my%2Bdb&encoding=utf8')
// assert.ok(subject.isDomainSocket)
// assert.equal(subject.host, '/some path/')
// assert.equal(subject.database, 'my+db')
// assert.equal(subject.client_encoding, 'utf8')
// })

var checkForPart = function (array, part) {
assert.ok(array.indexOf(part) > -1, array.join(' ') + ' did not contain ' + part)
}
Expand Down
Loading