Skip to content

Commit

Permalink
Add 5.0 beta to test matrix (#926)
Browse files Browse the repository at this point in the history
  • Loading branch information
scotttrinh authored Apr 2, 2024
1 parent 5a06139 commit cbcf83a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 34 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
- os: ubuntu-latest
node-version: "20"
edgedb-version: "nightly"
- os: ubuntu-latest
node-version: "20"
edgedb-version: "5.0-beta.2"
- os: ubuntu-latest
node-version: "20"
edgedb-version: "3"
Expand Down Expand Up @@ -107,13 +110,13 @@ jobs:
yarn workspace @edgedb/integration-legacy test:ci
- name: Run query builder integration tests lts
if: ${{ matrix.edgedb-version == '3' || matrix.edgedb-version == 'stable' || matrix.edgedb-version == 'nightly' }}
if: ${{ matrix.edgedb-version == '3' || matrix.edgedb-version == 'stable' || matrix.edgedb-version == 'nightly' || matrix.edgedb-version == '5.0-beta.2' }}
run: |
yarn workspace @edgedb/integration-lts test:ci
yarn workspace @edgedb/integration-lts run bench:types
- name: Run query builder integration tests stable
if: ${{ matrix.edgedb-version == 'stable' || matrix.edgedb-version == 'nightly' }}
if: ${{ matrix.edgedb-version == 'stable' || matrix.edgedb-version == 'nightly' || matrix.edgedb-version == '5.0-beta.2' }}
run: |
yarn workspace @edgedb/integration-stable test:ci
Expand Down
19 changes: 12 additions & 7 deletions packages/driver/test/retry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import * as errors from "../src/errors";
import { Client } from "../src/index.node";
import { type Client } from "../src/index.node";
import { defaultBackoff, RetryOptions } from "../src/options";
import { getClient } from "./testbase";

Expand All @@ -34,7 +34,7 @@ class Barrier {
}
this._counter -= 1;
if (this._counter == 0) {
for (let waiter of this._waiters.splice(0, this._waiters.length)) {
for (const waiter of this._waiters.splice(0, this._waiters.length)) {
waiter();
}
} else {
Expand Down Expand Up @@ -94,13 +94,13 @@ beforeAll(async () => {
};
`);
});
});
}, 50_000);

afterAll(async () => {
await run(async (con) => {
await con.execute(`DROP TYPE ${typename};`);
});
});
}, 50_000);

test("retry: regular 01", async () => {
await run(async (con) => {
Expand All @@ -116,7 +116,7 @@ test("retry: regular 01", async () => {

async function checkRetries(client: Client, client2: Client, name: string) {
let iterations = 0;
let barrier = new Barrier(2);
const barrier = new Barrier(2);

async function transaction(client: Client): Promise<unknown> {
return await client.transaction(async (tx) => {
Expand Down Expand Up @@ -152,7 +152,10 @@ async function checkRetries(client: Client, client2: Client, name: string) {
});
}

let results = await Promise.all([transaction(client), transaction(client2)]);
const results = await Promise.all([
transaction(client),
transaction(client2),
]);
results.sort();
expect(results).toEqual([1, 2]);
expect(iterations).toEqual(3);
Expand Down Expand Up @@ -199,7 +202,9 @@ test("retry attempts", async () => {

throw new errors.TransactionConflictError();
});
} catch {}
} catch {
/* empty catch */
}

expect(counter).toBe(5);

Expand Down
4 changes: 1 addition & 3 deletions packages/driver/test/retryConnError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ test("retry readonly queries: complete fetch", async () => {
await expect(
nonRetryingClient.query(`select 'Hello edgedb-js!'`)
).rejects.toThrow();

await client.close();
});

test("retry readonly queries: optimistic fetch", async () => {
Expand Down Expand Up @@ -229,4 +227,4 @@ test("non readonly queries: optimistic fetch", async () => {
).toBe(3);

await client.close();
});
}, 15_000);
4 changes: 2 additions & 2 deletions packages/driver/test/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ if (getEdgeDBVersion().major >= 2) {

client.close();
}
}, 10000);
}, 20_000);

test("withConfig", async () => {
const client = getClient({ concurrency: 1 });
Expand Down Expand Up @@ -195,7 +195,7 @@ if (getEdgeDBVersion().major >= 2) {

client.close();
}
});
}, 50_000);
} else {
test("legacy protocol", async () => {
const client = getClient();
Expand Down
48 changes: 28 additions & 20 deletions packages/driver/test/transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import * as errors from "../src/errors";
import { Client } from "../src/index.node";
import { type Client } from "../src/index.node";
import { IsolationLevel, TransactionOptions } from "../src/options";
import { sleep } from "../src/utils";
import Event from "../src/primitives/event";
Expand Down Expand Up @@ -47,13 +47,13 @@ beforeAll(async () => {
};
`);
});
});
}, 10_000);

afterAll(async () => {
await run(async (con) => {
await con.execute(`DROP TYPE ${typename};`);
});
});
}, 50_000);

test("transaction: regular 01", async () => {
await run(async (con) => {
Expand All @@ -80,18 +80,18 @@ test("transaction: regular 01", async () => {

expect(items).toHaveLength(0);
});
});
}, 10_000);

function* all_options(): Generator<
[IsolationLevel | undefined, boolean | undefined, boolean | undefined],
void,
void
> {
let levels = [undefined, IsolationLevel.Serializable];
let booleans = [undefined, true, false];
for (let isolation of levels) {
for (let readonly of booleans) {
for (let deferred of booleans) {
const levels = [undefined, IsolationLevel.Serializable];
const booleans = [undefined, true, false];
for (const isolation of levels) {
for (const readonly of booleans) {
for (const deferred of booleans) {
yield [isolation, readonly, deferred];
}
}
Expand All @@ -100,25 +100,33 @@ function* all_options(): Generator<

test("transaction: kinds", async () => {
await run(async (con) => {
for (let [isolation, readonly, defer] of all_options()) {
let partial = { isolation, readonly, defer };
let opt = new TransactionOptions(partial); // class api
for (const [isolation, readonly, defer] of all_options()) {
const partial = { isolation, readonly, defer };
const opt = new TransactionOptions(partial); // class api
await con
.withTransactionOptions(opt)
.withRetryOptions({ attempts: 1 })
.transaction(async (tx) => {});
await con.withTransactionOptions(opt).transaction(async (tx) => {});
.transaction(async () => {
/* no-op */
});
await con.withTransactionOptions(opt).transaction(async () => {
/* no-op */
});
}
});

await run(async (con) => {
for (let [isolation, readonly, defer] of all_options()) {
let opt = { isolation, readonly, defer }; // obj api
for (const [isolation, readonly, defer] of all_options()) {
const opt = { isolation, readonly, defer }; // obj api
await con
.withTransactionOptions(opt)
.withRetryOptions({ attempts: 1 })
.transaction(async (tx) => {});
await con.withTransactionOptions(opt).transaction(async (tx) => {});
.transaction(async () => {
/* no-op */
});
await con.withTransactionOptions(opt).transaction(async () => {
/* no-op */
});
}
});
});
Expand Down Expand Up @@ -183,10 +191,10 @@ test("transaction deadlocking client pool", async () => {
const client = getClient({ concurrency: 1 });

const innerQueryDone = new Event();
let innerQueryResult: any;
let innerQueryResult;

await expect(
client.transaction(async (tx) => {
client.transaction(async () => {
// This query will hang forever waiting on the connection holder
// held by the transaction, which itself will not return the holder
// to the pool until the query completes. This deadlock should be
Expand Down

0 comments on commit cbcf83a

Please sign in to comment.