Go to file
Rick 8da83f3b69
feat: support update and delete testsuite on UI (#119)
2023-07-07 20:28:24 +08:00
.github feat: embed the ui into the Go binary file (#117) 2023-07-07 08:21:53 +08:00
.vscode fix: cannot find the correct parent test cases (#56) 2023-04-26 21:14:38 +08:00
cmd feat: embed the ui into the Go binary file (#117) 2023-07-07 08:21:53 +08:00
console/atest-ui feat: support update and delete testsuite on UI (#119) 2023-07-07 20:28:24 +08:00
docs Proposal accepted in GLCC 2023 (#111) 2023-06-30 13:38:14 +08:00
extensions/collector feat: support to set upstream proxy address (#86) 2023-06-08 11:14:11 +08:00
pkg feat: support update and delete testsuite on UI (#119) 2023-07-07 20:28:24 +08:00
sample feat: support show the response body and header (#113) 2023-07-05 08:44:57 +08:00
.gitignore feat: add ui for the api-testing (#102) 2023-06-26 08:47:24 +08:00
.goreleaser.yaml feat: add a HTTP request collector as atest extension (#85) 2023-06-07 22:59:47 +08:00
CONTRIBUTION.md feat: support output the test report (#17) 2023-04-01 19:00:50 +08:00
Dockerfile Support maintain testSuite and testCase via UI (#108) 2023-07-01 17:59:07 +08:00
LICENSE Initial commit 2022-06-08 14:12:05 +08:00
Makefile feat: embed the ui into the Go binary file (#117) 2023-07-07 08:21:53 +08:00
README.md Support maintain testSuite and testCase via UI (#108) 2023-07-01 17:59:07 +08:00
action.yml Add goreleaser config file 2022-06-09 11:09:01 +08:00
go.mod Support maintain testSuite and testCase via UI (#108) 2023-07-01 17:59:07 +08:00
go.sum feat: add ui for the api-testing (#102) 2023-06-26 08:47:24 +08:00
go.work feat: add a HTTP request collector as atest extension (#85) 2023-06-07 22:59:47 +08:00
go.work.sum feat: add ui for the api-testing (#102) 2023-06-26 08:47:24 +08:00
main.go feat: add ui for the api-testing (#102) 2023-06-26 08:47:24 +08:00

README.md

Codacy Badge Codacy Badge GitHub All Releases LinuxSuRen/open-source-best-practice

This is a API testing tool.

Features

  • Multiple test report formats: Markdown, HTML, Stdout
  • Response Body fields equation check
  • Response Body eval
  • Verify the Kubernetes resources
  • Validate the response body with JSON schema
  • Pre and post handle with the API request
  • Output reference between TestCase
  • Run in server mode, and provide the gRPC and HTTP endpoint
  • VS Code extension support
  • HTTP API record

Get started

Install it via hd or download from releases:

hd install atest

or, you can install it in Kubernetes. See also the manifests.

see the following usage:

API testing tool

Usage:
  atest [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  func        Print all the supported functions
  help        Help about any command
  json        Print the JSON schema of the test suites struct
  run         Run the test suite
  sample      Generate a sample test case YAML file
  server      Run as a server mode
  service     Install atest as a Linux service

Flags:
  -h, --help      help for atest
  -v, --version   version for atest

Use "atest [command] --help" for more information about a command.

below is an example of the usage, and you could see the report as well:

atest run -p sample/testsuite-gitlab.yaml --duration 1m --thread 3 --report md

API Average Max Min Count Error
GET https://gitlab.com/api/v4/projects 1.152777167s 2.108680194s 814.928496ms 99 0
GET https://gitlab.com/api/v4/projects/45088772 840.761064ms 1.487285371s 492.583066ms 10 0
consume: 1m2.153686448s

Use in Docker

Use atest as server mode in Docker, then you could visit the UI from 8080 and the gRPC endpoint from 7070:

docker run -p 7070:7070 -p 8080:8080 ghcr.io/linuxsuren/api-testing

Use atest-collector in Docker:

docker run -p 1234:8080 -v /var/tmp:/var/tmp \
  ghcr.io/linuxsuren/api-testing atest-collector \
  --filter-path /api \
  -o /var/tmp/sample.yaml
# you could find the test cases file from /var/tmp/sample
# cat /var/tmp/sample

Template

The following fields are templated with sprig:

  • API
  • Request Body
  • Request Header

Functions

You could use all the common functions which comes from sprig. Besides some specific functions are available:

Name Usage
randomKubernetesName {{randomKubernetesName}} to generate Kubernetes resource name randomly, the name will have 8 chars
sleep {{sleep(1)}} in the pre and post request handle

Verify against Kubernetes

It could verify any kinds of Kubernetes resources. Please set the environment variables before using it:

  • KUBERNETES_SERVER
  • KUBERNETES_TOKEN

See also the example.

TODO

  • Reduce the size of context
  • Support customized context

Limit

  • Only support to parse the response body when it's a map or array