Database Testing

The syntax used for DSNs changed in version 5.0. Prior versions used perl’s syntax; while newer versions use go’s syntax.

Configuring

You will need to specify various parameters:

Service DB {
    dbtype:     mysql
    dbname:     mydb
    dbparam:    tls=true
    user:       argus
    pass:       secret
    hostname:   dbhost.example.com
    sql:        SELECT COUNT(*) FROM mytable
}
  • hostname - the hostname of the database server
  • dbtype - type of database. currently supported: postgres, mysql, sqlserver, hdb
  • dbname - the name of the database
  • dbparam - any required connection parameters.
  • user - the username to use for connecting to the database
  • pass - the password to use for connecting to the database, depending on your database, this may be optional.
  • dsn - optionally, specify the dsn used to connect to the database. consult the documentation for the go driver for your database for exact syntax.
  • sql - any arbitrary sql ‘select’ statement

The results of the select statement may be tested using any of the normal tests described in extended testing, such as ‘expect’, or ‘minvalue’.