Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit c8e35c5

Browse files
LaunchDarklyReleaseBoteli-darklyLaunchDarklyCIbwoskow-ldmaxwellgerber
authored
prepare 6.4.2 release (#250)
* revise tests to use new helper package * misc cleanup * use launchdarkly-js-test-helpers 1.0.0 * fix package reference * minor fixes to config validation messages + add comment * diagnostic eventsInQueue counter should be # of events at last flush * rename eventsInQueue to eventsInLastBatch * don't let user fall outside of last bucket in rollout * add unit tests for basic bucketing logic and edge case * avoid redundant property lookups * fix Redis client parameter to match TS declaration (but still support old incorrect parameter) * add event payload ID * remove mistakenly checked-in test code (note, this SDK key was only valid on staging) * add mention of singleton usage * update diagnostic event info for OS name, data store type, Node version * standardize linting * disallow window and document * fix null/undef checks * misc linting fixes * inlineUsersInEvents is not an unknown option * drop node-sha1 dependency * don't omit streamInits.failed when it's false * bump request dependency to get security patch; loosen some exact dependencies * remove request package; improve polling cache logic + add test * bump typescript version to fix build error in Node 6 * update @types/node to fix TypeScript check step * lint * make sure we keep polling regardless of whether we got new data * use launchdarkly-eventsource, make stream retry behavior consistent * stream retry delay option should be in seconds & should be included in diagnostics * minor test fix * fix: Throw an error on malformed user-supplied logger * don't call unref() on Redis client; ensure that database integration tests close the store * update Redis driver to major version 3 * add test case * allow redisOpts parameter to be omitted * add logger adapter shim + tests * minor cleanup and comments for ch74741 fix (logger wrapper) * fix proxy tunnel configuration and make sure it's used in streaming * change some string concatenation expressions to use interpolation * feat: upgrade winston (#189) * fix merge * remove support for indirect/patch and indirect/put (#182) * reuse same Promise and same event listeners for all waitForInitialization calls * better docs for waitForInitialization + misc doc cleanup (#184) * update js-eventsource to 1.3.1 for stream parsing bugfix (#185) * fix broken logger format (#186) * retroactively update changelog for bugfix in 5.13.2 release * allow get/getAll Redis queries to be queued if Redis client hasn't yet connected * set stream read timeout * adding the alias functionality (#190) * Removed the guides link * remove monkey-patching of setImmediate * Persist contextKind property during feature and custom event transformations (#194) * add inlineUsersInEvents option in TypeScript * Add support for seed to bucketUser * Add note for incorporating seed into evaluation * Send events when the evaluation is from an experiment * Use seed to evaluate. * Clean up test descriptions * Rename variable to be less confusing * Use ternary to eliminate mutation * Make return signature more consistent * Un-prettier the tests * redis lower bounds bump (#199) * update launchdarkly-js-test-helpers to fix TLS tests (#200) * update js-eventsource to remove vulnerability warning (#201) * add CI jobs for all compatible Node versions * CI fixes * more CI fixes * comment * use default value to simplify config * (6.0 - #1) stop saying we're compatible with Node <12 (#203) * add CI jobs for all compatible Node versions (#202) * (6.0 - #2) remove Redis integration (#204) * allow feature store to be specified as a factory (so it can get our logger) * (6.0 - #3) remove Winston (#205) * remove deprecated things for 6.0 (#206) * update node-cache to 5.x (drops old Node compat) * update semver to 7.x (drops old Node compat) * update uuid to 8.x (Node compat, perf improvements, bugfixes) * update dev dependencies * linter * replace lrucache package with lru-cache (#209) * make yaml dependency optional (#210) * update release metadata to include maintenance branch * remove package-lock.json (#211) * rm prerelease changelog * (big segments #1) add interfaces for big segments (#212) * (big segments #2) add all components for big segments except evaluation (#213) * (big segments #3) implement big segments in flag evaluation (#214) * (big segments #4) add standard test suite for big segment store tests + refactor feature store tests (#215) * move new interfaces to a module instead of a namespace (#216) * fix TS export of CachingStoreWrapper * use Releaser v2 config * fix overly specific test expectation that breaks in Node 17 * Initial work on FlagBuilder (#219) * Add TestData factory(with some dummy methods); Initial work on FlagBuilder * fixed indentation and linter errors; fixed an error in update; fixed incorrect test label * fixed typo in TestData store * converted boolean variation constants to be file variables instead of class variables Co-authored-by: charukiewicz <christian@foxhound.systems> Co-authored-by: belevy <ben@foxhound.systems> * implemented FlagRuleBuilder; added .build() methods to FlagBuilder/FlagRuleBuilder and changed tests to avoid using private interface * converted _targets to be Map instead of object literal; changed variationForBoolean to be a module-scoped function instead class-scoped * Implement stream processor(data source) interface for test data * Add TestData to index.js and write out the types for TestData and friends * added testdata documentation to index.d.ts; fix linter errors; changed flag default behavior to create boolean flag * Fix the interface file: reindented to 2 spaces, corrected definition of functions from properties to functions in interfaces; corrected issues in JSDoc comments * modify tests to fix capitalization and actually test the test datasource works as an LDClient updateProcessor. * Fix linter error on defaulted callback * explicitly enable JSDOM types in TypeScript build to avoid errors when jsdom is referenced for some reason * capitalize Big Segments in docs & logs * documentation comment fixes for TestData * pin TypeScript to 4.4.x * move TestData and FIleDataSource to integrations module * lint * rename types used by TestData for clarity (#229) * use varargs semantics for TestFlagBuilder.variations() and add it to the TS interface (#230) * don't ever use for...in (#232) * don't ever use for...in * add null guard * bump launchdarkly-eventsource dependency for sc-136154 fix * use TestData in our own tests (#231) * use TestData in our own tests * update TS interface * lint * typo * fix allFlagsState behavior regarding experimentation * lint * allow "secondary" to be referenced in clauses * don't throw an exception for non-string in semver comparison * correctly handle "client not ready" condition in allFlagsState * lint * Flags with a version of 0 reported as 'unknown' in summary events. (#239) * implement contract test service, not including big segments (#242) Co-authored-by: Eli Bishop <eli@launchdarkly.com> * Implement Application tags for the node SDK. (#241) * update js-eventsource to 1.4.4 for security fix * remove package-lock.json * adjust test expectation about error message to work in recent Node versions * Adds link to Relay Proxy docs * Update index.d.ts Co-authored-by: Eli Bishop <eli@launchdarkly.com> * ensure setTimeout task is cleared when polling is stopped * fix some flaky tests using async blocking logic * rm unused * simplify polling implementation using setInterval * use newer js-test-helpers for async tests * add request number to timeout message * Enforce 64 character limit for application tag values. (#263) Co-authored-by: Eli Bishop <eli@launchdarkly.com> Co-authored-by: LaunchDarklyCI <dev@launchdarkly.com> Co-authored-by: Ben Woskow <bwoskow@launchdarkly.com> Co-authored-by: Maxwell Gerber <maxwell.gerber@mulesoft.com> Co-authored-by: Chris West <solo-github@goeswhere.com> Co-authored-by: Ben Woskow <48036130+bwoskow-ld@users.noreply.github.com> Co-authored-by: Mike Zorn <mike@launchdarkly.com> Co-authored-by: Robert J. Neal <rneal@launchdarkly.com> Co-authored-by: Ben Levy <benjaminlevy007@gmail.com> Co-authored-by: charukiewicz <christian@foxhound.systems> Co-authored-by: belevy <ben@foxhound.systems> Co-authored-by: charukiewicz <charukiewicz@protonmail.com> Co-authored-by: LaunchDarklyReleaseBot <launchdarklyreleasebot@launchdarkly.com> Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> Co-authored-by: Ember Stevens <ember.stevens@launchdarkly.com> Co-authored-by: Ember Stevens <79482775+ember-stevens@users.noreply.github.com>
1 parent 7098956 commit c8e35c5

File tree

11 files changed

+47
-65
lines changed

11 files changed

+47
-65
lines changed

.circleci/config.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ workflows:
1616
docker-image: cimg/node:current
1717
run-lint: true
1818
- build-test-linux:
19-
name: Node 16.3
20-
docker-image: cimg/node:16.3
19+
name: Node 17.9
20+
docker-image: cimg/node:17.9
21+
- build-test-linux:
22+
name: Node 16.14
23+
docker-image: cimg/node:16.14
2124
- build-test-linux:
2225
name: Node 15.14
2326
docker-image: cimg/node:15.14
2427
- build-test-linux:
25-
name: Node 14.17
26-
docker-image: cimg/node:14.17
28+
name: Node 14.19
29+
docker-image: cimg/node:14.19
2730
- build-test-linux:
2831
name: Node 13.14
2932
docker-image: cimg/node:13.14

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ To verify that the TypeScript declarations compile correctly (this involves comp
3838
npm run check-typescript
3939
```
4040

41+
To run the SDK contract test suite (see [`contract-tests/README.md`](./contract-tests/README.md)):
42+
43+
```bash
44+
npm run contract-tests
45+
```
46+
4147
### Auditing package dependencies
4248

4349
The `npm audit` tool compares all dependencies and transitive dependencies to a database of package versions with known vulnerabilities. However, the output of this tool includes both runtime and development dependencies.

configuration.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ module.exports = (function () {
6363
config.logger.warn(messages.invalidTagValue(name));
6464
return undefined;
6565
}
66+
if (tagValue.length > 64) {
67+
config.logger.warn(messages.tagValueTooLong(name));
68+
return undefined;
69+
}
6670
return tagValue;
6771
}
6872

messages.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ exports.wrongOptionTypeBoolean = (name, actualType) =>
2727
`Config option "${name}" should be a boolean, got ${actualType}, converting to boolean`;
2828

2929
exports.invalidTagValue = name => `Config option "${name}" must only contain letters, numbers, ., _ or -.`;
30+
31+
exports.tagValueTooLong = name => `Value of "${name}" was longer than 64 characters and was discarded.`;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"eslint-plugin-prettier": "^3.4.0",
5050
"jest": "^27.0.4",
5151
"jest-junit": "^12.2.0",
52-
"launchdarkly-js-test-helpers": "^1.2.1",
52+
"launchdarkly-js-test-helpers": "^2.2.0",
5353
"prettier": "^2.3.1",
5454
"tmp": "^0.2.1",
5555
"typescript": "~4.4.4",

test/LDClient-tls-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import {
44
AsyncQueue,
55
TestHttpHandlers,
66
TestHttpServer,
7+
failOnTimeout,
78
withCloseable
89
} from 'launchdarkly-js-test-helpers';
910
import * as stubs from './stubs';
10-
import { failIfTimeout } from './test_helpers';
1111

1212
describe('LDClient TLS configuration', () => {
1313
const sdkKey = 'secret';
@@ -46,9 +46,9 @@ describe('LDClient TLS configuration', () => {
4646
};
4747

4848
await withCloseable(LDClient.init(sdkKey, config), async client => {
49-
const message1 = await failIfTimeout(logCapture.warn.take(), 1000);
49+
const message1 = await failOnTimeout(logCapture.warn.take(), 1000, 'timed out waiting for log message');
5050
expect(message1).toMatch(/only disable the streaming API/); // irrelevant message due to our use of polling mode
51-
const message2 = await failIfTimeout(logCapture.warn.take(), 1000);
51+
const message2 = await failOnTimeout(logCapture.warn.take(), 1000, 'timed out waiting for log message');
5252
expect(message2).toMatch(/self.signed/);
5353
});
5454
});

test/configuration-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ describe('configuration', function() {
196196
expect(configIn.logger.warn).toHaveBeenCalledTimes(1);
197197
});
198198

199+
it('logs a warning when a tag value is too long', async () => {
200+
const configIn = emptyConfigWithMockLogger();
201+
configIn.application = { id: 'a'.repeat(65), version: 'b'.repeat(64) };
202+
expect(configuration.validate(configIn).application.id).toBeUndefined();
203+
expect(configIn.logger.warn).toHaveBeenCalledTimes(1);
204+
});
205+
199206
it('handles a valid application version', () => {
200207
const configIn = emptyConfigWithMockLogger();
201208
configIn.application = {version: 'test-version'};

test/event_processor-test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const { DiagnosticsManager, DiagnosticId } = require('../diagnostic_events');
22
const EventProcessor = require('../event_processor');
3-
const { TestHttpHandlers, TestHttpServer, withCloseable } = require('launchdarkly-js-test-helpers');
4-
const { failIfTimeout } = require('./test_helpers');
3+
const { failOnTimeout, TestHttpHandlers, TestHttpServer, withCloseable } = require('launchdarkly-js-test-helpers');
54

65
describe('EventProcessor', () => {
76

@@ -657,8 +656,8 @@ describe('EventProcessor', () => {
657656
ep.sendEvent({ kind: 'identify', creationDate: 1000, user: user });
658657

659658
// unfortunately we must wait for both the flush interval and the 1-second retry interval
660-
await failIfTimeout(s.nextRequest(), 500);
661-
await failIfTimeout(s.nextRequest(), 1500);
659+
await failOnTimeout(s.nextRequest(), 500, 'timed out waiting for event payload');
660+
await failOnTimeout(s.nextRequest(), 1500, 'timed out waiting for event payload');
662661
});
663662
}));
664663

test/polling-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
const InMemoryFeatureStore = require('../feature_store');
22
const PollingProcessor = require('../polling');
33
const dataKind = require('../versioned_data_kind');
4-
const { AsyncQueue, promisify, promisifySingle } = require('launchdarkly-js-test-helpers');
4+
const { AsyncQueue, failOnResolve, failOnTimeout, promisify, promisifySingle } = require('launchdarkly-js-test-helpers');
55
const stubs = require('./stubs');
6-
const { failIfTimeout } = require('./test_helpers');
76

87
describe('PollingProcessor', () => {
98
const longInterval = 100000;
@@ -81,7 +80,7 @@ describe('PollingProcessor', () => {
8180
processor.start(() => {});
8281
const startTime = new Date().getTime();
8382
for (let i = 0; i < 4; i++) {
84-
await failIfTimeout(calls.take(), 500);
83+
await failOnTimeout(calls.take(), 500, 'timed out waiting for poll request #' + (i + 1));
8584
}
8685
expect(new Date().getTime() - startTime).toBeLessThanOrEqual(500);
8786
});
@@ -107,9 +106,9 @@ describe('PollingProcessor', () => {
107106
let errReceived;
108107
processor.start(e => { errReceived = e; });
109108

110-
await failIfTimeout(calls.take(), 500);
111-
await failIfTimeout(calls.take(), 500);
112-
await failIfTimeout(calls.take(), 500);
109+
for (let i = 0; i < 3; i++) {
110+
await failOnTimeout(calls.take(), 500, 'timed out waiting for poll request #' + (i + 1));
111+
}
113112

114113
expect(config.logger.error).not.toHaveBeenCalled();
115114
expect(errReceived).toBeUndefined();
@@ -143,10 +142,11 @@ describe('PollingProcessor', () => {
143142
const result = new AsyncQueue();
144143
processor.start(e => result.add(e));
145144

146-
const errReceived = await failIfTimeout(result.take(), 1000);
145+
const errReceived = await failOnTimeout(result.take(), 1000, 'timed out waiting for initialization to complete');
147146
expect(errReceived.message).toMatch(new RegExp('error ' + status + '.*giving up permanently'));
148147

149-
expect(calls.length()).toEqual(1);
148+
await failOnTimeout(calls.take(), 10, 'expected initial poll request but did not see one');
149+
await failOnResolve(calls.take(), 100, 'received unexpected second poll request');
150150
expect(config.logger.error).toHaveBeenCalledTimes(1);
151151
}
152152

test/streaming-test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ const { DiagnosticId, DiagnosticsManager } = require('../diagnostic_events');
22
const InMemoryFeatureStore = require('../feature_store');
33
const StreamProcessor = require('../streaming');
44
import * as httpUtils from '../utils/httpUtils';
5-
import { failIfResolves, failIfTimeout } from './test_helpers';
65
const dataKind = require('../versioned_data_kind');
76

8-
const { promisifySingle } = require('launchdarkly-js-test-helpers');
7+
const { failOnResolve, failOnTimeout, promisifySingle } = require('launchdarkly-js-test-helpers');
98
const stubs = require('./stubs');
109

1110
describe('StreamProcessor', () => {
@@ -258,10 +257,10 @@ describe('StreamProcessor', () => {
258257

259258
es.instance.simulateError(err);
260259

261-
await failIfTimeout(logCapture.warn.take(), 1000);
260+
await failOnTimeout(logCapture.warn.take(), 1000, 'timed out waiting for log message');
262261

263-
await failIfResolves(waitForStart, 50);
264-
await failIfResolves(logCapture.error.take(), 50);
262+
await failOnResolve(waitForStart, 50, 'initialization completed unexpectedly');
263+
await failOnResolve(logCapture.error.take(), 50, 'got unexpected log error');
265264

266265
expect(es.closed).not.toBeTruthy();
267266

@@ -297,11 +296,11 @@ describe('StreamProcessor', () => {
297296

298297
const waitForStart = promisifySingle(sp.start)();
299298
es.instance.simulateError(err);
300-
const errReceived = await failIfTimeout(waitForStart, 1000);
299+
const errReceived = await failOnTimeout(waitForStart, 1000, 'timed out waiting for error result');
301300

302301
expect(errReceived).toEqual(err);
303302

304-
await failIfTimeout(logCapture.error.take(), 50);
303+
await failOnTimeout(logCapture.error.take(), 50, 'timed out waiting for log error');
305304

306305
expect(es.closed).toBe(true);
307306

0 commit comments

Comments
 (0)