Skip to content

Commit aa33699

Browse files
committed
Added integration tests
1 parent e58a513 commit aa33699

42 files changed

Lines changed: 166 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/splitclient-rb/cache/stores/localhost_split_builder.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def build_split(feature, treatments)
2222
seed: 2_089_907_429,
2323
defaultTreatment: 'control_treatment',
2424
configurations: build_configurations(treatments),
25-
conditions: build_conditions(treatments)
25+
conditions: build_conditions(treatments),
26+
prerequisites: []
2627
}
2728
end
2829

spec/integrations/in_memory_client_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,30 @@
9090
expect(impressions[1][:treatment][:change_number]).to eq(1_506_703_262_916)
9191
end
9292

93+
it 'returns treatments with prereq_flag feature and check impressions' do
94+
stub_request(:get, "https://sdk.split.io/api/splitChanges?s=1.3&since=1506703262916&rbSince=-1").to_return(status: 200, body: 'ok')
95+
client.block_until_ready
96+
expect(client.get_treatment('nico_test', 'prereq_flag')).to eq 'on'
97+
expect(client.get_treatment('bla', 'prereq_flag')).to eq 'off_default'
98+
99+
sleep 0.5
100+
impressions = custom_impression_listener.queue
101+
102+
expect(impressions.size).to eq 2
103+
104+
expect(impressions[0][:matching_key]).to eq('nico_test')
105+
expect(impressions[0][:split_name]).to eq('prereq_flag')
106+
expect(impressions[0][:treatment][:treatment]).to eq('on')
107+
expect(impressions[0][:treatment][:label]).to eq('in segment all')
108+
expect(impressions[0][:treatment][:change_number]).to eq(1494593336752)
109+
110+
expect(impressions[1][:matching_key]).to eq('bla')
111+
expect(impressions[1][:split_name]).to eq('prereq_flag')
112+
expect(impressions[1][:treatment][:treatment]).to eq('off_default')
113+
expect(impressions[1][:treatment][:label]).to eq('prerequisites not met')
114+
expect(impressions[1][:treatment][:change_number]).to eq(1494593336752)
115+
end
116+
93117
it 'returns treatments with Test_Save_1 feature and check impressions' do
94118
stub_request(:get, "https://sdk.split.io/api/splitChanges?s=1.3&since=1506703262916&rbSince=-1").to_return(status: 200, body: 'ok')
95119
client.block_until_ready

