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

Generic client, Browser + Node.js connections #165

Merged
merged 37 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c5166c3
Refactor client to support custom connections
slvrtrn May 29, 2023
b06d187
Global devDependencies
slvrtrn May 29, 2023
07862d6
Generic ClickHouse client without Node.js specific types
slvrtrn May 30, 2023
2e2e379
Update paths
slvrtrn May 30, 2023
a9f3a50
Update package names
slvrtrn May 30, 2023
27982ab
WIP webpack + karma + jasmine
slvrtrn May 31, 2023
8007a0c
Migrate to Jasmine; Browser connection tests
slvrtrn Jun 1, 2023
582116a
WIP CI
slvrtrn Jun 1, 2023
857092f
Prettier
slvrtrn Jun 1, 2023
a7f912f
Fix tests
slvrtrn Jun 1, 2023
c4969b3
Streaming support for browser; more tests
slvrtrn Jun 7, 2023
d6ae565
Add more browser tests; fix Node.js tests
slvrtrn Jun 7, 2023
8d38ca8
Enable local cluster tests
slvrtrn Jun 8, 2023
92e0b8b
Enable cloud tests
slvrtrn Jun 8, 2023
c047942
Temp node_max_open_connections test fix
slvrtrn Jun 8, 2023
52e3a96
0.1.1: Keep-Alive sockets housekeeping (#169)
slvrtrn Jul 3, 2023
06c4401
[skip ci] Update coverage report
slvrtrn Jul 3, 2023
65792af
Merge main
slvrtrn Jul 11, 2023
ffa5938
Merge main/partially address PR comments
slvrtrn Jul 12, 2023
928bfd8
Update README
slvrtrn Jul 12, 2023
5bed356
Ignore some tests
slvrtrn Jul 12, 2023
63501dd
Lint fix
slvrtrn Jul 13, 2023
a9bfd3c
Update GHA
slvrtrn Jul 13, 2023
35f1d0c
TSConfig housekeeping
slvrtrn Jul 13, 2023
78a4a8e
Co-locate test files in their respective packages
slvrtrn Jul 13, 2023
79d3c40
Update GHA
slvrtrn Jul 13, 2023
5c4b370
Update package.json
slvrtrn Jul 13, 2023
8c61e45
Prettier
slvrtrn Jul 13, 2023
57a3bc3
Update GHA
slvrtrn Jul 13, 2023
b92b7d8
Enable Karma tests in GHA
slvrtrn Jul 13, 2023
2ac2f14
Separate TLS test configuration
slvrtrn Jul 13, 2023
3aa2d6d
Revisit some of the ignored tests, ignore KeepAlive for now
slvrtrn Jul 13, 2023
837077d
Cleanup
slvrtrn Jul 13, 2023
25462d4
@ts-expect-error
slvrtrn Jul 13, 2023
1aa5031
Fix Webpack and leaking Node.js requires
slvrtrn Jul 13, 2023
a6c4909
Update README.md
slvrtrn Jul 13, 2023
d2a7ab5
Fix abort request streaming test
slvrtrn Jul 13, 2023
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
5 changes: 3 additions & 2 deletions .build/update_version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import version from '../src/version'
import packageJson from '../package.json'
import fs from 'fs'
import packageJson from '../package.json'
import version from '../packages/client-common/src/version'
;(async () => {
// FIXME: support all 3 modules
console.log(`Current package version is: ${version}`)
packageJson.version = version
console.log('Updated package json:')
Expand Down
1 change: 1 addition & 0 deletions .docker/clickhouse/cluster/server1_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
<keep_alive_timeout>3</keep_alive_timeout>

<logger>
<level>debug</level>
Expand Down
1 change: 1 addition & 0 deletions .docker/clickhouse/cluster/server2_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
<keep_alive_timeout>3</keep_alive_timeout>

<logger>
<level>debug</level>
Expand Down
1 change: 1 addition & 0 deletions .docker/clickhouse/single_node/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
<keep_alive_timeout>3</keep_alive_timeout>

<logger>
<level>debug</level>
Expand Down
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node_modules
webpack
8 changes: 5 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": ["./tsconfig.dev.json"]
"project": ["./tsconfig.all.json"]
},
"env": {
"node": true
Expand All @@ -25,10 +25,12 @@
},
"overrides": [
{
"files": ["./__tests__/**/*.ts"],
"files": ["./**/__tests__/**/*.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off"
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-ts-comment": "off",
"no-constant-condition": "off"
}
}
]
Expand Down
167 changes: 100 additions & 67 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ name: 'tests'

on:
workflow_dispatch:
inputs:
push-coverage-report:
type: choice
required: true
description: Push coverage
options:
- yes
- no
default: no
push:
branches:
- main
Expand All @@ -20,10 +11,8 @@ on:
- 'benchmarks/**'
- 'examples/**'
pull_request:
branches:
- main
paths-ignore:
- 'README.md'
- '**/*.md'
- 'LICENSE'
- 'benchmarks/**'
- 'examples/**'
Expand All @@ -32,12 +21,12 @@ on:
- cron: '0 9 * * *'

jobs:
build:
node-unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [ 16, 18, 20 ]
node: [16, 18, 20]
steps:
- uses: actions/checkout@main

Expand All @@ -60,16 +49,47 @@ jobs:

- name: Run unit tests
run: |
npm run test:unit
npm run test:node:unit

integration-tests-local-single-node:
needs: build
browser-all-tests-local-single-node:
runs-on: ubuntu-latest
needs: node-unit-tests
strategy:
fail-fast: true
matrix:
node: [ 16, 18, 20 ]
clickhouse: [ head, latest ]
clickhouse: [head, latest]
steps:
- uses: actions/checkout@main

- name: Start ClickHouse (version - ${{ matrix.clickhouse }}) in Docker
uses: isbang/compose-action@v1.1.0
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
with:
compose-file: 'docker-compose.yml'
down-flags: '--volumes'

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: |
npm install

- name: Run all browser tests
run: |
npm run test:browser

node-integration-tests-local-single-node:
needs: node-unit-tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [16, 18, 20]
clickhouse: [head, latest]

steps:
- uses: actions/checkout@main
Expand All @@ -95,35 +115,27 @@ jobs:
run: |
sudo echo "127.0.0.1 server.clickhouseconnect.test" | sudo tee -a /etc/hosts

# Includes TLS integration tests run
# Will also run unit tests, but that's almost free.
# Otherwise, we need to set up a separate job,
# which will also run the integration tests for the second time,
# and that's more time-consuming.
- name: Run all tests
- name: Run integration tests
run: |
npm t -- --coverage
npm run test:node:integration

- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
retention-days: 1
- name: Run TLS tests
run: |
npm run test:node:tls

integration-tests-local-cluster:
needs: build
node-integration-tests-local-cluster:
needs: node-unit-tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [ 16, 18, 20 ]
clickhouse: [ head, latest ]
node: [16, 18, 20]
clickhouse: [head, latest]

steps:
- uses: actions/checkout@main

- name: Start ClickHouse (version - ${{ matrix.clickhouse }}) in Docker
- name: Start ClickHouse cluster (version - ${{ matrix.clickhouse }}) in Docker
uses: isbang/compose-action@v1.1.0
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
Expand All @@ -142,15 +154,46 @@ jobs:

- name: Run integration tests
run: |
npm run test:integration:local_cluster
npm run test:node:integration:local_cluster

integration-tests-cloud:
needs: build
browser-integration-tests-local-cluster:
runs-on: ubuntu-latest
needs: node-unit-tests
strategy:
fail-fast: true
matrix:
node: [ 16, 18, 20 ]
clickhouse: [head, latest]
steps:
- uses: actions/checkout@main

- name: Start ClickHouse cluster (version - ${{ matrix.clickhouse }}) in Docker
uses: isbang/compose-action@v1.1.0
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
with:
compose-file: 'docker-compose.cluster.yml'
down-flags: '--volumes'

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: |
npm install

- name: Run all browser tests
run: |
npm run test:browser:integration:local_cluster

node-integration-tests-cloud:
needs: node-unit-tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [16, 18, 20]

steps:
- uses: actions/checkout@main
Expand All @@ -169,37 +212,27 @@ jobs:
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST }}
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD }}
run: |
npm run test:integration:cloud
npm run test:node:integration:cloud

upload-coverage-and-badge:
if: github.ref == 'refs/heads/main' && github.event.inputs.push-coverage-report != 'no'
needs:
- integration-tests-local-single-node
- integration-tests-local-cluster
- integration-tests-cloud
browser-integration-tests-cloud:
needs: node-unit-tests
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@main

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
- name: Download coverage report
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage
- name: Install packages
run: npm i -G make-coverage-badge
- name: Generate badge
run: npx make-coverage-badge
- name: Make "Coverage" lowercase for style points
run: sed -i 's/Coverage/coverage/g' coverage/badge.svg
- uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: 'coverage'
commit_message: '[skip ci] Update coverage report'

- name: Install dependencies
run: |
npm install

- name: Run integration tests
env:
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST }}
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD }}
run: |
npm run test:browser:integration:cloud
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
benchmarks/leaks/input
*.tgz
.npmrc
webpack