-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update local testing workflow to allow for parallelism, improved dx (#…
…3707) * update local testing workflow to allow for parallelism, improved dx * update comment * remove extraneous comment * move file/directory removal to before process exit * prettier
- Loading branch information
1 parent
5cc2f23
commit c588b51
Showing
12 changed files
with
105 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
web-local/tests/dashboards/dimension-and-measure-selection.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createServer } from "net"; | ||
|
||
export async function getOpenPort(): Promise<number> { | ||
return new Promise((res) => { | ||
const srv = createServer(); | ||
srv.listen(0, () => { | ||
const address = srv?.address(); | ||
if (!address || typeof address === "string") { | ||
throw new Error("Invalid address"); | ||
} | ||
srv.close(() => res(address.port)); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { test as base } from "@playwright/test"; | ||
import { rmSync, writeFileSync, existsSync, mkdirSync } from "fs"; | ||
import { spawn } from "node:child_process"; | ||
import treeKill from "tree-kill"; | ||
import { getOpenPort } from "./getOpenPort"; | ||
import { asyncWaitUntil } from "@rilldata/web-common/lib/waitUtils"; | ||
import axios from "axios"; | ||
|
||
const BASE_PROJECT_DIRECTORY = "temp/test-project"; | ||
|
||
export const test = base.extend({ | ||
page: async ({ page }, use) => { | ||
const TEST_PORT = await getOpenPort(); | ||
const TEST_PORT_GRPC = await getOpenPort(); | ||
const TEST_PROJECT_DIRECTORY = `${BASE_PROJECT_DIRECTORY}-${TEST_PORT}`; | ||
|
||
rmSync(TEST_PROJECT_DIRECTORY, { | ||
force: true, | ||
recursive: true, | ||
}); | ||
|
||
if (!existsSync(TEST_PROJECT_DIRECTORY)) { | ||
mkdirSync(TEST_PROJECT_DIRECTORY, { recursive: true }); | ||
} | ||
|
||
// Add `rill.yaml` file to the project repo | ||
writeFileSync( | ||
`${TEST_PROJECT_DIRECTORY}/rill.yaml`, | ||
'compiler: rill-beta\ntitle: "Test Project"', | ||
); | ||
|
||
const cmd = `start --no-open --port ${TEST_PORT} --port-grpc ${TEST_PORT_GRPC} --db ${TEST_PROJECT_DIRECTORY}/stage.db?rill_pool_size=4 ${TEST_PROJECT_DIRECTORY}`; | ||
|
||
const childProcess = spawn("../rill", cmd.split(" "), { | ||
stdio: "inherit", | ||
shell: true, | ||
}); | ||
|
||
childProcess.on("error", console.log); | ||
|
||
// Ping runtime until it's ready | ||
await asyncWaitUntil(async () => { | ||
try { | ||
const response = await axios.get( | ||
`http://localhost:${TEST_PORT}/v1/ping`, | ||
); | ||
return response.status === 200; | ||
} catch (err) { | ||
return false; | ||
} | ||
}); | ||
|
||
await page.goto(`http://localhost:${TEST_PORT}`); | ||
|
||
await use(page); | ||
|
||
rmSync(TEST_PROJECT_DIRECTORY, { | ||
force: true, | ||
recursive: true, | ||
}); | ||
|
||
const processExit = new Promise((resolve) => { | ||
childProcess.on("exit", resolve); | ||
}); | ||
|
||
if (childProcess.pid) treeKill(childProcess.pid); | ||
|
||
await processExit; | ||
}, | ||
}); |