Skip to content

Commit

Permalink
chore(ui): run web console tests with context path
Browse files Browse the repository at this point in the history
  • Loading branch information
glasstiger committed Jan 11, 2025
1 parent c23d571 commit 4108b89
Show file tree
Hide file tree
Showing 18 changed files with 163 additions and 105 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/build_and run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Build and Run Tests

on:
workflow_call:
inputs:
context-path:
required: true
type: string

jobs:
build_and_run_tests:
name: Build and Run Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"

- uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: maven

- name: Build QuestDB
run: mvn clean package -f packages/browser-tests/questdb/pom.xml -DskipTests -P build-binaries

- name: Extract QuestDB
run: tar -xzf packages/browser-tests/questdb/core/target/questdb-*-rt-linux-x86-64.tar.gz -C tmp/

- name: Create DB Root
run: mkdir tmp/dbroot

- name: Start QuestDB
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh start -d ./tmp/dbroot
env:
QDB_DEV_MODE_ENABLED: "true"
QDB_HTTP_CONTEXT_PATH: ${{ inputs.context-path }}

- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: Install dependencies
run: yarn install --immutable --immutable-cache

- name: Build @questdb/react-components
run: yarn workspace @questdb/react-components run build

- name: Build @questdb/web-console
run: yarn workspace @questdb/web-console run build

- name: Run bundle watcher on @questdb/web-console
run: yarn workspace @questdb/web-console bundlewatch

- name: Run @questdb/web-console unit tests
run: yarn workspace @questdb/web-console run test:prod

- name: Run browser-tests test - auth
run: node packages/web-console/serve-dist.js & yarn workspace browser-tests test:auth

- name: Stop QuestDB
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh stop

- name: Start QuestDB, set auth credentials
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh start -d ./tmp/dbroot
env:
QDB_DEV_MODE_ENABLED: "true"
QDB_HTTP_USER: "admin"
QDB_HTTP_PASSWORD: "quest"
QDB_HTTP_CONTEXT_PATH: ${{ inputs.context-path }}

- name: Run browser-tests test
run: yarn workspace browser-tests test