spec/test_data/integrations/splits.json

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"impressionsDisabled": false,
55
"trafficTypeName": "account",
66
"name": "FACUNDO_TEST",
7+
"prerequisites": [],
78
"trafficAllocation": 59,
89
"trafficAllocationSeed": -2108186082,
910
"seed": -1947050785,
@@ -124,6 +125,7 @@
124125
"impressionsDisabled": false,
125126
"trafficTypeName": "account",
126127
"name": "testing",
128+
"prerequisites": [],
127129
"trafficAllocation": 100,
128130
"trafficAllocationSeed": 527505678,
129131
"seed": -1716462249,
@@ -238,6 +240,7 @@
238240
"impressionsDisabled": false,
239241
"trafficTypeName": "account",
240242
"name": "testing222",
243+
"prerequisites": [],
241244
"trafficAllocation": 100,
242245
"trafficAllocationSeed": -397360967,
243246
"seed": 1058132210,
@@ -292,6 +295,7 @@
292295
"impressionsDisabled": false,
293296
"trafficTypeName": "account",
294297
"name": "a_new_split_2",
298+
"prerequisites": [],
295299
"trafficAllocation": 99,
296300
"trafficAllocationSeed": -1349440646,
297301
"seed": -1536389703,
@@ -558,6 +562,7 @@
558562
"impressionsDisabled": false,
559563
"trafficTypeName": "account",
560564
"name": "test_string_without_attr",
565+
"prerequisites": [],
561566
"trafficAllocation": 100,
562567
"trafficAllocationSeed": -782597068,
563568
"seed": -1682478887,
@@ -628,6 +633,7 @@
628633
"impressionsDisabled": false,
629634
"trafficTypeName": "user",
630635
"name": "Test",
636+
"prerequisites": [],
631637
"trafficAllocation": 100,
632638
"trafficAllocationSeed": 217539832,
633639
"seed": 52164426,
@@ -754,6 +760,7 @@
754760
"impressionsDisabled": false,
755761
"trafficTypeName": "account",
756762
"name": "Test_Save_1",
763+
"prerequisites": [],
757764
"trafficAllocation": 100,
758765
"trafficAllocationSeed": -257595325,
759766
"seed": -665945237,
@@ -901,6 +908,7 @@
901908
"impressionsDisabled": false,
902909
"trafficTypeName": "account",
903910
"name": "TEST",
911+
"prerequisites": [],
904912
"trafficAllocation": 100,
905913
"trafficAllocationSeed": -673356676,
906914
"seed": -511119211,
@@ -950,6 +958,7 @@
950958
"impressionsDisabled": false,
951959
"trafficTypeName": "user",
952960
"name": "benchmark_jw_1",
961+
"prerequisites": [],
953962
"trafficAllocation": 100,
954963
"trafficAllocationSeed": 987354894,
955964
"seed": 1292874260,
@@ -1037,6 +1046,7 @@
10371046
"impressionsDisabled": false,
10381047
"trafficTypeName": "user",
10391048
"name": "nico_tests",
1049+
"prerequisites": [],
10401050
"trafficAllocation": 100,
10411051
"trafficAllocationSeed": 1409699192,
10421052
"seed": -1997241870,
@@ -1083,6 +1093,7 @@
10831093
"impressionsDisabled": false,
10841094
"trafficTypeName": "account",
10851095
"name": "testo2222",
1096+
"prerequisites": [],
10861097
"trafficAllocation": 100,
10871098
"trafficAllocationSeed": 1164474086,
10881099
"seed": 1270508512,
@@ -1296,6 +1307,7 @@
12961307
"impressionsDisabled": false,
12971308
"trafficTypeName": "user",
12981309
"name": "Tagging",
1310+
"prerequisites": [],
12991311
"trafficAllocation": 100,
13001312
"trafficAllocationSeed": 1910132597,
13011313
"seed": -311493896,
@@ -1345,6 +1357,7 @@
13451357
"impressionsDisabled": false,
13461358
"trafficTypeName": "account",
13471359
"name": "Welcome_Page_UI",
1360+
"prerequisites": [],
13481361
"trafficAllocation": 100,
13491362
"trafficAllocationSeed": 1848523960,
13501363
"seed": 1608586361,
@@ -1397,6 +1410,7 @@
13971410
"impressionsDisabled": false,
13981411
"trafficTypeName": "test",
13991412
"name": "pato_test_3",
1413+
"prerequisites": [],
14001414
"trafficAllocation": 100,
14011415
"trafficAllocationSeed": 458647735,
14021416
"seed": 95677506,
@@ -1446,6 +1460,7 @@
14461460
"impressionsDisabled": false,
14471461
"trafficTypeName": "account",
14481462
"name": "testo23",
1463+
"prerequisites": [],
14491464
"trafficAllocation": 100,
14501465
"trafficAllocationSeed": -689658216,
14511466
"seed": 1711156051,
@@ -1495,6 +1510,7 @@
14951510
"impressionsDisabled": false,
14961511
"trafficTypeName": "account",
14971512
"name": "testo909090",
1513+
"prerequisites": [],
14981514
"trafficAllocation": 100,
14991515
"trafficAllocationSeed": -1196467266,
15001516
"seed": -1998101827,
@@ -1662,6 +1678,7 @@
16621678
"impressionsDisabled": false,
16631679
"trafficTypeName": "account",
16641680
"name": "testo22",
1681+
"prerequisites": [],
16651682
"trafficAllocation": 100,
16661683
"trafficAllocationSeed": 1223277820,
16671684
"seed": -1152948537,
@@ -1711,6 +1728,7 @@
17111728
"impressionsDisabled": false,
17121729
"trafficTypeName": "user",
17131730
"name": "test-net",
1731+
"prerequisites": [],
17141732
"trafficAllocation": 100,
17151733
"trafficAllocationSeed": -2038196969,
17161734
"seed": -862203077,
@@ -1760,6 +1778,7 @@
17601778
"impressionsDisabled": false,
17611779
"trafficTypeName": "account",
17621780
"name": "test_dep_2",
1781+
"prerequisites": [],
17631782
"trafficAllocation": 100,
17641783
"trafficAllocationSeed": -806171485,
17651784
"seed": 922684950,
@@ -1853,6 +1872,7 @@
18531872
"impressionsDisabled": false,
18541873
"trafficTypeName": "account",
18551874
"name": "Definition_As_Of_Clickable_UI",
1875+
"prerequisites": [],
18561876
"trafficAllocation": 100,
18571877
"trafficAllocationSeed": -198035199,
18581878
"seed": -151947071,
@@ -1934,6 +1954,7 @@
19341954
"impressionsDisabled": false,
19351955
"trafficTypeName": "account",
19361956
"name": "Identify_UI",
1957+
"prerequisites": [],
19371958
"trafficAllocation": 100,
19381959
"trafficAllocationSeed": -139516103,
19391960
"seed": 1543172523,
@@ -1983,6 +2004,7 @@
19832004
"impressionsDisabled": false,
19842005
"trafficTypeName": "account",
19852006
"name": "test_definition_as_of",
2007+
"prerequisites": [],
19862008
"trafficAllocation": 100,
19872009
"trafficAllocationSeed": 1025823325,
19882010
"seed": -554248124,
@@ -2032,6 +2054,7 @@
20322054
"impressionsDisabled": false,
20332055
"trafficTypeName": "user",
20342056
"name": "Test-jw-go",
2057+
"prerequisites": [],
20352058
"trafficAllocation": 100,
20362059
"trafficAllocationSeed": 768122971,
20372060
"seed": 1539205707,
@@ -2111,6 +2134,7 @@
21112134
"impressionsDisabled": false,
21122135
"trafficTypeName": "user",
21132136
"name": "benchmark_jw_7",
2137+
"prerequisites": [],
21142138
"trafficAllocation": 100,
21152139
"trafficAllocationSeed": -1340337178,
21162140
"seed": -1091938685,
@@ -2160,6 +2184,7 @@
21602184
"impressionsDisabled": false,
21612185
"trafficTypeName": "user",
21622186
"name": "benchmark_jw_6",
2187+
"prerequisites": [],
21632188
"trafficAllocation": 100,
21642189
"trafficAllocationSeed": -1202331834,
21652190
"seed": -48445256,
@@ -2209,6 +2234,7 @@
22092234
"impressionsDisabled": false,
22102235
"trafficTypeName": "user",
22112236
"name": "benchmark_jw_5",
2237+
"prerequisites": [],
22122238
"trafficAllocation": 100,
22132239
"trafficAllocationSeed": 2119994290,
22142240
"seed": -227092192,
@@ -2258,6 +2284,7 @@
22582284
"impressionsDisabled": false,
22592285
"trafficTypeName": "user",
22602286
"name": "benchmark_jw_4",
2287+
"prerequisites": [],
22612288
"trafficAllocation": 100,
22622289
"trafficAllocationSeed": 1066635158,
22632290
"seed": -850704283,
@@ -2307,6 +2334,7 @@
23072334
"impressionsDisabled": false,
23082335
"trafficTypeName": "user",
23092336
"name": "benchmark_jw_3",
2337+
"prerequisites": [],
23102338
"trafficAllocation": 100,
23112339
"trafficAllocationSeed": 1252392550,
23122340
"seed": 971538037,
@@ -2356,6 +2384,7 @@
23562384
"impressionsDisabled": false,
23572385
"trafficTypeName": "user",
23582386
"name": "benchmark_jw_2",
2387+
"prerequisites": [],
23592388
"trafficAllocation": 100,
23602389
"trafficAllocationSeed": -285565213,
23612390
"seed": -1992295819,
@@ -2405,6 +2434,7 @@
24052434
"impressionsDisabled": false,
24062435
"trafficTypeName": "account",
24072436
"name": "MAURO_TEST",
2437+
"prerequisites": [],
24082438
"trafficAllocation": 59,
24092439
"trafficAllocationSeed": -2108186082,
24102440
"seed": -1947050766,
@@ -2521,6 +2551,59 @@
25212551
"label": "in segment all"
25222552
}
25232553
]
2554+
},
2555+
{
2556+
"impressionsDisabled": false,
2557+
"trafficTypeName": "account",
2558+
"name": "prereq_flag",
2559+
"prerequisites": [
2560+
{"n": "MAURO_TEST", "ts": ["off"]},
2561+
{"n": "FACUNDO_TEST", "ts": ["on"]}
2562+
],
2563+
"trafficAllocation": 100,
2564+
"trafficAllocationSeed": -285565213,
2565+
"seed": -1992295819,
2566+
"status": "ACTIVE",
2567+
"killed": false,
2568+
"defaultTreatment": "off_default",
2569+
"changeNumber": 1494593336752,
2570+
"algo": 2,
2571+
"conditions": [
2572+
{
2573+
"conditionType": "ROLLOUT",
2574+
"matcherGroup": {
2575+
"combiner": "AND",
2576+
"matchers": [
2577+
{
2578+
"keySelector": {
2579+
"trafficType": "user",
2580+
"attribute": null
2581+
},
2582+
"matcherType": "ALL_KEYS",
2583+
"negate": false,
2584+
"userDefinedSegmentMatcherData": null,
2585+
"whitelistMatcherData": null,
2586+
"unaryNumericMatcherData": null,
2587+
"betweenMatcherData": null,
2588+
"booleanMatcherData": null,
2589+
"dependencyMatcherData": null,
2590+
"stringMatcherData": null
2591+
}
2592+
]
2593+
},
2594+
"partitions": [
2595+
{
2596+
"treatment": "on",
2597+
"size": 100
2598+
},
2599+
{
2600+
"treatment": "off",
2601+
"size": 0
2602+
}
2603+
],
2604+
"label": "in segment all"
2605+
}
2606+
]
25242607
}
25252608
],
25262609
"s": -1,

