From 43729e050dfbd20f7d652a89fc10346843e489d1 Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 12 Dec 2022 16:19:33 +0200 Subject: [PATCH 1/4] add test --- test/integration/systemEngine.test.ts | 92 ++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/test/integration/systemEngine.test.ts b/test/integration/systemEngine.test.ts index f02d8553..9a34af97 100644 --- a/test/integration/systemEngine.test.ts +++ b/test/integration/systemEngine.test.ts @@ -6,9 +6,57 @@ const connectionOptions = { engineName: process.env.FIREBOLT_ENGINE_NAME as string }; -jest.setTimeout(30000); +jest.setTimeout(1000000); describe("system engine", () => { + const engineName = connectionOptions.engineName + "_system_test"; + const databaseName = process.env.FIREBOLT_DATABASE + "_system_test"; + + beforeAll(async () => { + const firebolt = Firebolt({ + apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string + }); + + const connection = await firebolt.connect({ + ...connectionOptions, + engineName: "system" + }); + + try { + await connection.execute(`create database if not exists ${databaseName}`); + + await connection.execute( + `create engine if not exists ${engineName} with REGION = 'us-east-1' SPEC = 'B1' SCALE = 1` + ); + + await connection.execute( + `attach engine ${engineName} to ${databaseName}` + ); + } catch (error) { + console.log(error); + expect(true).toEqual(false); + } + }); + + afterAll(async () => { + const firebolt = Firebolt({ + apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string + }); + + const connection = await firebolt.connect({ + ...connectionOptions, + engineName: "system" + }); + + try { + // await connection.execute(`drop engine if exists ${engineName}`); + // await connection.execute(`drop database if exists ${databaseName}`); + } catch (error) { + console.log(error); + expect(true).toEqual(false); + } + }); + it("resolve engine endpoint", async () => { const firebolt = Firebolt({ apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string @@ -30,6 +78,48 @@ describe("system engine", () => { engineName: "system" }); + try { + const statement = await connection.execute("show engines"); + const { data } = await statement.fetchResult(); + const engine = (data as unknown[][]).find(row => row[0] === engineName); + expect(engine).toBeTruthy(); + } catch (error) { + console.log(error); + expect(true).toEqual(false); + } + }); + it("able to list databases", async () => { + const firebolt = Firebolt({ + apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string + }); + + const connection = await firebolt.connect({ + ...connectionOptions, + engineName: "system" + }); + + try { + const statement = await connection.execute("show engines"); + const { data } = await statement.fetchResult(); + const database = (data as unknown[][]).find( + row => row[0] === databaseName + ); + expect(database).toBeTruthy(); + } catch (error) { + console.log(error); + expect(true).toEqual(false); + } + }); + it("start/stop engine", async () => { + const firebolt = Firebolt({ + apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string + }); + + const connection = await firebolt.connect({ + ...connectionOptions, + engineName: "system" + }); + try { const statement = await connection.execute("show engines"); const { data } = await statement.fetchResult(); From 3e90225e52b994f3dbd3909f40f366fb490fc3eb Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 12 Dec 2022 16:29:31 +0200 Subject: [PATCH 2/4] cleanup --- test/integration/systemEngine.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/integration/systemEngine.test.ts b/test/integration/systemEngine.test.ts index 9a34af97..acee8ccd 100644 --- a/test/integration/systemEngine.test.ts +++ b/test/integration/systemEngine.test.ts @@ -22,6 +22,12 @@ describe("system engine", () => { engineName: "system" }); + try { + await connection.execute(`drop engine if exists ${engineName}`); + await connection.execute(`drop database if exists ${databaseName}`); + } catch (error) { + console.log(error); + } try { await connection.execute(`create database if not exists ${databaseName}`); @@ -49,8 +55,8 @@ describe("system engine", () => { }); try { - // await connection.execute(`drop engine if exists ${engineName}`); - // await connection.execute(`drop database if exists ${databaseName}`); + await connection.execute(`drop engine if exists ${engineName}`); + await connection.execute(`drop database if exists ${databaseName}`); } catch (error) { console.log(error); expect(true).toEqual(false); From a301ae72dbf075983da0e9f661a482824e40cdc2 Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 12 Dec 2022 16:36:53 +0200 Subject: [PATCH 3/4] catch --- test/integration/systemEngine.test.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/test/integration/systemEngine.test.ts b/test/integration/systemEngine.test.ts index acee8ccd..178eb9e7 100644 --- a/test/integration/systemEngine.test.ts +++ b/test/integration/systemEngine.test.ts @@ -22,12 +22,17 @@ describe("system engine", () => { engineName: "system" }); - try { - await connection.execute(`drop engine if exists ${engineName}`); - await connection.execute(`drop database if exists ${databaseName}`); - } catch (error) { - console.log(error); - } + await connection + .execute(`drop engine if exists ${engineName}`) + .catch(error => { + console.log(error); + }); + + await connection + .execute(`drop database if exists ${databaseName}`) + .catch(error => { + console.log(error); + }); try { await connection.execute(`create database if not exists ${databaseName}`); @@ -127,8 +132,8 @@ describe("system engine", () => { }); try { - const statement = await connection.execute("show engines"); - const { data } = await statement.fetchResult(); + await connection.execute(`start engine ${engineName}`); + await connection.execute(`stop engine ${engineName}`); } catch (error) { console.log(error); expect(true).toEqual(false); From 2e5914b265c4d941d30b45b61e8b2dc34c990a64 Mon Sep 17 00:00:00 2001 From: Vitalii Date: Mon, 12 Dec 2022 17:18:06 +0200 Subject: [PATCH 4/4] skip start stop --- test/integration/systemEngine.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/systemEngine.test.ts b/test/integration/systemEngine.test.ts index 178eb9e7..172722ff 100644 --- a/test/integration/systemEngine.test.ts +++ b/test/integration/systemEngine.test.ts @@ -121,7 +121,7 @@ describe("system engine", () => { expect(true).toEqual(false); } }); - it("start/stop engine", async () => { + it.skip("start/stop engine", async () => { const firebolt = Firebolt({ apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string });