- name: Print Log Files
if: success() || failure()
run: cat tmp/dbroot/log/*

- name: Save QuestDB log on test failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: questdb-log
path: tmp/dbroot/log/*

- name: Stop QuestDB
if: success() || failure()
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh stop
75 changes: 2 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,80 +9,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ./.github/workflows/build_and_run_tests.yml
with:
submodules: "recursive"

- uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: maven

- name: Build QuestDB
run: mvn clean package -f packages/browser-tests/questdb/pom.xml -DskipTests -P build-binaries

- name: Extract QuestDB
run: tar -xzf packages/browser-tests/questdb/core/target/questdb-*-rt-linux-x86-64.tar.gz -C tmp/

- name: Create DB Root
run: mkdir tmp/dbroot

- name: Start QuestDB
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh start -d ./tmp/dbroot
env:
QDB_DEV_MODE_ENABLED: "true"

- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "yarn"

- name: Install dependencies
run: yarn install --immutable --immutable-cache

- name: Build @questdb/react-components
run: yarn workspace @questdb/react-components run build

- name: Build @questdb/web-console
run: yarn workspace @questdb/web-console run build

- name: Run bundle watcher on @questdb/web-console
run: yarn workspace @questdb/web-console bundlewatch

- name: Run @questdb/web-console unit tests
run: yarn workspace @questdb/web-console run test:prod

- name: Run browser-tests test - auth
run: node packages/web-console/serve-dist.js & yarn workspace browser-tests test:auth

- name: Stop QuestDB
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh stop

- name: Start QuestDB, set auth credentials
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh start -d ./tmp/dbroot
env:
QDB_DEV_MODE_ENABLED: "true"
QDB_HTTP_USER: "admin"
QDB_HTTP_PASSWORD: "quest"

- name: Run browser-tests test
run: yarn workspace browser-tests test

- name: Print Log Files
if: success() || failure()
run: cat tmp/dbroot/log/*

- name: Save QuestDB log on test failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: questdb-log
path: tmp/dbroot/log/*

- name: Stop QuestDB
if: success() || failure()
run: ./tmp/questdb-*-rt-linux-x86-64/bin/questdb.sh stop
context-path: ""

- name: Publish @questdb/web-console to npm
if: github.ref == 'refs/heads/main'
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/tests_with_context_path.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Run Tests With Context Path

on:
push:

jobs:
run_tests_with_context_path:
name: Running Tests With Context Path
runs-on: ubuntu-latest

steps:
- uses: ./.github/workflows/build_and_run_tests.yml
with:
context-path: "/context"
5 changes: 4 additions & 1 deletion packages/browser-tests/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ const {
addMatchImageSnapshotPlugin,
} = require("@simonsmith/cypress-image-snapshot/plugin");

const contextPath = process.env.QDB_HTTP_CONTEXT_PATH || ""
const baseUrl = `http://localhost:9999${contextPath}`;

module.exports = defineConfig({
defaultCommandTimeout: 10000,
e2e: {
defaultCommandTimeout: 30000,
screenshotOnRunFailure: false,
video: false,
baseUrl: "http://localhost:9999",
baseUrl: baseUrl,
viewportWidth: 1280,
viewportHeight: 720,
specPattern: "cypress/integration/**/*.spec.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/browser-tests/cypress/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ addMatchImageSnapshotCommand({

const { ctrlOrCmd, escapeRegExp } = require("./utils");

const baseUrl = "http://localhost:9999";
const contextPath = process.env.QDB_HTTP_CONTEXT_PATH || ""
const baseUrl = `http://localhost:9999${contextPath}`;

const tableSchemas = {
btc_trades:
Expand Down
3 changes: 2 additions & 1 deletion packages/browser-tests/cypress/integration/auth/auth.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="cypress" />

const baseUrl = "http://localhost:9999";
const contextPath = process.env.QDB_HTTP_CONTEXT_PATH || ""
const baseUrl = `http://localhost:9999${contextPath}`;

const interceptSettings = (payload) => {
cy.intercept({ method: "GET", url: `${baseUrl}/settings` }, payload).as(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="cypress" />

const baseUrl = "http://localhost:9999";
const contextPath = process.env.QDB_HTTP_CONTEXT_PATH || ""
const baseUrl = `http://localhost:9999${contextPath}`;

const getTabDragHandleByTitle = (title) =>
`.chrome-tab[data-tab-title="${title}"] .chrome-tab-drag-handle`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/// <reference types="cypress" />

const baseUrl = "http://localhost:9999";

const rowHeight = 30;

const assertRowCount = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/// <reference types="cypress" />

const baseUrl = "http://localhost:9999";

describe("Sidebar tests", () => {
beforeEach(() => {
cy.loadConsoleWithAuth();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/// <reference types="cypress" />

const baseUrl = "http://localhost:9999";

describe("questdb charts", () => {
beforeEach(() => {
cy.loadConsoleWithAuth();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="cypress" />

const baseUrl = "http://localhost:9999";
const contextPath = process.env.QDB_HTTP_CONTEXT_PATH || ""
const baseUrl = `http://localhost:9999${contextPath}`;

const tables = [
"btc_trades",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/// <reference types="cypress" />

const baseUrl = "http://localhost:9999";

const toggleTelemetry = (enabled) => {
// expected dataset format of the first row:
// [id, enabled, version, os, package]
cy.interceptQuery("telemetry_config LIMIT -1", "telemetryConfig", (req) => {
return req.continue((res) => {
// enable telemetry to kick start the process on the client side
// enable telemetry to kick-start the process on the client side
res.body.dataset[0][1] = enabled;
return res;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/// <reference types="cypress" />

const baseUrl = "http://localhost:9999";

describe("System configuration - no warnings", () => {
before(() => {
cy.loadConsoleWithAuth(true);
Expand Down
2 changes: 1 addition & 1 deletion packages/browser-tests/questdb
Submodule questdb updated 86 files
+1 −1 benchmarks/pom.xml
+2 −2 benchmarks/src/main/java/org/questdb/UnorderedVarcharMapBenchmark.java
+2 −3 ci/templates/hosted-jobs.yml
+1 −1 core/rust/qdbr/rust-toolchain.toml
+4 −3 core/src/main/java/io/questdb/Bootstrap.java
+23 −10 core/src/main/java/io/questdb/PropServerConfiguration.java
+2 −1 core/src/main/java/io/questdb/PropertyKey.java
+2 −2 core/src/main/java/io/questdb/cairo/BitmapIndexWriter.java
+1 −1 core/src/main/java/io/questdb/cairo/CairoEngine.java
+2 −6 core/src/main/java/io/questdb/cairo/CairoException.java
+1 −1 core/src/main/java/io/questdb/cairo/IndexBuilder.java
+3 −4 core/src/main/java/io/questdb/cairo/RecordChain.java
+1 −1 core/src/main/java/io/questdb/cairo/SymbolMapUtil.java
+5 −8 core/src/main/java/io/questdb/cairo/TableConverter.java
+18 −2 core/src/main/java/io/questdb/cairo/TableUtils.java
+3 −3 core/src/main/java/io/questdb/cairo/TableWriter.java
+2 −2 core/src/main/java/io/questdb/cairo/mig/EngineMigration.java
+2 −3 core/src/main/java/io/questdb/cairo/sql/NetworkSqlExecutionCircuitBreaker.java
+10 −24 core/src/main/java/io/questdb/cairo/vm/MemoryCARWImpl.java
+30 −11 core/src/main/java/io/questdb/cairo/vm/Vm.java
+1 −1 core/src/main/java/io/questdb/cairo/vm/api/MemoryCR.java
+1 −1 core/src/main/java/io/questdb/cairo/wal/WalEventWriter.java
+3 −3 core/src/main/java/io/questdb/cairo/wal/WalWriter.java
+1 −1 core/src/main/java/io/questdb/cairo/wal/WalWriterMetadata.java
+1 −1 core/src/main/java/io/questdb/cairo/wal/seq/SequencerMetadata.java
+2 −2 core/src/main/java/io/questdb/cairo/wal/seq/TableSequencerAPI.java
+2 −3 core/src/main/java/io/questdb/cairo/wal/seq/TableSequencerImpl.java
+10 −0 core/src/main/java/io/questdb/cutlass/http/DefaultHttpServerConfiguration.java
+2 −0 core/src/main/java/io/questdb/cutlass/http/HttpFullFatServerConfiguration.java
+12 −9 core/src/main/java/io/questdb/cutlass/http/HttpServer.java
+5 −0 core/src/main/java/io/questdb/cutlass/http/HttpServerConfigurationWrapper.java
+8 −16 core/src/main/java/io/questdb/cutlass/http/processors/JsonQueryProcessor.java
+2 −0 core/src/main/java/io/questdb/cutlass/http/processors/LineHttpProcessorConfiguration.java
+1 −1 core/src/main/java/io/questdb/cutlass/http/processors/LineHttpTudCache.java
+40 −16 core/src/main/java/io/questdb/cutlass/http/processors/StaticContentProcessor.java
+9 −7 core/src/main/java/io/questdb/cutlass/http/processors/TextQueryProcessor.java
+1 −1 core/src/main/java/io/questdb/cutlass/line/tcp/LineTcpMeasurementScheduler.java
+1 −1 core/src/main/java/io/questdb/cutlass/line/udp/LineUdpParserImpl.java
+1 −1 core/src/main/java/io/questdb/cutlass/text/CairoTextWriter.java
+1 −1 core/src/main/java/io/questdb/cutlass/text/ParallelCsvFileImporter.java
+1 −1 core/src/main/java/io/questdb/griffin/SqlCompilerImpl.java
+2 −2 core/src/main/java/io/questdb/griffin/engine/functions/rnd/RndStringMemory.java
+8 −11 core/src/main/java/io/questdb/griffin/engine/functions/window/AvgDoubleWindowFunctionFactory.java
+1 −1 core/src/main/java/io/questdb/griffin/engine/functions/window/CountConstWindowFunctionFactory.java
+1 −1 core/src/main/java/io/questdb/griffin/engine/functions/window/CountDoubleWindowFunctionFactory.java
+6 −8 core/src/main/java/io/questdb/griffin/engine/functions/window/CountFunctionFactoryHelper.java
+1 −1 core/src/main/java/io/questdb/griffin/engine/functions/window/CountSymbolWindowFunctionFactory.java
+1 −1 core/src/main/java/io/questdb/griffin/engine/functions/window/CountVarcharWindowFunctionFactory.java
+0 −818 .../src/main/java/io/questdb/griffin/engine/functions/window/FirstNotNullValueDoubleWindowFunctionFactory.java
+49 −60 core/src/main/java/io/questdb/griffin/engine/functions/window/FirstValueDoubleWindowFunctionFactory.java
+8 −8 core/src/main/java/io/questdb/griffin/engine/functions/window/MaxDoubleWindowFunctionFactory.java
+9 −10 core/src/main/java/io/questdb/griffin/engine/functions/window/MinDoubleWindowFunctionFactory.java
+7 −8 core/src/main/java/io/questdb/griffin/engine/functions/window/SumDoubleWindowFunctionFactory.java
+2 −2 core/src/main/java/io/questdb/griffin/engine/ops/UpdateOperation.java
+0 −1 core/src/main/java/module-info.java
+0 −1 core/src/main/resources/META-INF/services/io.questdb.griffin.FunctionFactory
+2 −2 core/src/main/resources/io/questdb/site/conf/server.conf
+1 −1 core/src/test/java/io/questdb/test/AbstractCairoTest.java
+3 −2 core/src/test/java/io/questdb/test/ServerMainTest.java
+1 −1 core/src/test/java/io/questdb/test/cairo/BinarySearchTest.java
+3 −3 core/src/test/java/io/questdb/test/cairo/BitmapIndexTest.java
+11 −17 core/src/test/java/io/questdb/test/cairo/CairoEngineTest.java
+2 −2 core/src/test/java/io/questdb/test/cairo/CairoMemoryTest.java
+2 −7 core/src/test/java/io/questdb/test/cairo/CairoReadonlyEngineTest.java
+1 −1 core/src/test/java/io/questdb/test/cairo/MemRemappedFileTest.java
+18 −65 core/src/test/java/io/questdb/test/cairo/TableNameRegistryTest.java
+1 −1 core/src/test/java/io/questdb/test/cairo/TableReaderMetadataCorruptionTest.java
+1 −1 core/src/test/java/io/questdb/test/cairo/TableReaderTest.java
+3 −6 core/src/test/java/io/questdb/test/cairo/TableWriterTest.java
+1 −2 core/src/test/java/io/questdb/test/cairo/o3/O3MaxLagFuzzTest.java
+1 −2 core/src/test/java/io/questdb/test/cairo/o3/O3ParquetPartitionFuzzTest.java
+6 −6 core/src/test/java/io/questdb/test/cairo/vm/ContiguousMemoryMTest.java
+5 −5 core/src/test/java/io/questdb/test/cairo/vm/ContiguousOffsetMappedMemoryTest.java
+1 −1 core/src/test/java/io/questdb/test/cairo/wal/WalListenerTest.java
+8 −4 core/src/test/java/io/questdb/test/cairo/wal/WalTableSqlTest.java
+25 −54 core/src/test/java/io/questdb/test/cairo/wal/WalWriterTest.java
+6 −6 core/src/test/java/io/questdb/test/cutlass/http/IODispatcherTest.java
+17 −8 core/src/test/java/io/questdb/test/cutlass/http/WebConsoleLoadingTest.java
+1 −1 core/src/test/java/io/questdb/test/cutlass/line/tcp/LineTcpReceiverTest.java
+1 −1 core/src/test/java/io/questdb/test/fuzz/FuzzDropCreateTableOperation.java
+5 −5 core/src/test/java/io/questdb/test/griffin/AlterTableDetachPartitionTest.java
+1 −1 core/src/test/java/io/questdb/test/griffin/CheckpointTest.java
+1 −1 core/src/test/java/io/questdb/test/griffin/ParallelGroupByFuzzTest.java
+657 −759 core/src/test/java/io/questdb/test/griffin/engine/window/WindowFunctionTest.java
+0 −24 core/src/test/java/io/questdb/test/griffin/engine/window/WindowFunctionUnitTest.java
+2 −5 core/src/test/java/io/questdb/test/tools/TestUtils.java
6 changes: 3 additions & 3 deletions packages/web-console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ If the server has a context path configured with the `http.context.path` option,
the dev server is aware of it, and it proxies requests accordingly.\
We can set the context path with the following environment variable before starting dev server:
```
CONTEXT_PATH=/instance2
export CONTEXT_PATH
QDB_HTTP_CONTEXT_PATH=/instance2
export QDB_HTTP_CONTEXT_PATH
yarn workspace @questdb/web-console start
```

Expand All @@ -46,7 +46,7 @@ After the above the web console is available on [localhost:9999/instance2/](http
If the context path is removed from the server configuration, we also need to clear the environment variable,
and restart the dev server:
```
unset CONTEXT_PATH
unset QDB_HTTP_CONTEXT_PATH
yarn workspace @questdb/web-console start
```

Expand Down
21 changes: 13 additions & 8 deletions packages/web-console/serve-dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@ const url = require("url")
const fs = require("fs")
const path = require("path")

const contextPath = process.env.QDB_HTTP_CONTEXT_PATH || ""

const server = http.createServer((req, res) => {
const { method } = req
const urlData = url.parse(req.url)
const baseUrl = "http://" + req.headers.host + contextPath;
const reqUrl = new url.URL(req.url, baseUrl);
const reqPath = reqUrl.pathname + reqUrl.search;
const reqPathName = reqUrl.pathname;

if (
urlData.pathname.startsWith("/exec") ||
urlData.pathname.startsWith("/settings") ||
urlData.pathname.startsWith("/warnings")
reqPathName.startsWith("/exec") ||
reqPathName.startsWith("/settings") ||
reqPathName.startsWith("/warnings")
) {
// proxy /exec requests to localhost:9000
const options = {
hostname: "localhost",
port: 9000,
path: urlData.path,
path: contextPath + reqPath,
method,
headers: req.headers,
}
Expand All @@ -34,16 +39,16 @@ const server = http.createServer((req, res) => {
"packages",
"web-console",
"dist",
["", "/"].some((p) => urlData.pathname === p)
["", "/"].some((p) => reqPathName === p)
? "index.html"
: urlData.pathname,
: reqPathName,
)
const fileStream = fs.createReadStream(filePath)

fileStream.on("error", (err) => {
if (err.code === "ENOENT") {
res.statusCode = 404
res.end(`File not found: ${urlData}`)
res.end(`File not found: ${reqPath}`)
} else {
res.statusCode = 500
res.end(`Server error: ${err}`)
Expand Down
2 changes: 1 addition & 1 deletion packages/web-console/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const config = {
port: 9999,
backendUrl: "http://127.0.0.1:9000",
isProduction: process.env.NODE_ENV === "production",
contextPath: process.env.CONTEXT_PATH || "",
contextPath: process.env.QDB_HTTP_CONTEXT_PATH || "",
}

module.exports = {
Expand Down
Loading

0 comments on commit 4108b89

Please sign in to comment.