blob: 63982da7a7cfa4a2448d772dedd378910429733e [file] [log] [blame] [view]
robliao2ff53322016-09-23 19:28:241# Field Trial Testing Configuration
2
ishermana509c1852017-03-23 21:11:353This directory contains the `fieldtrial_testing_config.json` configuration file,
4which is used to ensure test coverage of active field trials.
robliao2ff53322016-09-23 19:28:245
ishermana509c1852017-03-23 21:11:356For each study, the first available experiment after platform filtering is used
7as the default experiment for Chromium builds. This experiment is also used for
Andrew Williams07af7f62024-07-16 23:05:568perf bots and various tests in the waterfall (browser tests, including those in
9browser_tests, components_browsertests, content_browsertests,
10extensions_browsertests, interactive_ui_tests, and sync_integration_tests, and
11[web platform tests](/docs/testing/web_platform_tests.md)). It is not used by
12unit test targets.
robliao2ff53322016-09-23 19:28:2413
ishermana509c1852017-03-23 21:11:3514> Note: This configuration applies specifically to Chromium developer builds.
Luc Nguyen1180c662022-02-08 20:38:5915> Chrome branded / official builds do not use these definitions by default.
16> They can, however, be enabled with the `--enable-field-trial-config` switch.
Luc Nguyen0e516644a2022-02-18 15:32:2417> For Chrome branded Android builds, due to binary size constraints, the
18> configuration cannot be applied by this switch.
robliao2ff53322016-09-23 19:28:2419
Alexei Svitkine3126867622020-12-02 23:03:0220> Note: Non-developer builds of Chromium (for example, non-Chrome browsers,
21> or Chromium builds provided by Linux distros) should disable the testing
Luc Nguyen1180c662022-02-08 20:38:5922> config by either (1) specifying the GN flag `disable_fieldtrial_testing_config=true`,
Alexei Svitkinef89da71f2023-10-20 21:39:3723> (2) specifying the `--disable-field-trial-config` switch or (3) specifying a
24> custom variations server URL using the `--variations-server-url` switch.
Luc Nguyen1180c662022-02-08 20:38:5925
26> Note: An experiment in the testing configuration file that enables/disables a
27> feature that is explicitly overridden (e.g. using the `--enable-features` or
28> `--disable-features` switches) will be skipped.
Alexei Svitkine3126867622020-12-02 23:03:0229
robliao2ff53322016-09-23 19:28:2430## Config File Format
31
32```json
33{
34 "StudyName": [
35 {
36 "platforms": [Array of Strings of Valid Platforms for These Experiments],
37 "experiments": [
38 {
39 "//0": "Comment Line 0. Lines 0-9 are supported.",
40 "name": "ExperimentName",
41 "params": {Dictionary of Params},
42 "enable_features": [Array of Strings of Features],
43 "disable_features": [Array of Strings of Features]
44 },
45 ...
46 ]
47 },
48 ...
49 ],
50 ...
51}
52```
53
54The config file is a dictionary at the top level mapping a study name to an
Carlos Knippschilde12741b2019-12-12 01:26:2355array of *study configurations*. The study name in the configuration file
56**must** match the FieldTrial name used in the Chromium client code.
ishermana509c1852017-03-23 21:11:3557
58> Note: Many newer studies do not use study names in the client code at all, and
59> rely on the [Feature List API][FeatureListAPI] instead. Nonetheless, if a
Carlos Knippschilde12741b2019-12-12 01:26:2360> study has a server-side configuration, the study `name` specified here
61> must still match the name specified in the server-side configuration; this is
Joe Mason8c711c202021-07-14 20:04:1462> used to implement consistency checks on the server.
robliao2ff53322016-09-23 19:28:2463
64### Study Configurations
65
ishermana509c1852017-03-23 21:11:3566Each *study configuration* is a dictionary containing `platforms` and
robliao2ff53322016-09-23 19:28:2467`experiments`.
68
ishermana509c1852017-03-23 21:11:3569`platforms` is an array of strings, indicating the targetted platforms. The
thefrog95a334fc2022-06-28 16:00:2870strings may be `android`, `android_weblayer`, `android_webview`, `chromeos`,
71`chromeos_lacros`, `ios`, `linux`, `mac`, or `windows`.
robliao2ff53322016-09-23 19:28:2472
73`experiments` is an array containing the *experiments*.
74
ishermana509c1852017-03-23 21:11:3575The converter uses the `platforms` array to determine which experiment to use
76for the study. The first experiment matching the active platform will be used.
77
78> Note: While `experiments` is defined as an array, currently only the first
79> entry is used*\**. We would love to be able to test all possible study
80> configurations, but don't currently have the buildbot resources to do so.
81> Hence, the current best-practice is to identify which experiment group is the
82> most likely candidate for ultimate launch, and to test that configuration. If
83> there is a server-side configuration for this study, it's typically
84> appropriate to copy/paste one of the experiment definitions into this file.
85>
86> *\**
87> <small>
88> Technically, there is one exception: If there's a forcing_flag group
89> specified in the config, that group will be used if there's a corresponding
90> forcing_flag specified on the command line. You, dear reader, should
91> probably not use this fancy mechanism unless you're <em>quite</em> sure you
92> know what you're doing =)
93> </small>
robliao2ff53322016-09-23 19:28:2494
95### Experiments (Groups)
96Each *experiment* is a dictionary that must contain the `name` key, identifying
Ilya Sherman84225992020-02-28 00:39:2197the experiment group name.
ishermana509c1852017-03-23 21:11:3598
Ilya Sherman84225992020-02-28 00:39:2199> Note: Studies should typically use the [Feature List API][FeatureListAPI]. For
100> such studies, the experiment `name` specified in the testing config is still
101> required (for legacy reasons), but it is ignored. However, the lists of
102> `enable_features`, `disable_features`, and `params` **must** match the server
103> config. This is enforced via server-side Tricorder checks.
104>
105> For old-school studies that do check the actual experiment group name in the
106> client code, the `name` **must** exactly match the client code and the server
107> config.
robliao2ff53322016-09-23 19:28:24108
Jonathan Backer60ac0ec2020-06-17 15:40:53109The remaining keys -- `enable_features`, `disable_features`, `min_os_version`,
110and `params` -- are optional.
robliao2ff53322016-09-23 19:28:24111
robliao2ff53322016-09-23 19:28:24112`enable_features` and `disable_features` indicate which features should be
ishermana509c1852017-03-23 21:11:35113enabled and disabled, respectively, through the
114[Feature List API][FeatureListAPI].
115
Jonathan Backer60ac0ec2020-06-17 15:40:53116`min_os_version` indicates a minimum OS version level (e.g. "10.0.0") to apply
117the experiment. This string is decoded as a `base::Version`. The same version is
118applied to all platforms. If you need different versions for different
119platforms, you will need to use different studies.
120
Ilya Sherman84225992020-02-28 00:39:21121`params` is a dictionary mapping parameter name to parameter value.
122
ishermana509c1852017-03-23 21:11:35123> Reminder: The variations framework does not actually fetch any field trial
124> definitions from the server for Chromium builds, so any feature enabling or
125> disabling must be configured here.
126
127[FeatureListAPI]: https://cs.chromium.org/chromium/src/base/feature_list.h
robliao2ff53322016-09-23 19:28:24128
129#### Comments
130
131Each experiment may have up to 10 lines of comments. The comment key must be of
132the form `//N` where `N` is between 0 and 9.
133
134```json
135{
136 "AStudyWithExperimentComment": [
137 {
Paul Millerad77b7892018-07-11 20:07:43138 "platforms": ["chromeos", "linux", "mac", "windows"],
robliao2ff53322016-09-23 19:28:24139 "experiments": [
140 {
141 "//0": "This is the first comment line.",
142 "//1": "This is the second comment line.",
143 "name": "DesktopExperiment"
144 }
145 ]
146 }
147 ]
148}
149```
150
151### Specifying Different Experiments for Different Platforms
152Simply specify two different study configurations in the study:
153
154```json
155{
156 "DifferentExperimentsPerPlatform": [
157 {
Paul Millerad77b7892018-07-11 20:07:43158 "platforms": ["chromeos", "linux", "mac", "windows"],
robliao2ff53322016-09-23 19:28:24159 "experiments": [{ "name": "DesktopExperiment" }]
160 },
161 {
162 "platforms": ["android", "ios"],
163 "experiments": [{ "name": "MobileExperiment" }]
164 }
165 ]
166}
167```
168
Dominic Battref431ec72022-06-29 07:54:20169## Formatting
170
171Run the following command to auto-format the `fieldtrial_testing_config.json`
172configuration file:
173
174```shell
175python3 testing/variations/PRESUBMIT.py testing/variations/fieldtrial_testing_config.json
176```
177
178The presubmit tool will also ensure that your changes follow the correct
179ordering and format.