Skip to content

Commit ed98c54

Browse files
authored
feat(Config-v2): Support for optlyconfig-v2 added. (#322)
## Summary - Support for OptimizelyConfig v2 added. ## Issues - All Config-v2 tests should pass.
1 parent 9325d7d commit ed98c54

File tree

6 files changed

+484
-141
lines changed

6 files changed

+484
-141
lines changed

api/openapi-spec/openapi.yaml

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,33 +300,67 @@ components:
300300
type: string
301301
error_description:
302302
type: string
303-
Experiment:
303+
OptimizelyExperiment:
304304
properties:
305305
id:
306306
type: string
307307
key:
308308
type: string
309+
audiences:
310+
type: string
309311
variationsMap:
310312
type: object
311313
additionalProperties:
312-
$ref: '#/components/schemas/Variation'
314+
$ref: '#/components/schemas/OptimizelyVariation'
313315
required:
314316
- id
315317
- key
316-
Feature:
318+
OptimizelyAttribute:
319+
properties:
320+
id:
321+
type: string
322+
key:
323+
type: string
324+
OptimizelyAudience:
325+
properties:
326+
id:
327+
type: string
328+
name:
329+
type: string
330+
conditions:
331+
type: string
332+
OptimizelyEvent:
333+
properties:
334+
id:
335+
type: string
336+
key:
337+
type: string
338+
experimentIds:
339+
type: array
340+
items:
341+
type: string
342+
OptimizelyFeature:
317343
properties:
318344
id:
319345
type: string
320346
key:
321347
type: string
348+
experimentRules:
349+
type: array
350+
items:
351+
$ref: '#/components/schemas/OptimizelyExperiment'
352+
deliveryRules:
353+
type: array
354+
items:
355+
$ref: '#/components/schemas/OptimizelyExperiment'
322356
variablesMap:
323357
type: object
324358
additionalProperties:
325-
type: object
359+
$ref: '#/components/schemas/OptimizelyVariable'
326360
experimentsMap:
327361
type: object
328362
additionalProperties:
329-
$ref: '#/components/schemas/Experiment'
363+
$ref: '#/components/schemas/OptimizelyExperiment'
330364
required:
331365
- id
332366
- key
@@ -413,16 +447,32 @@ components:
413447
type: string
414448
OptimizelyConfig:
415449
properties:
450+
environmentKey:
451+
type: string
452+
sdkKey:
453+
type: string
416454
revision:
417455
type: string
418456
experimentsMap:
419457
type: object
420458
additionalProperties:
421-
$ref: '#/components/schemas/Experiment'
459+
$ref: '#/components/schemas/OptimizelyExperiment'
422460
featuresMap:
423461
type: object
424462
additionalProperties:
425-
$ref: '#/components/schemas/Feature'
463+
$ref: '#/components/schemas/OptimizelyFeature'
464+
attributes:
465+
type: array
466+
items:
467+
$ref: '#/components/schemas/OptimizelyAttribute'
468+
audiences:
469+
type: array
470+
items:
471+
$ref: '#/components/schemas/OptimizelyAudience'
472+
events:
473+
type: array
474+
items:
475+
$ref: '#/components/schemas/OptimizelyEvent'
426476
TrackContext:
427477
properties:
428478
eventTags:
@@ -452,16 +502,22 @@ components:
452502
additionalProperties: true
453503
required:
454504
- userId
455-
Variation:
505+
OptimizelyVariation:
456506
properties:
457507
id:
458508
type: string
459509
key:
460510
type: string
511+
featureEnabled:
512+
type: boolean
513+
variablesMap:
514+
type: object
515+
additionalProperties:
516+
$ref: '#/components/schemas/OptimizelyVariable'
461517
required:
462518
- id
463519
- key
464-
Variable:
520+
OptimizelyVariable:
465521
properties:
466522
id:
467523
type: string
@@ -470,7 +526,7 @@ components:
470526
type:
471527
type: string
472528
value:
473-
type: object
529+
type: string
474530
required:
475531
- id
476532
- key

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/go-kit/kit v0.9.0
1313
github.com/google/uuid v1.1.1
1414
github.com/lestrrat-go/jwx v0.9.0
15-
github.com/optimizely/go-sdk v1.6.2-0.20210507191537-aba050a09690
15+
github.com/optimizely/go-sdk v1.7.0
1616
github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6
1717
github.com/rakyll/statik v0.1.7
1818
github.com/rs/zerolog v1.18.1-0.20200514152719-663cbb4c8469

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLD
8686
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
8787
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
8888
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
89-
github.com/optimizely/go-sdk v1.6.2-0.20210507191537-aba050a09690 h1:lPr7wfM+gdPEKJiOpKdjnEOrxvou1WJdMXxqCrUObis=
90-
github.com/optimizely/go-sdk v1.6.2-0.20210507191537-aba050a09690/go.mod h1:1uinGREH+AdijSRw3qitWkvIna1e/ZGN5eymNYPjw1A=
89+
github.com/optimizely/go-sdk v1.7.0 h1:IMSUSH3NdTJjkiTO6f9s+pePaqc8pN+UuX1XqP5aiwY=
90+
github.com/optimizely/go-sdk v1.7.0/go.mod h1:1uinGREH+AdijSRw3qitWkvIna1e/ZGN5eymNYPjw1A=
9191
github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6 h1:lNCW6THrCKBiJBpz8kbVGjC7MgdCGKwuvBgc7LoD6sw=
9292
github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
9393
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=

pkg/optimizely/optimizelytest/config.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ type TestProjectConfig struct {
4545
AnonymizeIP bool
4646
BotFiltering bool
4747
sendFlagDecisions bool
48+
sdkKey string
49+
environmentKey string
4850
}
4951

5052
// GetDatafile returns a string representation of the environment's datafile
@@ -72,6 +74,14 @@ func (c *TestProjectConfig) GetAnonymizeIP() bool {
7274
return c.AnonymizeIP
7375
}
7476

77+
// GetAttributes returns attributes
78+
func (c *TestProjectConfig) GetAttributes() (attributeList []entities.Attribute) {
79+
for _, attribute := range c.AttributeMap {
80+
attributeList = append(attributeList, attribute)
81+
}
82+
return attributeList
83+
}
84+
7585
// GetAttributeID returns attributeID
7686
func (c *TestProjectConfig) GetAttributeID(key string) string {
7787
return c.AttributeKeyToIDMap[key]
@@ -82,6 +92,24 @@ func (c *TestProjectConfig) GetBotFiltering() bool {
8292
return c.BotFiltering
8393
}
8494

95+
// GetSdkKey returns sdkKey for specific environment.
96+
func (c *TestProjectConfig) GetSdkKey() string {
97+
return c.sdkKey
98+
}
99+
100+
// GetEnvironmentKey returns current environment of the datafile.
101+
func (c *TestProjectConfig) GetEnvironmentKey() string {
102+
return c.environmentKey
103+
}
104+
105+
// GetEvents returns all events
106+
func (c *TestProjectConfig) GetEvents() (eventList []entities.Event) {
107+
for _, event := range c.EventMap {
108+
eventList = append(eventList, event)
109+
}
110+
return eventList
111+
}
112+
85113
// GetEventByKey returns the event with the given key
86114
func (c *TestProjectConfig) GetEventByKey(eventKey string) (entities.Event, error) {
87115
if event, ok := c.EventMap[eventKey]; ok {
@@ -141,6 +169,22 @@ func (c *TestProjectConfig) GetExperimentList() (experimentList []entities.Exper
141169
return experimentList
142170
}
143171

172+
// GetRolloutList returns an array of all the rollouts
173+
func (c *TestProjectConfig) GetRolloutList() (rolloutList []entities.Rollout) {
174+
for _, rollout := range c.RolloutMap {
175+
rolloutList = append(rolloutList, rollout)
176+
}
177+
return rolloutList
178+
}
179+
180+
// GetAudienceList returns an array of all the audiences
181+
func (c *TestProjectConfig) GetAudienceList() (audienceList []entities.Audience) {
182+
for _, audience := range c.AudienceMap {
183+
audienceList = append(audienceList, audience)
184+
}
185+
return audienceList
186+
}
187+
144188
// GetAudienceByID returns the audience with the given ID
145189
func (c *TestProjectConfig) GetAudienceByID(audienceID string) (entities.Audience, error) {
146190
if audience, ok := c.AudienceMap[audienceID]; ok {

tests/acceptance/test_acceptance/test_batch.py

Lines changed: 72 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,78 @@ def test_batch_valid_reponse(session_obj):
4747

4848

4949
expected_body_of_operationid_2 = """{
50-
"experimentsMap": {
51-
"ab_exper": {
52-
"id": "17273802375",
53-
"key": "ab_exper",
54-
"variationsMap": {
55-
"my_single_variation": {
56-
"featureEnabled": false,
57-
"id": "17266384371",
58-
"key": "my_single_variation",
59-
"variablesMap": {}
60-
}
61-
}
62-
}
63-
},
64-
"featuresMap": {
65-
"feature1": {
66-
"experimentsMap": {},
67-
"id": "15444990338",
68-
"key": "feature1",
69-
"variablesMap": {
70-
"fff": {
71-
"id": "15427520260",
72-
"key": "fff",
73-
"type": "string",
74-
"value": "ss"
75-
}
76-
}
77-
}
78-
},
79-
"revision": "18"
50+
"attributes": [{
51+
"id": "12459620467",
52+
"key": "bob_ross"
53+
}],
54+
"audiences": [
55+
],
56+
"environmentKey": "",
57+
"events": [{
58+
"experimentIds": [
59+
],
60+
"id": "15410720745",
61+
"key": "clickyclick"
62+
}
63+
],
64+
"experimentsMap": {
65+
"ab_exper": {
66+
"audiences": "",
67+
"id": "17273802375",
68+
"key": "ab_exper",
69+
"variationsMap": {
70+
"my_single_variation": {
71+
"featureEnabled": false,
72+
"id": "17266384371",
73+
"key": "my_single_variation",
74+
"variablesMap": {
75+
}
76+
}
77+
}
78+
}
79+
},
80+
"featuresMap": {
81+
"feature1": {
82+
"deliveryRules": [{
83+
"audiences": "",
84+
"id": "15439080355",
85+
"key": "15439080355",
86+
"variationsMap": {
87+
"15404730339": {
88+
"featureEnabled": true,
89+
"id": "15404730339",
90+
"key": "15404730339",
91+
"variablesMap": {
92+
"fff": {
93+
"id": "15427520260",
94+
"key": "fff",
95+
"type": "string",
96+
"value": "ss"
97+
98+
}
99+
}
100+
}
101+
}
102+
}
103+
],
104+
"experimentRules": [
105+
],
106+
"experimentsMap": {
107+
},
108+
"id": "15444990338",
109+
"key": "feature1",
110+
"variablesMap": {
111+
"fff": {
112+
"id": "15427520260",
113+
"key": "fff",
114+
"type": "string",
115+
"value": "ss"
116+
}
117+
}
118+
}
119+
},
120+
"revision": "18",
121+
"sdkKey": ""
80122
}"""
81123

82124

0 commit comments

Comments
 (0)