Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/client/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ func (c *MockProjectConfig) GetRegion() string {
return "US"
}

func (c *MockProjectConfig) GetHoldoutList() []entities.Holdout {
return []entities.Holdout{}
}

func (c *MockProjectConfig) GetHoldoutsForFlag(featureKey string) []entities.Holdout {
return []entities.Holdout{}
}

type MockProjectConfigManager struct {
projectConfig config.ProjectConfig
mock.Mock
Expand Down
5 changes: 5 additions & 0 deletions pkg/cmab/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ func (m *MockProjectConfig) GetHoldoutsForFlag(featureKey string) []entities.Hol
return args.Get(0).([]entities.Holdout)
}

func (m *MockProjectConfig) GetHoldoutList() []entities.Holdout {
args := m.Called()
return args.Get(0).([]entities.Holdout)
}

type CmabServiceTestSuite struct {
suite.Suite
mockClient *MockCmabClient
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/datafileprojectconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ func (c DatafileProjectConfig) GetHoldoutsForFlag(featureKey string) []entities.
return []entities.Holdout{}
}

// GetHoldoutList returns all holdouts in the project
func (c DatafileProjectConfig) GetHoldoutList() []entities.Holdout {
return c.holdouts
}

// NewDatafileProjectConfig initializes a new datafile from a json byte array using the default JSON datafile parser
func NewDatafileProjectConfig(jsonDatafile []byte, logger logging.OptimizelyLogProducer) (*DatafileProjectConfig, error) {
datafile, err := Parse(jsonDatafile)
Expand Down
1 change: 1 addition & 0 deletions pkg/config/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type ProjectConfig interface {
GetFlagVariationsMap() map[string][]entities.Variation
GetRegion() string
GetHoldoutsForFlag(featureKey string) []entities.Holdout
GetHoldoutList() []entities.Holdout
}

// ProjectConfigManager maintains an instance of the ProjectConfig
Expand Down
241 changes: 241 additions & 0 deletions pkg/config/testdata/holdouts_datafile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
{
"accountId": "12133785640",
"projectId": "6460519658291200",
"revision": "12",
"attributes": [
{
"id": "5502380200951808",
"key": "all"
},
{
"id": "5750214343000064",
"key": "ho"
}
],
"audiences": [
{
"name": "ho_3_aud",
"conditions": "[\"or\", {\"match\": \"exact\", \"name\": \"$opt_dummy_attribute\", \"type\": \"custom_attribute\", \"value\": \"$opt_dummy_value\"}]",
"id": "5435551013142528"
},
{
"name": "ho_6_aud",
"conditions": "[\"or\", {\"match\": \"exact\", \"name\": \"$opt_dummy_attribute\", \"type\": \"custom_attribute\", \"value\": \"$opt_dummy_value\"}]",
"id": "5841838209236992"
},
{
"name": "ho_4_aud",
"conditions": "[\"or\", {\"match\": \"exact\", \"name\": \"$opt_dummy_attribute\", \"type\": \"custom_attribute\", \"value\": \"$opt_dummy_value\"}]",
"id": "6043616745881600"
},
{
"name": "ho_5_aud",
"conditions": "[\"or\", {\"match\": \"exact\", \"name\": \"$opt_dummy_attribute\", \"type\": \"custom_attribute\", \"value\": \"$opt_dummy_value\"}]",
"id": "6410995866796032"
},
{
"id": "$opt_dummy_audience",
"name": "Optimizely-Generated Audience for Backwards Compatibility",
"conditions": "[\"or\", {\"match\": \"exact\", \"name\": \"$opt_dummy_attribute\", \"type\": \"custom_attribute\", \"value\": \"$opt_dummy_value\"}]"
}
],
"version": "4",
"events": [
{
"id": "6554438379241472",
"experimentIds": [],
"key": "event1"
}
],
"integrations": [],
"holdouts": [
{
"id": "1673115",
"key": "holdout_6",
"status": "Running",
"variations": [
{
"id": "$opt_dummy_variation_id",
"key": "off",
"featureEnabled": false,
"variables": []
}
],
"trafficAllocation": [
{
"entityId": "$opt_dummy_variation_id",
"endOfRange": 4000
}
],
"audienceIds": ["5841838209236992"],
"audienceConditions": ["or", "5841838209236992"]
},
{
"id": "1673114",
"key": "holdout_5",
"status": "Running",
"variations": [
{
"id": "$opt_dummy_variation_id",
"key": "off",
"featureEnabled": false,
"variables": []
}
],
"trafficAllocation": [
{
"entityId": "$opt_dummy_variation_id",
"endOfRange": 2000
}
],
"audienceIds": ["6410995866796032"],
"audienceConditions": ["or", "6410995866796032"]
},
{
"id": "1673113",
"key": "holdouts_4",
"status": "Running",
"variations": [
{
"id": "$opt_dummy_variation_id",
"key": "off",
"featureEnabled": false,
"variables": []
}
],
"trafficAllocation": [
{
"entityId": "$opt_dummy_variation_id",
"endOfRange": 5000
}
],
"audienceIds": ["6043616745881600"],
"audienceConditions": ["or", "6043616745881600"]
},
{
"id": "1673112",
"key": "holdout_3",
"status": "Running",
"variations": [
{
"id": "$opt_dummy_variation_id",
"key": "off",
"featureEnabled": false,
"variables": []
}
],
"trafficAllocation": [
{
"entityId": "$opt_dummy_variation_id",
"endOfRange": 1000
}
],
"audienceIds": ["5435551013142528"],
"audienceConditions": ["or", "5435551013142528"]
}
],
"anonymizeIP": true,
"botFiltering": false,
"typedAudiences": [
{
"name": "ho_3_aud",
"conditions": ["and", ["or", ["or", {"match": "exact", "name": "ho", "type": "custom_attribute", "value": 3}]], ["or", {"match": "le", "name": "all", "type": "custom_attribute", "value": 3}]],
"id": "5435551013142528"
},
{
"name": "ho_6_aud",
"conditions": ["and", ["or", ["or", {"match": "exact", "name": "ho", "type": "custom_attribute", "value": 6}]], ["or", {"match": "le", "name": "all", "type": "custom_attribute", "value": 6}]],
"id": "5841838209236992"
},
{
"name": "ho_4_aud",
"conditions": ["and", ["or", ["or", {"match": "exact", "name": "ho", "type": "custom_attribute", "value": 4}]], ["or", {"match": "le", "name": "all", "type": "custom_attribute", "value": 4}]],
"id": "6043616745881600"
},
{
"name": "ho_5_aud",
"conditions": ["and", ["or", ["or", {"match": "exact", "name": "ho", "type": "custom_attribute", "value": 5}]], ["or", {"match": "le", "name": "all", "type": "custom_attribute", "value": 5}]],
"id": "6410995866796032"
}
],
"variables": [],
"environmentKey": "production",
"sdkKey": "BLsSFScP7tSY5SCYuKn8c",
"featureFlags": [
{
"id": "497759",
"key": "flag1",
"rolloutId": "rollout-497759-631765411405174",
"experimentIds": [],
"variables": []
},
{
"id": "497760",
"key": "flag2",
"rolloutId": "rollout-497760-631765411405174",
"experimentIds": [],
"variables": []
}
],
"rollouts": [
{
"id": "rollout-497759-631765411405174",
"experiments": [
{
"id": "default-rollout-497759-631765411405174",
"key": "default-rollout-497759-631765411405174",
"status": "Running",
"layerId": "rollout-497759-631765411405174",
"variations": [
{
"id": "1583341",
"key": "variation_1",
"featureEnabled": true,
"variables": []
}
],
"trafficAllocation": [
{
"entityId": "1583341",
"endOfRange": 10000
}
],
"forcedVariations": {},
"audienceIds": [],
"audienceConditions": []
}
]
},
{
"id": "rollout-497760-631765411405174",
"experiments": [
{
"id": "default-rollout-497760-631765411405174",
"key": "default-rollout-497760-631765411405174",
"status": "Running",
"layerId": "rollout-497760-631765411405174",
"variations": [
{
"id": "1583340",
"key": "variation_2",
"featureEnabled": true,
"variables": []
}
],
"trafficAllocation": [
{
"entityId": "1583340",
"endOfRange": 10000
}
],
"forcedVariations": {},
"audienceIds": [],
"audienceConditions": []
}
]
}
],
"experiments": [],
"groups": [],
"region": "US"
}
5 changes: 5 additions & 0 deletions pkg/decision/evaluator/audience_evaluator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ func (m *MockProjectConfig) GetHoldoutsForFlag(featureKey string) []entities.Hol
return args.Get(0).([]entities.Holdout)
}

func (m *MockProjectConfig) GetHoldoutList() []entities.Holdout {
args := m.Called()
return args.Get(0).([]entities.Holdout)
}

// MockLogger is a mock implementation of OptimizelyLogProducer
// (This declaration has been removed to resolve the redeclaration error)

Expand Down