robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 1 | # Field Trial Testing Configuration |
| 2 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 3 | This directory contains the `fieldtrial_testing_config.json` configuration file, |
| 4 | which is used to ensure test coverage of active field trials. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 5 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 6 | For each study, the first available experiment after platform filtering is used |
| 7 | as the default experiment for Chromium builds. This experiment is also used for |
Andrew Williams | 07af7f6 | 2024-07-16 23:05:56 | [diff] [blame] | 8 | perf bots and various tests in the waterfall (browser tests, including those in |
| 9 | browser_tests, components_browsertests, content_browsertests, |
| 10 | extensions_browsertests, interactive_ui_tests, and sync_integration_tests, and |
| 11 | [web platform tests](/docs/testing/web_platform_tests.md)). It is not used by |
| 12 | unit test targets. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 13 | |
Alex Rudenko | cbe846e7 | 2024-11-29 09:01:00 | [diff] [blame] | 14 | > Note: This configuration applies specifically to Chromium developer and |
| 15 | > [Chrome for Testing branded](https://goo.gle/chrome-for-testing) builds. |
| 16 | > Chrome branded builds do not use these definitions by default. They can, however, |
| 17 | > be enabled with the `--enable-field-trial-config` switch. |
Luc Nguyen | 0e516644a | 2022-02-18 15:32:24 | [diff] [blame] | 18 | > For Chrome branded Android builds, due to binary size constraints, the |
| 19 | > configuration cannot be applied by this switch. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 20 | |
Alexei Svitkine | 312686762 | 2020-12-02 23:03:02 | [diff] [blame] | 21 | > Note: Non-developer builds of Chromium (for example, non-Chrome browsers, |
| 22 | > or Chromium builds provided by Linux distros) should disable the testing |
Luc Nguyen | 1180c66 | 2022-02-08 20:38:59 | [diff] [blame] | 23 | > config by either (1) specifying the GN flag `disable_fieldtrial_testing_config=true`, |
Alexei Svitkine | f89da71f | 2023-10-20 21:39:37 | [diff] [blame] | 24 | > (2) specifying the `--disable-field-trial-config` switch or (3) specifying a |
| 25 | > custom variations server URL using the `--variations-server-url` switch. |
Luc Nguyen | 1180c66 | 2022-02-08 20:38:59 | [diff] [blame] | 26 | |
| 27 | > Note: An experiment in the testing configuration file that enables/disables a |
| 28 | > feature that is explicitly overridden (e.g. using the `--enable-features` or |
| 29 | > `--disable-features` switches) will be skipped. |
Alexei Svitkine | 312686762 | 2020-12-02 23:03:02 | [diff] [blame] | 30 | |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 31 | ## Config File Format |
| 32 | |
| 33 | ```json |
| 34 | { |
| 35 | "StudyName": [ |
| 36 | { |
| 37 | "platforms": [Array of Strings of Valid Platforms for These Experiments], |
| 38 | "experiments": [ |
| 39 | { |
| 40 | "//0": "Comment Line 0. Lines 0-9 are supported.", |
| 41 | "name": "ExperimentName", |
| 42 | "params": {Dictionary of Params}, |
| 43 | "enable_features": [Array of Strings of Features], |
| 44 | "disable_features": [Array of Strings of Features] |
| 45 | }, |
| 46 | ... |
| 47 | ] |
| 48 | }, |
| 49 | ... |
| 50 | ], |
| 51 | ... |
| 52 | } |
| 53 | ``` |
| 54 | |
| 55 | The config file is a dictionary at the top level mapping a study name to an |
Carlos Knippschild | e12741b | 2019-12-12 01:26:23 | [diff] [blame] | 56 | array of *study configurations*. The study name in the configuration file |
| 57 | **must** match the FieldTrial name used in the Chromium client code. |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 58 | |
| 59 | > Note: Many newer studies do not use study names in the client code at all, and |
| 60 | > rely on the [Feature List API][FeatureListAPI] instead. Nonetheless, if a |
Carlos Knippschild | e12741b | 2019-12-12 01:26:23 | [diff] [blame] | 61 | > study has a server-side configuration, the study `name` specified here |
| 62 | > must still match the name specified in the server-side configuration; this is |
Joe Mason | 8c711c20 | 2021-07-14 20:04:14 | [diff] [blame] | 63 | > used to implement consistency checks on the server. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 64 | |
| 65 | ### Study Configurations |
| 66 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 67 | Each *study configuration* is a dictionary containing `platforms` and |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 68 | `experiments`. |
| 69 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 70 | `platforms` is an array of strings, indicating the targetted platforms. The |
thefrog | 95a334fc | 2022-06-28 16:00:28 | [diff] [blame] | 71 | strings may be `android`, `android_weblayer`, `android_webview`, `chromeos`, |
| 72 | `chromeos_lacros`, `ios`, `linux`, `mac`, or `windows`. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 73 | |
| 74 | `experiments` is an array containing the *experiments*. |
| 75 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 76 | The converter uses the `platforms` array to determine which experiment to use |
| 77 | for the study. The first experiment matching the active platform will be used. |
| 78 | |
| 79 | > Note: While `experiments` is defined as an array, currently only the first |
| 80 | > entry is used*\**. We would love to be able to test all possible study |
| 81 | > configurations, but don't currently have the buildbot resources to do so. |
| 82 | > Hence, the current best-practice is to identify which experiment group is the |
| 83 | > most likely candidate for ultimate launch, and to test that configuration. If |
| 84 | > there is a server-side configuration for this study, it's typically |
| 85 | > appropriate to copy/paste one of the experiment definitions into this file. |
| 86 | > |
| 87 | > *\** |
| 88 | > <small> |
| 89 | > Technically, there is one exception: If there's a forcing_flag group |
| 90 | > specified in the config, that group will be used if there's a corresponding |
| 91 | > forcing_flag specified on the command line. You, dear reader, should |
| 92 | > probably not use this fancy mechanism unless you're <em>quite</em> sure you |
| 93 | > know what you're doing =) |
| 94 | > </small> |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 95 | |
| 96 | ### Experiments (Groups) |
| 97 | Each *experiment* is a dictionary that must contain the `name` key, identifying |
Ilya Sherman | 8422599 | 2020-02-28 00:39:21 | [diff] [blame] | 98 | the experiment group name. |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 99 | |
Ilya Sherman | 8422599 | 2020-02-28 00:39:21 | [diff] [blame] | 100 | > Note: Studies should typically use the [Feature List API][FeatureListAPI]. For |
| 101 | > such studies, the experiment `name` specified in the testing config is still |
| 102 | > required (for legacy reasons), but it is ignored. However, the lists of |
| 103 | > `enable_features`, `disable_features`, and `params` **must** match the server |
| 104 | > config. This is enforced via server-side Tricorder checks. |
| 105 | > |
| 106 | > For old-school studies that do check the actual experiment group name in the |
| 107 | > client code, the `name` **must** exactly match the client code and the server |
| 108 | > config. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 109 | |
Jonathan Backer | 60ac0ec | 2020-06-17 15:40:53 | [diff] [blame] | 110 | The remaining keys -- `enable_features`, `disable_features`, `min_os_version`, |
Stephen Nusko | 57c6a986 | 2025-04-25 04:22:39 | [diff] [blame] | 111 | `disable_benchmarking`, and `params` -- are optional. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 112 | |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 113 | `enable_features` and `disable_features` indicate which features should be |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 114 | enabled and disabled, respectively, through the |
| 115 | [Feature List API][FeatureListAPI]. |
| 116 | |
Jonathan Backer | 60ac0ec | 2020-06-17 15:40:53 | [diff] [blame] | 117 | `min_os_version` indicates a minimum OS version level (e.g. "10.0.0") to apply |
| 118 | the experiment. This string is decoded as a `base::Version`. The same version is |
| 119 | applied to all platforms. If you need different versions for different |
| 120 | platforms, you will need to use different studies. |
| 121 | |
Stephen Nusko | 57c6a986 | 2025-04-25 04:22:39 | [diff] [blame] | 122 | `disable_benchmarking` indicates that when the flag |
| 123 | `--enable-benchmarking` is passed at start up this experiment should not be |
| 124 | enabled. This should be used extremely sparingly. |
| 125 | |
Stephen Nusko | ff1275876 | 2025-05-23 03:01:41 | [diff] [blame] | 126 | > Warning: `disable_benchmarking` works as described above on most platforms |
| 127 | > however when using the |
| 128 | > [fieldtrial_util.py](https://source.chromium.org/chromium/chromium/src/+/main:tools/variations/fieldtrial_util.py) |
| 129 | > script we will always exclude `disable_benchmarking` experiments. This is |
| 130 | > due to this script being primarily used for benchmarking, and because it |
| 131 | > generates command lines flags to set state we don't know if |
| 132 | > `--enable-benchmarking` will be passed or not. |
| 133 | |
Ilya Sherman | 8422599 | 2020-02-28 00:39:21 | [diff] [blame] | 134 | `params` is a dictionary mapping parameter name to parameter value. |
| 135 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 136 | > Reminder: The variations framework does not actually fetch any field trial |
| 137 | > definitions from the server for Chromium builds, so any feature enabling or |
| 138 | > disabling must be configured here. |
| 139 | |
| 140 | [FeatureListAPI]: https://cs.chromium.org/chromium/src/base/feature_list.h |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 141 | |
| 142 | #### Comments |
| 143 | |
| 144 | Each experiment may have up to 10 lines of comments. The comment key must be of |
| 145 | the form `//N` where `N` is between 0 and 9. |
| 146 | |
| 147 | ```json |
| 148 | { |
| 149 | "AStudyWithExperimentComment": [ |
| 150 | { |
Paul Miller | ad77b789 | 2018-07-11 20:07:43 | [diff] [blame] | 151 | "platforms": ["chromeos", "linux", "mac", "windows"], |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 152 | "experiments": [ |
| 153 | { |
| 154 | "//0": "This is the first comment line.", |
| 155 | "//1": "This is the second comment line.", |
| 156 | "name": "DesktopExperiment" |
| 157 | } |
| 158 | ] |
| 159 | } |
| 160 | ] |
| 161 | } |
| 162 | ``` |
| 163 | |
| 164 | ### Specifying Different Experiments for Different Platforms |
| 165 | Simply specify two different study configurations in the study: |
| 166 | |
| 167 | ```json |
| 168 | { |
| 169 | "DifferentExperimentsPerPlatform": [ |
| 170 | { |
Paul Miller | ad77b789 | 2018-07-11 20:07:43 | [diff] [blame] | 171 | "platforms": ["chromeos", "linux", "mac", "windows"], |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 172 | "experiments": [{ "name": "DesktopExperiment" }] |
| 173 | }, |
| 174 | { |
| 175 | "platforms": ["android", "ios"], |
| 176 | "experiments": [{ "name": "MobileExperiment" }] |
| 177 | } |
| 178 | ] |
| 179 | } |
| 180 | ``` |
| 181 | |
Dominic Battre | f431ec7 | 2022-06-29 07:54:20 | [diff] [blame] | 182 | ## Formatting |
| 183 | |
| 184 | Run the following command to auto-format the `fieldtrial_testing_config.json` |
| 185 | configuration file: |
| 186 | |
| 187 | ```shell |
| 188 | python3 testing/variations/PRESUBMIT.py testing/variations/fieldtrial_testing_config.json |
| 189 | ``` |
| 190 | |
| 191 | The presubmit tool will also ensure that your changes follow the correct |
| 192 | ordering and format. |