Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI Improvements] Migrate Tests to resource manager architecture - GET /tests - CLI #2665

Closed
Tracked by #2335
xoscar opened this issue Jun 5, 2023 · 0 comments
Closed
Tracked by #2335
Assignees
Labels

Comments

@xoscar
Copy link
Collaborator

xoscar commented Jun 5, 2023

This task is part of the test migration for the GET /tests endpoint

Acceptance criteria

AC1
As a user using the CLI
I should be able to use the resource verb list to fetch tests from the server]
And the output should be formatted depending on the flag I use

tracetest list test

Description: List Tests
Required flags: none
Optional Flags:

  • --all Get all results, not paginated. If passed, --take and --skip do nothing
  • --take N take N records [default: 20]
  • --skip N skip the first N records [default: 0]
  • --query get resources matching the given query string

Pretty Output Example:

Total avialable Tests: 2

ID Name Version Trigger Type Runs Last Run Time Last Run Successes Last Run Fails URL
WZGNTOBVg Pokeshop - List 1 http 5 2hs ago 1 0 http://localhost:11633/test/WZGNTOBVg
WZGNTOBVg Pokeshop - List 1 http 5 2hs ago 1 0 http://localhost:11633/test/WZGNTOBVg

JSON Output Example:

{
  "items": [
    {
      "type": "Test",
      "spec": {
        "id": "uivSWYf4g",
        "name": "Pokeshop - List",
        "description": "Get a Pokemon",
        "version": 1,
        "createdAt": "2023-03-27T20:08:14.171787Z",
        "serviceUnderTest": {
          "triggerType": "http",
          "triggerSettings": {
            "http": {
              "url": "http://demo-pokemon-api.demo.svc.cluster.local/not-exists",
              "method": "GET",
              "headers": [{
                "key": "Content-Type",
                "value": "application/json"
              }]
            }
          }
        },
        "specs": {
          "specs": [{
            "name": "",
            "selector": {
              "query": "span[tracetest.span.type=\"general\" name=\"Tracetest trigger\"]",
              "structure": [{
                "filters": [{
                    "property": "tracetest.span.type",
                    "operator": "=",
                    "value": "general"
                  },
                  {
                    "property": "name",
                    "operator": "=",
                    "value": "Tracetest trigger"
                  }
                ]
              }]
            },
            "assertions": [
              "attr:tracetest.response.status = 200"
            ]
          }]
        },
        "summary": {
          "runs": 5,
          "lastRun": {
            "time": "2023-03-27T20:08:14.366933Z",
            "passes": 1
          }
        }
      }
    },
    {
      "type": "Test",
      "spec": {
        "id": "uivSWYf4g",
        "name": "Pokeshop - List",
        "description": "Get a Pokemon",
        "version": 1,
        "createdAt": "2023-03-27T20:08:14.171787Z",
        "serviceUnderTest": {
          "triggerType": "http",
          "triggerSettings": {
            "http": {
              "url": "http://demo-pokemon-api.demo.svc.cluster.local/not-exists",
              "method": "GET",
              "headers": [{
                "key": "Content-Type",
                "value": "application/json"
              }]
            }
          }
        },
        "specs": {
          "specs": [{
            "name": "",
            "selector": {
              "query": "span[tracetest.span.type=\"general\" name=\"Tracetest trigger\"]",
              "structure": [{
                "filters": [{
                    "property": "tracetest.span.type",
                    "operator": "=",
                    "value": "general"
                  },
                  {
                    "property": "name",
                    "operator": "=",
                    "value": "Tracetest trigger"
                  }
                ]
              }]
            },
            "assertions": [
              "attr:tracetest.response.status = 200"
            ]
          }]
        },
        "summary": {
          "runs": 5,
          "lastRun": {
            "time": "2023-03-27T20:08:14.366933Z",
            "passes": 1
          }
        }
      }
    }
  ],

}

YAML Output example:

---
type: Test
spec:
  id: uivSWYf4g
  name: Pokeshop - List
  description: Get a Pokemon
  trigger:
    type: http
    http:
    	url: http://demo-pokemon-api.demo.svc.cluster.local/not-exists
      method: GET
      headers:
      - key: Content-Type
      value: application/json
  specs:
    - selector: span[tracetest.span.type="general" name="Tracetest trigger"]
      assertions:
      - attr:tracetest.response.status = 200
---
type: Test
spec:
  id: uivSWYf4g
  name: Pokeshop - List
  description: Get a Pokemon
  trigger:
    type: http
    http:
    	url: http://demo-pokemon-api.demo.svc.cluster.local/not-exists
      method: GET
      headers:
      - key: Content-Type
      value: application/json
  specs:
    - selector: span[tracetest.span.type="general" name="Tracetest trigger"]
      assertions:
      - attr:tracetest.response.status = 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants