Repository navigation
Reuse feature-flag responses across connections to the same host #630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5f7a754
3ce075d
f6abb2f
6fe6195
c712c07
65e614c
f4eef13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { expect } from 'chai'; | ||
| import sinon from 'sinon'; | ||
| import { DBSQLClient } from '../../lib'; | ||
| import config from './utils/config'; | ||
| import FeatureFlagCache from '../../lib/FeatureFlagCache'; | ||
|
|
||
| describe('Thrift feature flags across idle reconnects', () => { | ||
| let sharedContexts: sinon.SinonStub; | ||
| let idleContexts: sinon.SinonStub; | ||
|
|
||
| beforeEach(() => { | ||
| sharedContexts = sinon.stub(FeatureFlagCache as any, 'sharedContexts').value(new Map()); | ||
| idleContexts = sinon.stub(FeatureFlagCache as any, 'idleContexts').value(new Map()); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| idleContexts.restore(); | ||
| sharedContexts.restore(); | ||
| }); | ||
|
|
||
| for (const reuseClient of [false, true]) { | ||
| it(`reuses flags and preserves results when ${ | ||
| reuseClient ? 'reconnecting a client' : 'creating another client' | ||
| }`, async () => { | ||
| const fetch = sinon.spy(FeatureFlagCache.prototype as any, 'fetchFeatureFlags'); | ||
| let client = new DBSQLClient(); | ||
| let enabled: boolean | undefined; | ||
| try { | ||
| const cycle = async (iteration: number) => { | ||
| if (!reuseClient && iteration > 0) client = new DBSQLClient(); | ||
| try { | ||
| await client.connect({ | ||
| host: config.host, | ||
| path: config.path, | ||
| token: config.token, | ||
| userAgentEntry: `feature-flag-reconnect-${reuseClient}`, | ||
| }); | ||
| if (iteration === 0) enabled = client.getTelemetryStats() !== undefined; | ||
| expect(client.getTelemetryStats() !== undefined).to.equal(enabled); | ||
| const session = await client.openSession(); | ||
| try { | ||
| const operation = await session.executeStatement('SELECT 1 AS value, CAST(NULL AS STRING) AS missing'); | ||
| try { | ||
| expect(await operation.fetchAll({ maxRows: 1 })).to.deep.equal([{ value: 1, missing: null }]); | ||
| } finally { | ||
| await operation.close(); | ||
| } | ||
| } finally { | ||
| await session.close(); | ||
| } | ||
| } finally { | ||
| await client.close(); | ||
| } | ||
| }; | ||
| await cycle(0); | ||
| await cycle(1); | ||
| expect(fetch.callCount).to.equal(1); | ||
| } finally { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 Low — The e2e test asserts 🔀 Found by Claude Opus 5.5 · confirmed by the judge |
||
| fetch.restore(); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.