Skip to content

Commit 1e65346

Browse files
committed
Update and streamline tests
1 parent 1df3b3d commit 1e65346

File tree

4 files changed

+121
-187
lines changed

4 files changed

+121
-187
lines changed

src/tests/__snapshots__/query-cross-region.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`BoilingData in all North-America and Europe AWS Regions runs query succesfully in other regions too 1`] = `
3+
exports[`BD can switch the WebSocket connection endpoint dynamically run a local query in all supported regions 1`] = `
44
Array [
55
Array [
66
Object {
@@ -22,7 +22,7 @@ Array [
2222
]
2323
`;
2424

25-
exports[`BoilingData in all North-America and Europe AWS Regions runs query succesfully in other regions too 2`] = `
25+
exports[`BD can switch the WebSocket connection endpoint dynamically run a local query in all supported regions 2`] = `
2626
Array [
2727
Array [
2828
Object {
@@ -44,7 +44,7 @@ Array [
4444
]
4545
`;
4646

47-
exports[`BoilingData in all North-America and Europe AWS Regions runs query succesfully in other regions too 3`] = `
47+
exports[`BD can switch the WebSocket connection endpoint dynamically run a local query in all supported regions 3`] = `
4848
Array [
4949
Array [
5050
Object {
@@ -66,7 +66,7 @@ Array [
6666
]
6767
`;
6868

69-
exports[`BoilingData in all North-America and Europe AWS Regions runs query succesfully in other regions too 4`] = `
69+
exports[`BD can switch the WebSocket connection endpoint dynamically run a local query in all supported regions 4`] = `
7070
Array [
7171
Array [
7272
Object {

src/tests/__snapshots__/query.test.ts.snap

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -387,28 +387,6 @@ Array [
387387

388388
exports[`boilingdata with DuckDB run single query with scan cursor over the size 1`] = `Array []`;
389389

390-
exports[`boilingdata with Glue Tables can do partition filter push down 1`] = `
391-
Array [
392-
Object {
393-
"status": "Catalog Error: Table with name nyctaxis does not exist!
394-
Did you mean \\"temp.information_schema.tables\\"?
395-
LINE 1: SELECT * FROM \\"default\\".nyctaxis WHERE year = 2009 AN...
396-
^",
397-
},
398-
]
399-
`;
400-
401-
exports[`boilingdata with Glue Tables can read S3 object paths from Glue Table 1`] = `
402-
Array [
403-
Object {
404-
"status": "Catalog Error: Table with name nyctaxis does not exist!
405-
Did you mean \\"system.information_schema.tables\\"?
406-
LINE 1: SELECT * FROM \\"default\\".nyctaxis LIMIT 10;
407-
^",
408-
},
409-
]
410-
`;
411-
412390
exports[`boilingdata with promise method can run simple promise based query 1`] = `
413391
Array [
414392
Object {

src/tests/query-cross-region.test.ts

Lines changed: 77 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ globalCallbacks.onSocketClose = () => {
2222
logger.info("socket closed");
2323
return undefined;
2424
};
25+
2526
const regions: BDAWSRegion[] = [
2627
"eu-west-1",
2728
"eu-north-1",
@@ -36,95 +37,95 @@ const regions: BDAWSRegion[] = [
3637
// "ca-central-1",
3738
];
3839

40+
// Create connection to each region
41+
const bdAllRegions = regions.map(region => ({
42+
region,
43+
bd: new BoilingData({ username, password, globalCallbacks, logLevel, region }),
44+
}));
45+
const connMap = new Map<string, BoilingData>();
46+
bdAllRegions.forEach(conn => connMap.set(conn.region, conn.bd));
47+
3948
describe("BD can switch the WebSocket connection endpoint dynamically", () => {
40-
it("run single query from 4 different supported regions", async () => {
41-
const expected = [
42-
{
43-
DOLocationID: 1,
44-
PULocationID: 1,
45-
RatecodeID: 5,
46-
VendorID: 1,
47-
congestion_surcharge: 0,
48-
extra: 0,
49-
fare_amount: 121,
50-
improvement_surcharge: 0.3,
51-
mta_tax: 0,
52-
passenger_count: 2,
53-
payment_type: 1,
54-
store_and_fwd_flag: "N",
55-
tip_amount: 0,
56-
tolls_amount: 0,
57-
total_amount: 121.3,
58-
tpep_dropoff_datetime: 1551410222000,
59-
tpep_pickup_datetime: 1551410199000,
60-
trip_distance: 0,
61-
},
62-
{
63-
DOLocationID: 1,
64-
PULocationID: 1,
65-
RatecodeID: 5,
66-
VendorID: 1,
67-
congestion_surcharge: 0,
68-
extra: 0,
69-
fare_amount: 110,
70-
improvement_surcharge: 0.3,
71-
mta_tax: 0,
72-
passenger_count: 1,
73-
payment_type: 1,
74-
store_and_fwd_flag: "N",
75-
tip_amount: 10,
76-
tolls_amount: 0,
77-
total_amount: 120.3,
78-
tpep_dropoff_datetime: 1551415659000,
79-
tpep_pickup_datetime: 1551415597000,
80-
trip_distance: 18.4,
81-
},
82-
];
49+
const expected = [
50+
{
51+
DOLocationID: 1,
52+
PULocationID: 1,
53+
RatecodeID: 5,
54+
VendorID: 1,
55+
congestion_surcharge: 0,
56+
extra: 0,
57+
fare_amount: 121,
58+
improvement_surcharge: 0.3,
59+
mta_tax: 0,
60+
passenger_count: 2,
61+
payment_type: 1,
62+
store_and_fwd_flag: "N",
63+
tip_amount: 0,
64+
tolls_amount: 0,
65+
total_amount: 121.3,
66+
tpep_dropoff_datetime: 1551410222000,
67+
tpep_pickup_datetime: 1551410199000,
68+
trip_distance: 0,
69+
},
70+
{
71+
DOLocationID: 1,
72+
PULocationID: 1,
73+
RatecodeID: 5,
74+
VendorID: 1,
75+
congestion_surcharge: 0,
76+
extra: 0,
77+
fare_amount: 110,
78+
improvement_surcharge: 0.3,
79+
mta_tax: 0,
80+
passenger_count: 1,
81+
payment_type: 1,
82+
store_and_fwd_flag: "N",
83+
tip_amount: 10,
84+
tolls_amount: 0,
85+
total_amount: 120.3,
86+
tpep_dropoff_datetime: 1551415659000,
87+
tpep_pickup_datetime: 1551415597000,
88+
trip_distance: 18.4,
89+
},
90+
];
91+
92+
beforeAll(async () => await Promise.all(bdAllRegions.map(conn => conn.bd.connect())));
93+
94+
afterAll(async () => await Promise.all(bdAllRegions.map(conn => conn.bd.close())));
8395

96+
it("run a local query in all supported regions", async () => {
97+
// Run all in parallel
98+
await Promise.all(
99+
regions.map(async region => {
100+
const rows: any[] = [];
101+
const bucket = region == "eu-west-1" ? "boilingdata-demo" : `${region}-boilingdata-demo`;
102+
const sql = `SELECT * FROM parquet_scan('s3://${bucket}/test.parquet') LIMIT 1;`;
103+
rows.push(await connMap.get(region)?.execQueryPromise({ sql }));
104+
const sorted = rows.sort();
105+
console.log(sorted);
106+
expect(sorted).toMatchSnapshot();
107+
}),
108+
);
109+
});
110+
it("run single query to eu-west-1 from all supported regions", async () => {
84111
// Run all queries in parallel
85112
await Promise.all(
86113
regions.map(async region => {
87114
const sql = `SELECT * FROM parquet_scan('s3://boilingdata-demo/demo2.parquet') ORDER BY DOLocationID, PULocationID, tpep_dropoff_datetime, tpep_pickup_datetime, trip_distance LIMIT 2;`;
88-
const bd = new BoilingData({
89-
username,
90-
password,
91-
globalCallbacks,
92-
logLevel,
93-
region,
94-
});
95-
await bd.connect();
96115
// The JSON is bigint JSON, thus converting back to "normal", to get Object properties inherited, like toString()
97-
const rows = JSON.parse(JSON.stringify(await bd.execQueryPromise({ sql })));
116+
const rows = JSON.parse(JSON.stringify(await connMap.get(region)?.execQueryPromise({ sql })));
98117
expect(rows.sort()).toEqual(expected);
99-
await bd.close();
100118
}),
101119
);
102120
});
103-
});
104-
105-
describe("BoilingData in all North-America and Europe AWS Regions", () => {
106-
it("runs query succesfully in other regions too", async () => {
107-
// Run all in parallel
121+
it("run single query to us-east-2 from all supported regions", async () => {
122+
// Run all queries in parallel
108123
await Promise.all(
109124
regions.map(async region => {
110-
const rows: any[] = [];
111-
const bdInstance = new BoilingData({
112-
username,
113-
password,
114-
globalCallbacks,
115-
logLevel,
116-
region,
117-
});
118-
await bdInstance.connect();
119-
logger.info(`connected to region ${region}`);
120-
const bucket = region == "eu-west-1" ? "boilingdata-demo" : `${region}-boilingdata-demo`;
121-
const sql = `SELECT * FROM parquet_scan('s3://${bucket}/test.parquet') LIMIT 1;`;
122-
rows.push(await bdInstance.execQueryPromise({ sql }));
123-
await bdInstance.close();
124-
logger.info(`connection closed to region ${region}`);
125-
const sorted = rows.sort();
126-
console.log(sorted);
127-
expect(sorted).toMatchSnapshot();
125+
const sql = `SELECT * FROM parquet_scan('s3://us-east-2-boilingdata-demo/demo2.parquet') ORDER BY DOLocationID, PULocationID, tpep_dropoff_datetime, tpep_pickup_datetime, trip_distance LIMIT 2;`;
126+
// The JSON is bigint JSON, thus converting back to "normal", to get Object properties inherited, like toString()
127+
const rows = JSON.parse(JSON.stringify(await connMap.get(region)?.execQueryPromise({ sql })));
128+
expect(rows.sort()).toEqual(expected);
128129
}),
129130
);
130131
});

0 commit comments

Comments
 (0)