Skip to content

Commit 9045ee2

Browse files
feat: FIR-42655 firebolt node sdk draining engine status not recognized (#129)
1 parent a226cbb commit 9045ee2

File tree

5 files changed

+60
-7
lines changed

5 files changed

+60
-7
lines changed

src/service/engine/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class EngineModel {
5252
}
5353

5454
async delete() {
55-
if (this.current_status_summary == EngineStatusSummary.DELETING) {
55+
if (this.current_status_summary == EngineStatusSummary.DRAINING) {
5656
return;
5757
}
5858
const query = `DROP ENGINE "${this.name}"`;

src/service/engine/types.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ export function processEngineStatus(
2626
}
2727

2828
export enum EngineStatusSummary {
29-
DELETING = "Dropping",
30-
REPAIRING = "Repairing",
31-
RUNNING = "Running",
3229
STARTING = "Starting",
33-
STARTING_INITIALIZING = "Started",
30+
RUNNING = "Running",
31+
RESIZING = "Resizing",
32+
DRAINING = "Draining",
3433
STOPPED = "Stopped",
3534
STOPPING = "Stopping",
3635
// Specific for V1, here are just for typing match
@@ -39,7 +38,9 @@ export enum EngineStatusSummary {
3938
RESTARTING = "ENGINE_STATUS_SUMMARY_RESTARTING",
4039
RESTARTING_INITIALIZING = "ENGINE_STATUS_SUMMARY_RESTARTING_INITIALIZING",
4140
UNSPECIFIED = "ENGINE_STATUS_SUMMARY_UNSPECIFIED",
42-
UPGRADING = "ENGINE_STATUS_SUMMARY_UPGRADING"
41+
UPGRADING = "ENGINE_STATUS_SUMMARY_UPGRADING",
42+
REPAIRING = "ENGINE_STATUS_SUMMARY_REPAIRING",
43+
STARTING_INITIALIZING = "ENGINE_STATUS_SUMMARY_STARTING_INITIALIZING",
4344
}
4445

4546
export enum EngineType {

src/service/engine/v1/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type Engine = {
99
};
1010

1111
export enum EngineStatusSummary {
12-
DELETING = "ENGINE_STATUS_SUMMARY_DELETING",
12+
DRAINING = "ENGINE_STATUS_SUMMARY_DELETING",
1313
REPAIRING = "ENGINE_STATUS_SUMMARY_REPAIRING",
1414
RUNNING = "ENGINE_STATUS_SUMMARY_RUNNING",
1515
STARTING = "ENGINE_STATUS_SUMMARY_STARTING",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Firebolt } from "../../../src/index";
2+
3+
const connectionParams = {
4+
auth: {
5+
client_id: process.env.FIREBOLT_CLIENT_ID as string,
6+
client_secret: process.env.FIREBOLT_CLIENT_SECRET as string
7+
},
8+
account: process.env.FIREBOLT_ACCOUNT as string,
9+
database: process.env.FIREBOLT_DATABASE as string,
10+
engineName: process.env.FIREBOLT_ENGINE_NAME as string
11+
};
12+
13+
jest.setTimeout(100000);
14+
15+
describe("geography", () => {
16+
it("handles select geo", async () => {
17+
const firebolt = Firebolt({
18+
apiEndpoint: process.env.FIREBOLT_API_ENDPOINT as string
19+
});
20+
21+
const connection = await firebolt.connect(connectionParams);
22+
23+
await connection.execute("SET advanced_mode=1");
24+
await connection.execute("SET enable_geography=true");
25+
26+
const statement = await connection.execute(
27+
"select 'POINT(1 1)'::geography;"
28+
);
29+
30+
const { data, meta } = await statement.fetchResult();
31+
expect(meta[0].type).toEqual("geography");
32+
const row = data[0];
33+
expect((row as unknown[])[0]).toEqual("0101000020E6100000FEFFFFFFFFFFEF3F000000000000F03F");
34+
});
35+
});

test/unit/v2/engine.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,23 @@ describe("engine service", () => {
589589
delete process.env.ENGINE_NAME;
590590
});
591591

592+
it("Parse engine statuses", async () => {
593+
// Taken from https://docs.firebolt.io/Overview/engine-fundamentals.html#viewing-and-understanding-engine-status
594+
const statuses = [
595+
["STARTING", EngineStatusSummary.STARTING],
596+
["RUNNING", EngineStatusSummary.RUNNING],
597+
["RESIZING", EngineStatusSummary.RESIZING],
598+
["DRAINING", EngineStatusSummary.DRAINING],
599+
["STOPPING", EngineStatusSummary.STOPPING],
600+
["STOPPED", EngineStatusSummary.STOPPED]
601+
];
602+
for (const [rawStatus, status] of statuses) {
603+
expect(processEngineStatus(rawStatus)).toEqual(status);
604+
}
605+
expect(processEngineStatus(undefined)).toBe(undefined);
606+
expect(processEngineStatus("unexisting")).not.toBeTruthy();
607+
});
608+
592609
it("Parses different engine statuses correctly", async () => {
593610
const statuses = ["RUNNING", "Running", "running"];
594611
for (const status of statuses) {

0 commit comments

Comments
 (0)