github.com/GoogleCloudPlatform/testgrid@v0.0.174/config.md (about)

     1  # TestGrid Configuration
     2  
     3  ## Table of Contents
     4  
     5  * [Prow Job Configuration](#prow-job-configuration)
     6  * [Configuration](#configuration)
     7  * [Testing & Verification](#testing-your-configuration)
     8  * [Advanced Configuration](#advanced-configuration)
     9  
    10  TestGrid is composed of:
    11  
    12  * A list of **test groups** that contain results for a job over time.
    13  * A list of **dashboard tabs** that display a test group
    14  * A list of **dashboards**, or collections of dashboard tabs
    15  * A list of **dashboard groups** of related dashboards.
    16  
    17  Most of these objects are simply listed in a [YAML config file](https://github.com/kubernetes/test-infra/tree/master/config/testgrids) for TestGrid to consume.
    18  
    19  ## Prow Job Configuration
    20  
    21  If you just have a [Prow job](https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md) configuration you want to appear in an existing
    22  dashboard, add annotations to that Prow job.
    23  
    24  If it's a Prow job in [the k8s.io instance](https://github.com/kubernetes/test-infra/tree/master/config/jobs), you don't need to do anything else.
    25  
    26  Add this to your Prow job:
    27  
    28  ```yaml
    29  annotations:
    30    testgrid-dashboards: dashboard-name      # a dashboard already defined in a config.yaml.
    31    testgrid-tab-name: some-short-name       # optionally, a shorter name for the tab. If omitted, just uses the job name.
    32    testgrid-alert-email: me@me.com          # optionally, an alert email that will be applied to the tab created in the
    33                                             # first dashboard specified in testgrid-dashboards.
    34    description: Words about your job.       # optionally, a description of your job. If omitted, just uses the job name.
    35  
    36    testgrid-num-columns-recent: "10"        # optionally, the number of runs a row can be omitted from before it is
    37                                             # considered stale. Currently defaults to 10.
    38    testgrid-num-failures-to-alert: "3"      # optionally, the number of continuous failures before sending an email.
    39                                             # Currently defaults to 3.
    40    testgrid-alert-stale-results-hours: "12" # optionally, send an email if this many hours pass with no results at all.
    41    testgrid-in-cell-metric: "foo-metric"    # optionally, show the value of this metric as the text on a cell.
    42    testgrid-disable-prowjob-analysis: false # optionally, disable Prow job analysis if your results don't upload canonical Prow files.
    43    testgrid-base-options: base-options      # optionally, sets 'base_options' tab option.
    44  
    45  ```
    46  
    47  This functionality is provided by [Configurator](https://github.com/kubernetes/test-infra/tree/master/testgrid/cmd/configurator). If you have Prow jobs in a _different_
    48  instance of Prow, you may want to use [Transfigure](https://github.com/kubernetes/test-infra/tree/master/testgrid/cmd/transfigure) instead.
    49  
    50  If you need to create a new dashboard, or do anything more advanced, read on.
    51  
    52  ## Configuration
    53  
    54  Open or create a TestGrid config file [(example)](https://github.com/kubernetes/test-infra/tree/master/config/testgrids) in your favorite editor and:
    55  
    56  1. Configure the test groups
    57  2. Add those testgroups to one or more tabs in one or more dashboards
    58  3. Consider using dashboard groups if multiple dashboards are needed.
    59  
    60  ### Test groups
    61  
    62  Test groups contain a set of test results across time for the same job.
    63  Each group backs one or more dashboard tabs.
    64  
    65  Add a new test group under `test_groups:`, specifying the group's name,
    66  and where the logs are located.
    67  
    68  Ex:
    69  
    70  ```yaml
    71  test_groups:
    72  - name: {test_group_name}
    73    gcs_prefix: kubernetes-jenkins/logs/{test_group_name}
    74    # Use a comma-separated list of paths for gcs_prefix to show multiple jobs in one tab:
    75    # gcs_prefix: kubernetes-jenkins/logs/job1,kubernetes-jenkins/logs/job2
    76  ```
    77  
    78  See the `TestGroup` message in [`config.proto`] for additional fields to
    79  configure like `days_of_results`, `tests_name_policy`, `notifications`, etc.
    80  
    81  ### Dashboard Tabs
    82  
    83  A dashboard tab is a particular view of a test group. Multiple dashboard tabs can view the same
    84  test group in different ways, via different configuration options. All dashboard tabs belong under
    85  a dashboard (see below).
    86  
    87  ### Dashboards
    88  
    89  A dashboard is a set of related dashboard tabs.  The dashboard name shows up as the top-level link
    90  when viewing TestGrid.
    91  
    92  Add a new dashboard under `dashboards` and a new dashboard tab under that.
    93  
    94  Ex:
    95  
    96  ```yaml
    97  dashboards:
    98  - name: {dashboard-name}
    99    dashboard_tab:
   100    - name: {dashboard-tab-name}
   101      test_group_name: {test-group-name}
   102  ```
   103  
   104  See the `Dashboard` and `DashboardTab` messages in [`config.proto`] for
   105  additional configuration options, such as `notifications`, `file_bug_template`,
   106  `description`, `code_search_url_template`, etc.
   107  
   108  ### Dashboard groups
   109  
   110  A dashboard group is a set of related dashboards. When viewing a dashboard's tabs, you'll see the
   111  other dashboards in the Dashboard Group at the top of the client.
   112  
   113  Add a new dashboard group, specifying names for all the dashboards that fall under this group.
   114  
   115  Ex:
   116  
   117  ```yaml
   118  dashboard_groups:
   119  - name: {dashboard-group-name}
   120    dashboard_names:
   121    - {dashboard-1}
   122    - {dashboard-2}
   123    - {dashboard-3}
   124  ```
   125  
   126  ## Testing your configuration
   127  
   128  Run [`bazel test //config/tests/testgrids/..`](https://github.com/kubernetes/test-infra/tree/master/config/tests/testgrids) to ensure the configuration is valid.
   129  
   130  ## Advanced configuration
   131  
   132  See [`config.proto`] for an extensive list of configuration options. Here are some commonly-used ones.
   133  
   134  ### More/Fewer Results
   135  
   136  Specify `days_of_results` in a test group to increase or decrease the number of days of results shown.
   137  
   138  ```yaml
   139  test_groups:
   140  - name: kubernetes-build
   141    gcs_prefix: kubernetes-jenkins/logs/ci-kubernetes-build
   142    days_of_results: 7
   143  ```
   144  
   145  ### Disable Prowjob Analysis
   146  
   147  Use this if you're seeing failing Pod rows due to missing podinfo.json files, and that's expected behavior.
   148  
   149  ```yaml
   150  test_groups:
   151  - name: kubernetes-build
   152    gcs_prefix: foo/logs/my-conformance-job
   153    disable_prowjob_analysis: true
   154  ```
   155  
   156  ### Tab descriptions
   157  
   158  Add a short description to a dashboard tab describing its purpose.
   159  
   160  ```yaml
   161    dashboard_tab:
   162    - name: gce
   163      test_group_name: ci-kubernetes-e2e-gce
   164      base_options: 'include-filter-by-regex=Kubectl%7Ckubectl'
   165      description: 'kubectl gce e2e tests for master branch'
   166  ```
   167  
   168  ### Link/Bug/Regression-Search Templates
   169  
   170  `(DashboardTab) open_test_template` `(DashboardTab) open_bug_template`
   171  `(DashboardTab) file_bug_template` `(DashboardTab) results_url_template`
   172  `(DashboardTab) code_search_url_template`
   173  
   174  Need to change what links TestGrid opens for tests, bugs, or regression search?
   175  Customize them with templates!
   176  
   177  * `open_test_template`: The test result link when clicking on a cell (e.g. Spyglass)
   178  * `open_bug_template`: The bug link when clicking on associated bugs (e.g. GitHub)
   179  * `file_bug_template`: The default info when filing an issue through the client (e.g. GitHub)
   180  * `attach_bug_template`: The default info when attaching a target to an existing bug (e.g. GitHub)
   181  * `results_url_template`: The link to all test runs (e.g. Deck)
   182  * `code_search_url_template`: The link when searching a code base for a regression (e.g. GitHub)
   183  
   184  You can add fields to link templates to substitute them for an existing value!
   185  
   186  To URL encode something (see JavaScript's encodeURIComponent()) in a template,
   187  like a field, specify `<encode: [what-to-encode]>`.
   188  
   189  e.g. `url = "http://test/<encode:<test-name>>"`
   190  
   191  Fields for `open_test_template`, `open_bug_template`, `file_bug_template`,
   192  `results_url_template`:
   193  
   194  * `<environment>`: The tab name.
   195  * `<test-status>`: String description of the cell's test status (e.g. 'Failed').
   196  * `<test-id>`: Run ID for a cell.
   197  * `<test-name>`: The test name.
   198  * `<display-name>`: The name of the test, as displayed in TestGrid.
   199  * `<gcs_prefix>`: `gcs_prefix` (as defined in your test_group's config).
   200  * `<custom-N>`: The value of the Nth [custom column header](#column-headers) (as defined in
   201      your test_group's config).
   202  * `<results-explorer>`: The current URL (e.g. `https://testgrid.k8s.io/some-dash#some-tab`).
   203  * `<cs-path>`: `code_search_path` (as defined in your test_group's config).
   204  
   205  Fields for `code_search_url_template` (compared between two columns in
   206  TestGrid):
   207  
   208  * `<start-cl>`: The earlier CL/build ID in the comparison
   209  * `<end-cl>`: The later CL/build ID
   210  * `<start-custom-N>`: The earlier custom column header value (see `<custom-N>` above)
   211  * `<end-custom-N>`: The later custom column header value
   212  
   213  ### Column headers
   214  
   215  TestGrid shows date, build number, and k8s and test-infra commit shas above
   216  each run's results by default. To add your own custom column headers, add a
   217  key-value pair in your tests' metadata (see [metadata for
   218  finished.json](https://github.com/kubernetes/test-infra/tree/master/gubernator#job-artifact-gcs-layout)),
   219  and add the key for that pair as a `configuration_value` under `column_header`
   220  for your test group. Example:
   221  
   222  ```yaml
   223  test_groups:
   224  - name: ci-kubernetes-e2e-gce-ubuntudev-k8sdev-default
   225    gcs_prefix:
   226    kubernetes-jenkins/logs/ci-kubernetes-e2e-gce-ubuntudev-k8sdev-default
   227    column_header:
   228    - configuration_value: node_os_image
   229    - configuration_value: master_os_image
   230    - configuration_value: Commit
   231    - configuration_value: infra-commit
   232  ```
   233  
   234  ### Email alerts
   235  
   236  In TestGroup, set `num_failures_to_alert` (alerts for consistent failures)
   237  and/or `alert_stale_results_hours` (alerts when tests haven't run recently).
   238  You can also set `num_passes_to_disable_alert`.
   239  
   240  In DashboardTab, set `alert_mail_to_addresses` (comma-separated list of email
   241  addresses to send mail to).
   242  
   243  Additional options for DashboardTab alerts:
   244  
   245  * `num_passes_to_disable_alert`: the number of consecutive test passes to close the alert
   246  * `subject`: custom subject for alert mails
   247  * `debug_url`: custom link for further context/instructions on debugging this alert
   248  * `debug_message`: custom text to show for the debug link; `debug_url` is required for `debug_message` to appear
   249  
   250  These alerts will send whenever new failures are detected (or whenever the
   251  dashboard tab goes stale), and will stop when `num_passes_to_disable_alert`
   252  consecutive passes are found (or no failure is found in `num_columns_recent`
   253  runs).
   254  
   255  ```yaml
   256  # Send alerts to foo@bar.com whenever a test fails 3 times in a row, or tests
   257  # haven't run in the last day.
   258  test_groups:
   259  - name: ci-kubernetes-e2e-gce
   260    gcs_prefix: kubernetes-jenkins/logs/ci-kubernetes-e2e-gce
   261    alert_stale_results_hours: 24
   262    num_failures_to_alert: 3
   263  
   264  dashboards:
   265  - name: google-gce
   266    dashboard_tab:
   267    - name: gce
   268      test_group_name: ci-kubernetes-e2e-gce
   269      alert_options:
   270        alert_mail_to_addresses: 'foo@bar.com'
   271  ```
   272  
   273  ### Base options
   274  
   275  Default to a set of client modifiers when viewing this dashboard tab.
   276  
   277  ```yaml
   278  # Show test cases from ci-kubernetes-e2e-gce, but only if the test has 'Kubectl' or 'kubectl' in the name.
   279    dashboard_tab:
   280    - name: gce
   281      test_group_name: ci-kubernetes-e2e-gce
   282      base_options: 'include-filter-by-regex=Kubectl%7Ckubectl'
   283      description: 'kubectl gce e2e tests for master branch'
   284  ```
   285  
   286  ### More informative test names
   287  
   288  If you run multiple versions of a test against different parameters, show which parameters they with after the test name.
   289  
   290  ```yaml
   291  # Show a test case as "{test_case_name} [{Context}]"
   292  - name: ci-kubernetes-node-kubelet-benchmark
   293    gcs_prefix: kubernetes-jenkins/logs/ci-kubernetes-node-kubelet-benchmark
   294    test_name_config:
   295      name_elements:
   296      - target_config: Tests name
   297      - target_config: Context
   298      name_format: '%s [%s]'
   299  ```
   300  
   301  ### Customize regression search
   302  
   303  Narrow down where to search when searching for a regression between two builds/commits.
   304  
   305  ```yaml
   306    dashboard_tab:
   307    - name: bazel
   308      description: Runs bazel test //... on the test-infra repo.
   309      test_group_name: ci-test-infra-bazel
   310      code_search_url_template:
   311        url: https://github.com/kubernetes/test-infra/compare/<start-custom-0>...<end-custom-0>
   312  ```
   313  
   314  ### Notifications
   315  
   316  TestGrid supports the ability to add notifications, which appears as a yellow
   317  butter bar / toast message at the top of the screen.
   318  
   319  This is an effective way to broadcast system wide information (all
   320  FOO suites are failing due to blah, upgrade frobber to vX before the
   321  weekend, etc.)
   322  
   323  Configure the list of `notifications:` under dashboard or testgroup:
   324  Each notification includes a `summary:` that defines the text displayed.
   325  Notifications benefit from including a `context_link:` url that can be clicked
   326  to provide more information.
   327  
   328  Ex:
   329  
   330  ```yaml
   331  dashboards:
   332  - name: k8s
   333    dashboard_tab:
   334    - name: build
   335      test_group_name: kubernetes-build
   336    notifications:  # Attach to a specific dashboard
   337    - summary: Hello world (first notification).
   338    - summary: Tests are failing to start (second notification).
   339      context_link: https://github.com/kubernetes/kubernetes/issues/123
   340  ```
   341  
   342  or
   343  
   344  ```yaml
   345  test_groups:  # Attach to a specific test_group
   346  - name: kubernetes-build
   347    gcs_prefix: kubernetes-jenkins/logs/ci-kubernetes-build
   348    notifications:
   349    - summary: Hello world (first notification)
   350    - summary: Tests are failing to start (second notification).
   351      context_link: https://github.com/kubernetes/kubernetes/issues/123
   352  ```
   353  
   354  ### What Counts as 'Recent'
   355  
   356  Configure `num_columns_recent` to change how many columns TestGrid should consider 'recent' for results.
   357  TestGrid uses this to calculate things like 'is this test stale?' (and hides the test).
   358  
   359  ```yaml
   360  test_groups:
   361  - name: kubernetes-build
   362    gcs_prefix: kubernetes-jenkins/logs/ci-kubernetes-build
   363    num_columns_recent: 3
   364  ```
   365  
   366  ### Long-Running Tests
   367  
   368  If your tests run for a very long time (more than 24 hours), set
   369  `max_test_runtime_hours`.
   370  
   371  ```yaml
   372  # This test group has tests that run for 48 hours; set a high max runtime.
   373  test_groups:
   374  - name: some-tests
   375    gcs_prefix: path/to/test/logs/some-tests
   376    max_test_runtime_hours: 50  # Leave a small buffer just in case.
   377  ```
   378  
   379  ### Ignore Pending Results
   380  
   381  `ignore_pending` is false by default, which means that in-progress results will
   382  be shown if we have data for them. If you want to have these not show up, add:
   383  
   384  ```yaml
   385  test_groups:
   386  - name: kubernetes-build
   387    gcs_prefix: kubernetes-jenkins/logs/ci-kubernetes-build
   388    ignore_pending: true
   389  ```
   390  
   391  ### Showing a metric in the cells
   392  
   393  Specify `short_text_metric` to display a custom numeric metric in the TestGrid cells. Example:
   394  
   395  ```yaml
   396  test_groups:
   397  - name: ci-kubernetes-coverage-conformance
   398    gcs_prefix: kubernetes-jenkins/logs/ci-kubernetes-coverage-conformance
   399    short_text_metric: coverage
   400  ```
   401  
   402  [`config.proto`]: ./pb/config/config.proto