spec/test_data/splits/between_matcher/datetime_matcher_splits.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"orgId":"cee838c0-b3eb-11e5-855f-4eacec19f7bf",
55
"environment":"cf2d09f0-b3eb-11e5-855f-4eacec19f7bf",
66
"name":"test_feature",
7+
"prerequisites": [],
78
"trafficTypeId":"u",
89
"trafficTypeName":"User",
910
"seed":-195840228,

spec/test_data/splits/between_matcher/negate_number_matcher_splits.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"orgId":"cee838c0-b3eb-11e5-855f-4eacec19f7bf",
55
"environment":"cf2d09f0-b3eb-11e5-855f-4eacec19f7bf",
66
"name":"test_feature",
7+
"prerequisites": [],
78
"trafficTypeId":"u",
89
"trafficTypeName":"User",
910
"seed":-195840228,

spec/test_data/splits/between_matcher/negative_number_matcher_splits.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"orgId":"cee838c0-b3eb-11e5-855f-4eacec19f7bf",
55
"environment":"cf2d09f0-b3eb-11e5-855f-4eacec19f7bf",
66
"name":"test_feature",
7+
"prerequisites": [],
78
"trafficTypeId":"u",
89
"trafficTypeName":"User",
910
"seed":-195840228,

spec/test_data/splits/between_matcher/number_matcher_splits.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"orgId":"cee838c0-b3eb-11e5-855f-4eacec19f7bf",
55
"environment":"cf2d09f0-b3eb-11e5-855f-4eacec19f7bf",
66
"name":"test_feature",
7+
"prerequisites": [],
78
"trafficTypeId":"u",
89
"trafficTypeName":"User",
910
"seed":-195840228,

spec/test_data/splits/combining_matcher_splits.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
"trafficTypeName": "user",
55
"name": "PASSENGER_anding",
6+
"prerequisites": [],
67
"trafficAllocation": 100,
78
"trafficAllocationSeed": -1740914610,
89
"seed": 1288528654,

spec/test_data/splits/engine/all_keys_matcher.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"orgId":"cee838c0-b3eb-11e5-855f-4eacec19f7bf",
55
"environment":"cf2d09f0-b3eb-11e5-855f-4eacec19f7bf",
66
"name":"test_feature",
7+
"prerequisites": [],
78
"trafficTypeId":"u",
89
"trafficTypeName":"User",
910
"seed":-195840228,

0 commit comments

Comments
 (0)