Skip to content

Commit d314df9

Browse files
feat!: graceful fallback to code default (#1461)
Signed-off-by: marcozabel <marco.zabel@dynatrace.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
1 parent 8fb81af commit d314df9

18 files changed

Lines changed: 58 additions & 32 deletions

File tree

.gitmodules

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
[submodule "libs/shared/flagd-core/test-harness"]
1414
path = libs/shared/flagd-core/test-harness
1515
url = https://github.com/open-feature/flagd-testbed
16-
branch = v2.10.2
1716
[submodule "libs/shared/flagd-core/spec"]
1817
path = libs/shared/flagd-core/spec
1918
url = https://github.com/open-feature/spec

libs/providers/flagd-web/src/e2e/step-definitions/flag.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then })
3535
});
3636

3737
when(
38-
/^a string flag with key "(.*)" is evaluated with default value "(.*)"$/,
38+
/^a string flag with key "(.*)" is evaluated with (default|fallback) value "(.*)"$/,
3939
(key: string, defaultValue: string) => {
4040
flagKey = key;
4141
fallback = defaultValue;
@@ -224,7 +224,7 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then })
224224
});
225225

226226
when(
227-
/^a non-existent string flag with key "(.*)" is evaluated with details and a default value "(.*)"$/,
227+
/^a non-existent string flag with key "(.*)" is evaluated with details and a (default|fallback) value "(.*)"$/,
228228
(key: string, defaultValue: string) => {
229229
flagKey = key;
230230
fallback = defaultValue;
@@ -247,7 +247,7 @@ export const flagStepDefinitions: StepDefinitions = ({ given, and, when, then })
247247
);
248248

249249
when(
250-
/^a string flag with key "(.*)" is evaluated as an integer, with details and a default value (\d+)$/,
250+
/^a string flag with key "(.*)" is evaluated as an integer, with details and a (default|fallback) value (\d+)$/,
251251
(key: string, defaultValue: string) => {
252252
flagKey = key;
253253
fallback = Number.parseInt(defaultValue);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import type { StepsDefinitionCallbackOptions } from 'jest-cucumber/dist/src/feature-definition-creation';
2+
import type { State, Steps } from './state';
3+
import { ClientProviderStatus } from '@openfeature/core';
4+
5+
export const clientSteps: Steps = (state: State) => {
6+
return ({ and }: StepsDefinitionCallbackOptions) => {
7+
and('the client is in fatal state', () => {
8+
expect(state.client?.providerStatus).toBe(ClientProviderStatus.ERROR);
9+
});
10+
};
11+
};

libs/providers/flagd/src/e2e/step-definitions/providerSteps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const providerSteps: Steps =
5151
break;
5252
case 'forbidden':
5353
flagdOptions['port'] = container.getForbiddenPort();
54+
flagdOptions['fatalStatusCodes'] = [...(flagdOptions.fatalStatusCodes || []), 'FORBIDDEN'];
5455
break;
5556
case 'ssl': {
5657
flagdOptions['port'] = container.getPort(state.resolverType);

libs/providers/flagd/src/e2e/tests/in-process.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import type { State } from '../step-definitions/state';
66
import { eventSteps } from '../step-definitions/eventSteps';
77
import { flagSteps } from '../step-definitions/flagSteps';
88
import { contextSteps } from '../step-definitions/contextSteps';
9+
import { clientSteps } from '../step-definitions/clientSteps';
910

10-
const steps = [providerSteps, configSteps, eventSteps, flagSteps, contextSteps];
11+
const steps = [providerSteps, configSteps, eventSteps, flagSteps, contextSteps, clientSteps];
1112

1213
jest.setTimeout(50000);
1314
jest.retryTimes(3);
@@ -23,7 +24,7 @@ describe('in-process', () => {
2324
loadFeatures(GHERKIN_FLAGD, {
2425
// remove filters as we add support for features
2526
// see: https://github.com/open-feature/js-sdk-contrib/issues/1096 and child issues
26-
tagFilter: '@in-process and not @targetURI and not @sync and not @unixsocket',
27+
tagFilter: '@in-process and not @targetURI and not @sync and not @unixsocket and not @deprecated',
2728
scenarioNameTemplate: (vars) => {
2829
return `${vars.scenarioTitle} (${vars.scenarioTags.join(',')} ${vars.featureTags.join(',')})`;
2930
},

libs/providers/flagd/src/e2e/tests/rpc.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import { eventSteps } from '../step-definitions/eventSteps';
66
import { flagSteps } from '../step-definitions/flagSteps';
77
import { contextSteps } from '../step-definitions/contextSteps';
88
import { GHERKIN_FLAGD } from '../constants';
9+
import { clientSteps } from '../step-definitions/clientSteps';
910

10-
const steps = [providerSteps, configSteps, eventSteps, flagSteps, contextSteps];
11+
const steps = [providerSteps, configSteps, eventSteps, flagSteps, contextSteps, clientSteps];
1112

1213
jest.setTimeout(50000);
1314
jest.retryTimes(3);
@@ -24,7 +25,7 @@ describe('rpc', () => {
2425
tagFilter:
2526
// remove filters as we add support for features
2627
// see: https://github.com/open-feature/js-sdk-contrib/issues/1096 and child issues
27-
'@rpc and not @targetURI and not @caching and not @unixsocket',
28+
'@rpc and not @targetURI and not @caching and not @unixsocket and not @deprecated',
2829
scenarioNameTemplate: (vars) => {
2930
return `${vars.scenarioTitle} (${vars.scenarioTags.join(',')} ${vars.featureTags.join(',')})`;
3031
},

libs/providers/flagd/src/lib/flagd-provider.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import type {
1616
ResolveObjectResponse,
1717
ResolveStringRequest,
1818
ResolveStringResponse,
19-
} from '../proto/ts/flagd/evaluation/v1/evaluation';
20-
import { ServiceClient } from '../proto/ts/flagd/evaluation/v1/evaluation';
19+
} from '../proto/ts/flagd/evaluation/v2/evaluation';
20+
import { ServiceClient } from '../proto/ts/flagd/evaluation/v2/evaluation';
2121
import { FlagdProvider } from './flagd-provider';
2222
import type { FlagChangeMessage } from './service/grpc/grpc-service';
2323
import { GRPCService } from './service/grpc/grpc-service';

0 commit comments

Comments
 (0)