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 |
John Abd-El-Malek | 6cd762c | 2021-06-15 18:59:37 | [diff] [blame] | 8 | perf bots and various browser tests in the waterfall (e.g. browser_tests, |
| 9 | components_browsertests, content_browsertests, extensions_browsertests, interactive_ui_tests and |
| 10 | sync_integration_tests). It is not used by unit test targets. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 11 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 12 | > Note: This configuration applies specifically to Chromium developer builds. |
| 13 | > Chrome branded / official builds do not use these definitions. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 14 | |
Alexei Svitkine | 312686762 | 2020-12-02 23:03:02 | [diff] [blame] | 15 | > Note: Non-developer builds of Chromium (for example, non-Chrome browsers, |
| 16 | > or Chromium builds provided by Linux distros) should disable the testing |
| 17 | > config via the GN flag `fieldtrial_testing_like_official_build=true`. |
| 18 | |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 19 | ## Config File Format |
| 20 | |
| 21 | ```json |
| 22 | { |
| 23 | "StudyName": [ |
| 24 | { |
| 25 | "platforms": [Array of Strings of Valid Platforms for These Experiments], |
| 26 | "experiments": [ |
| 27 | { |
| 28 | "//0": "Comment Line 0. Lines 0-9 are supported.", |
| 29 | "name": "ExperimentName", |
| 30 | "params": {Dictionary of Params}, |
| 31 | "enable_features": [Array of Strings of Features], |
| 32 | "disable_features": [Array of Strings of Features] |
| 33 | }, |
| 34 | ... |
| 35 | ] |
| 36 | }, |
| 37 | ... |
| 38 | ], |
| 39 | ... |
| 40 | } |
| 41 | ``` |
| 42 | |
| 43 | 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] | 44 | array of *study configurations*. The study name in the configuration file |
| 45 | **must** match the FieldTrial name used in the Chromium client code. |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 46 | |
| 47 | > Note: Many newer studies do not use study names in the client code at all, and |
| 48 | > rely on the [Feature List API][FeatureListAPI] instead. Nonetheless, if a |
Carlos Knippschild | e12741b | 2019-12-12 01:26:23 | [diff] [blame] | 49 | > study has a server-side configuration, the study `name` specified here |
| 50 | > must still match the name specified in the server-side configuration; this is |
Joe Mason | 8c711c20 | 2021-07-14 20:04:14 | [diff] [blame^] | 51 | > used to implement consistency checks on the server. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 52 | |
| 53 | ### Study Configurations |
| 54 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 55 | Each *study configuration* is a dictionary containing `platforms` and |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 56 | `experiments`. |
| 57 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 58 | `platforms` is an array of strings, indicating the targetted platforms. The |
Dominik Röttsches | 1243e0f | 2019-07-08 18:49:56 | [diff] [blame] | 59 | strings may be `android`, `android_webview`, `chromeos`, `ios`, `linux`, `mac`, |
| 60 | or `windows`. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 61 | |
| 62 | `experiments` is an array containing the *experiments*. |
| 63 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 64 | The converter uses the `platforms` array to determine which experiment to use |
| 65 | for the study. The first experiment matching the active platform will be used. |
| 66 | |
| 67 | > Note: While `experiments` is defined as an array, currently only the first |
| 68 | > entry is used*\**. We would love to be able to test all possible study |
| 69 | > configurations, but don't currently have the buildbot resources to do so. |
| 70 | > Hence, the current best-practice is to identify which experiment group is the |
| 71 | > most likely candidate for ultimate launch, and to test that configuration. If |
| 72 | > there is a server-side configuration for this study, it's typically |
| 73 | > appropriate to copy/paste one of the experiment definitions into this file. |
| 74 | > |
| 75 | > *\** |
| 76 | > <small> |
| 77 | > Technically, there is one exception: If there's a forcing_flag group |
| 78 | > specified in the config, that group will be used if there's a corresponding |
| 79 | > forcing_flag specified on the command line. You, dear reader, should |
| 80 | > probably not use this fancy mechanism unless you're <em>quite</em> sure you |
| 81 | > know what you're doing =) |
| 82 | > </small> |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 83 | |
| 84 | ### Experiments (Groups) |
| 85 | Each *experiment* is a dictionary that must contain the `name` key, identifying |
Ilya Sherman | 8422599 | 2020-02-28 00:39:21 | [diff] [blame] | 86 | the experiment group name. |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 87 | |
Ilya Sherman | 8422599 | 2020-02-28 00:39:21 | [diff] [blame] | 88 | > Note: Studies should typically use the [Feature List API][FeatureListAPI]. For |
| 89 | > such studies, the experiment `name` specified in the testing config is still |
| 90 | > required (for legacy reasons), but it is ignored. However, the lists of |
| 91 | > `enable_features`, `disable_features`, and `params` **must** match the server |
| 92 | > config. This is enforced via server-side Tricorder checks. |
| 93 | > |
| 94 | > For old-school studies that do check the actual experiment group name in the |
| 95 | > client code, the `name` **must** exactly match the client code and the server |
| 96 | > config. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 97 | |
Jonathan Backer | 60ac0ec | 2020-06-17 15:40:53 | [diff] [blame] | 98 | The remaining keys -- `enable_features`, `disable_features`, `min_os_version`, |
| 99 | and `params` -- are optional. |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 100 | |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 101 | `enable_features` and `disable_features` indicate which features should be |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 102 | enabled and disabled, respectively, through the |
| 103 | [Feature List API][FeatureListAPI]. |
| 104 | |
Jonathan Backer | 60ac0ec | 2020-06-17 15:40:53 | [diff] [blame] | 105 | `min_os_version` indicates a minimum OS version level (e.g. "10.0.0") to apply |
| 106 | the experiment. This string is decoded as a `base::Version`. The same version is |
| 107 | applied to all platforms. If you need different versions for different |
| 108 | platforms, you will need to use different studies. |
| 109 | |
Ilya Sherman | 8422599 | 2020-02-28 00:39:21 | [diff] [blame] | 110 | `params` is a dictionary mapping parameter name to parameter value. |
| 111 | |
isherman | a509c185 | 2017-03-23 21:11:35 | [diff] [blame] | 112 | > Reminder: The variations framework does not actually fetch any field trial |
| 113 | > definitions from the server for Chromium builds, so any feature enabling or |
| 114 | > disabling must be configured here. |
| 115 | |
| 116 | [FeatureListAPI]: https://cs.chromium.org/chromium/src/base/feature_list.h |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 117 | |
| 118 | #### Comments |
| 119 | |
| 120 | Each experiment may have up to 10 lines of comments. The comment key must be of |
| 121 | the form `//N` where `N` is between 0 and 9. |
| 122 | |
| 123 | ```json |
| 124 | { |
| 125 | "AStudyWithExperimentComment": [ |
| 126 | { |
Paul Miller | ad77b789 | 2018-07-11 20:07:43 | [diff] [blame] | 127 | "platforms": ["chromeos", "linux", "mac", "windows"], |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 128 | "experiments": [ |
| 129 | { |
| 130 | "//0": "This is the first comment line.", |
| 131 | "//1": "This is the second comment line.", |
| 132 | "name": "DesktopExperiment" |
| 133 | } |
| 134 | ] |
| 135 | } |
| 136 | ] |
| 137 | } |
| 138 | ``` |
| 139 | |
| 140 | ### Specifying Different Experiments for Different Platforms |
| 141 | Simply specify two different study configurations in the study: |
| 142 | |
| 143 | ```json |
| 144 | { |
| 145 | "DifferentExperimentsPerPlatform": [ |
| 146 | { |
Paul Miller | ad77b789 | 2018-07-11 20:07:43 | [diff] [blame] | 147 | "platforms": ["chromeos", "linux", "mac", "windows"], |
robliao | 2ff5332 | 2016-09-23 19:28:24 | [diff] [blame] | 148 | "experiments": [{ "name": "DesktopExperiment" }] |
| 149 | }, |
| 150 | { |
| 151 | "platforms": ["android", "ios"], |
| 152 | "experiments": [{ "name": "MobileExperiment" }] |
| 153 | } |
| 154 | ] |
| 155 | } |
| 156 | ``` |
| 157 | |
| 158 | ## Presubmit |
| 159 | The presubmit tool will ensure that your changes follow the correct ordering and |
| 160 | format. |