Skip to content

Commit 6d86211

Browse files
authored
fix: add openfeature integration test to CI and fix tests (#6906)
* fix: add openfeature ingegration test to CI and fix it * unit tests in CI * fix: tests
1 parent f6c929e commit 6d86211

File tree

5 files changed

+95
-8
lines changed

5 files changed

+95
-8
lines changed

.github/workflows/openfeature.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: OpenFeature
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
schedule:
8+
- cron: 0 4 * * *
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
12+
cancel-in-progress: true
13+
14+
env:
15+
MOCHA_OPTIONS: ${{ github.ref == 'refs/heads/master' && '--retries 1' || '' }}
16+
17+
jobs:
18+
unit:
19+
strategy:
20+
matrix:
21+
version: [oldest, maintenance, active, latest]
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
25+
- uses: ./.github/actions/testagent/start
26+
- uses: ./.github/actions/node
27+
with:
28+
version: ${{ matrix.version }}
29+
- uses: ./.github/actions/install
30+
- run: yarn test:openfeature:ci
31+
- if: always()
32+
uses: ./.github/actions/testagent/logs
33+
with:
34+
suffix: openfeature-${{ github.job }}-${{ matrix.version }}
35+
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
36+
- uses: DataDog/junit-upload-github-action@762867566348d59ac9bcf479ebb4ec040db8940a # v2.0.0
37+
if: always()
38+
with:
39+
api_key: ${{ secrets.DD_API_KEY }}
40+
service: dd-trace-js-tests
41+
42+
macos:
43+
runs-on: macos-latest
44+
steps:
45+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
46+
- uses: ./.github/actions/node/latest
47+
- uses: ./.github/actions/install
48+
- run: yarn test:integration:openfeature
49+
- uses: DataDog/junit-upload-github-action@762867566348d59ac9bcf479ebb4ec040db8940a # v2.0.0
50+
if: always()
51+
with:
52+
api_key: ${{ secrets.DD_API_KEY }}
53+
service: dd-trace-js-tests
54+
55+
ubuntu:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
59+
- uses: ./.github/actions/node/oldest-maintenance-lts
60+
- uses: ./.github/actions/install
61+
- run: yarn test:integration:openfeature
62+
- uses: ./.github/actions/node/newest-maintenance-lts
63+
- run: yarn test:integration:openfeature
64+
- uses: ./.github/actions/node/active-lts
65+
- run: yarn test:integration:openfeature
66+
- uses: ./.github/actions/node/latest
67+
- run: yarn test:integration:openfeature
68+
- uses: DataDog/junit-upload-github-action@762867566348d59ac9bcf479ebb4ec040db8940a # v2.0.0
69+
if: always()
70+
with:
71+
api_key: ${{ secrets.DD_API_KEY }}
72+
service: dd-trace-js-tests
73+
74+
windows:
75+
runs-on: windows-latest
76+
steps:
77+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
78+
- uses: ./.github/actions/node/latest
79+
- uses: ./.github/actions/install
80+
with:
81+
cache: 'true'
82+
- run: yarn test:integration:openfeature
83+
- uses: DataDog/junit-upload-github-action@762867566348d59ac9bcf479ebb4ec040db8940a # v2.0.0
84+
if: always()
85+
with:
86+
api_key: ${{ secrets.DD_API_KEY }}
87+
service: dd-trace-js-tests

integration-tests/openfeature/openfeature-exposure-events.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('OpenFeature Remote Config and Exposure Events Integration', () => {
112112
agent.addRemoteConfig({
113113
product: RC_PRODUCT,
114114
id: configId,
115-
config: { flag_configuration: ufcPayloads.testBooleanAndStringFlags }
115+
config: ufcPayloads.testBooleanAndStringFlags
116116
})
117117

118118
// Wait for RC delivery then evaluate flags
@@ -192,7 +192,7 @@ describe('OpenFeature Remote Config and Exposure Events Integration', () => {
192192
agent.addRemoteConfig({
193193
product: RC_PRODUCT,
194194
id: configId,
195-
config: { flag_configuration: ufcPayloads.testBooleanAndStringFlags }
195+
config: ufcPayloads.testBooleanAndStringFlags
196196
})
197197

198198
setTimeout(async () => {
@@ -257,7 +257,7 @@ describe('OpenFeature Remote Config and Exposure Events Integration', () => {
257257
agent.addRemoteConfig({
258258
product: RC_PRODUCT,
259259
id: configId,
260-
config: { flag_configuration: ufcPayloads.simpleStringFlagForAck }
260+
config: ufcPayloads.simpleStringFlagForAck
261261
})
262262

263263
// Trigger request to start remote config polling

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"test:llmobs:sdk:ci": "nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:sdk",
4747
"test:llmobs:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/llmobs/plugins/@($(echo $PLUGINS))/*.spec.js\"",
4848
"test:llmobs:plugins:ci": "yarn services && nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:plugins",
49+
"test:openfeature": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/openfeature/*.spec.js\"",
50+
"test:openfeature:ci": "nyc --no-clean --include \"packages/dd-trace/src/openfeature/**/*.js\" -- npm run test:openfeature",
4951
"test:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/@($(echo ${SPEC:-'*'})).spec.js\"",
5052
"test:plugins:ci": "yarn services && nyc --no-clean --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins",
5153
"test:plugins:ci:flaky": "yarn services && nyc --no-clean --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins -- --bail --retries 2",

packages/dd-trace/test/openfeature/flagging_provider.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('FlaggingProvider', () => {
6565
const provider = new FlaggingProvider(mockTracer, mockConfig)
6666

6767
expect(provider).to.exist
68-
expect(log.debug).to.have.been.calledWith('[FlaggingProvider] Created')
68+
expect(log.debug).to.have.been.calledWith('FlaggingProvider created')
6969
})
7070
})
7171

@@ -78,7 +78,7 @@ describe('FlaggingProvider', () => {
7878
provider._setConfiguration(ufc)
7979

8080
expect(setConfigSpy).to.have.been.calledOnceWith(ufc)
81-
expect(log.debug).to.have.been.calledWith('[FlaggingProvider] Provider configuration updated')
81+
expect(log.debug).to.have.been.calledWith('FlaggingProvider provider configuration updated')
8282
})
8383

8484
it('should handle null/undefined configuration gracefully', () => {

packages/dd-trace/test/openfeature/index.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ describe('OpenFeature Module', () => {
115115

116116
exposureSubmitCh.publish(exposureEvents)
117117

118-
expect(mockWriter.append).to.have.been.calledTwice
119-
expect(mockWriter.append.firstCall).to.have.been.calledWith(exposureEvents[0])
120-
expect(mockWriter.append.secondCall).to.have.been.calledWith(exposureEvents[1])
118+
expect(mockWriter.append).to.have.been.calledOnceWith(exposureEvents)
121119
})
122120

123121
it('flushes the exposures writer', () => {

0 commit comments

Comments
 (0)