jefflester/minitrino

Build module testing framework

Closed this issue · 1 comments

Module Tests

Each module's metadata.json file will be extended to include a tests node. An example of this may look like the following:

{
  "tests": [
    {
      "type": "query",
      "data": "SELECT 1;",
      "successCriteria": {
        "rowCount": 27,
        "contains": [
          "foo"
        ]
      }
    },
    {
      "type": "shell",
      "container": "trino",
      "data": "cat /etc/starburst/config.properties",
      "successCriteria": {
        "exitCode": 0,
        "contains": [
          "starburst.data-product.enabled=true"
        ]
      }
    },
    {
      "type": "shell",
      "data": "curl -X GET -H 'Accept: application/json' -H 'X-Trino-User: admin' 'localhost:8080/api/v1/dataProduct/products/2'",
      "successCriteria": {
        "exitCode": 0,
        "contains": [
          "Not Found",
          "\"status\":\"404\""
        ]
      }
    },
    {
      "type": "logs",
      "container": "minio",
      "successCriteria": {
        "contains": [
          "bucket created"
        ]
      }
    }
  ]
}

JSON Nodes

  • type: (Required) Type of test to run. Valid values: query, shell, logs.
  • container: (Optional | Shell Specific) Which container to run the test inside of. If not specified, the test is run directly on the host.
  • data: (Required) Test payload (e.g. query, API call, shell command).
  • successCriteria: Criteria to be deemed successful.
    • rowCount: (Optional | Query Specific) How many rows returned in the query.
    • exitCode: (Optional | Shell Specific | Default: 0) Exit code of the shell command. If set to -1, the exit code is completely ignored.
    • contains: (Optional) A list of strings to check in the test's output.

Closed with #69