Skip to content

[Install] Python client and Config

Marcel Verkerk edited this page Dec 16, 2019 · 2 revisions

To make communication with the timings API a bit easier, we have created a number of "timings clients". This page shows you how to install and use the Python client.

  1. Install the Python client

    pip install timingsclient
    
  2. Create a config file
    Instead of sending a list of parameters to the API on every call to the various endpoints, the config file can be used to set defaults. Some of the parameters can be overwritten with the client's .getapiparams() function.

    Copy the sample config from the example below (or from here) to a location on your system - for example: /etc/timings/config.yaml. You can now edit your file as needed.

  3. Import and initiate the client

    from timingsclient import Perf
    
    PERF = Perf('/etc/timings/config.yaml')
    

You can now use this client in your test scenarios. Some example use cases:

  • Asserting page load time
  • Asserting API timings

Example config file:

PERF_API_URL: "http://localhost/v2/api/cicd/"
api_timeout: 2
api_params: 
 sla: 
  pageLoadTime: 2000
 baseline: 
  days: 7
  perc: 75
  padding: 1.2
 flags: 
  assertBaseline: true
  debug: false
  esTrace: false
  esCreate: false
  passOnFailedAssert: false
 log: 
  test_info: "Sample test_info"
  env_tester: "Sample tester"
  browser: "Sample browser"
  env_target: "Sample target"
  team: "SAMPLE TEAM"

more detailed information: https://github.com/godaddy/timings-client-py/blob/master/README.md