mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-13 22:27:12 +00:00
Feature/testing contributing doc (#197)
This commit is contained in:
parent
7b73004e85
commit
8a8cf4aa77
18
CONTRIBUTE.md
Normal file
18
CONTRIBUTE.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|

|
||||||
|
# CONTRIBUTE
|
||||||
|
We welcome code contributions from the community.
|
||||||
|
Please read and follow the guidelines below.
|
||||||
|
|
||||||
|
## Communication
|
||||||
|
* Before starting work on a major feature, please reach out to us via [GitHub](https://github.com/up9inc/mizu), [Slack](https://join.slack.com/share/zt-u6bbs3pg-X1zhQOXOH0yEoqILgH~csw), [email](mailto:mizu@up9.com), etc. We will make sure no one else is already working on it. A _major feature_ is defined as any change that is > 100 LOC altered (not including tests), or changes any user-facing behavior
|
||||||
|
* Small patches and bug fixes don't need prior communication.
|
||||||
|
|
||||||
|
## Contribution requirements
|
||||||
|
* Code style - most of the code is written in Go, please follow [these guidelines](https://golang.org/doc/effective_go)
|
||||||
|
* Go-tools compatible (`go get`, `go test`, etc)
|
||||||
|
* Unit-test coverage can’t go down ..
|
||||||
|
* Code must be usefully commented. Not only for developers on the project, but also for external users of these packages
|
||||||
|
* When reviewing PRs, you are encouraged to use Golang's [code review comments page](https://github.com/golang/go/wiki/CodeReviewComments)
|
||||||
|
|
||||||
|
|
||||||
|
|
19
README.md
19
README.md
@ -116,7 +116,8 @@ To generate a new config file with default values use `mizu config -r`
|
|||||||
|
|
||||||
### Telemetry
|
### Telemetry
|
||||||
|
|
||||||
By default, mizu reports usage telemetry. It can be disabled by adding a line of telemetry: false in the ${HOME}/.mizu/config.yaml file
|
By default, mizu reports usage telemetry. It can be disabled by adding a line of `telemetry: false` in the `${HOME}/.mizu/config.yaml` file
|
||||||
|
|
||||||
|
|
||||||
## Advanced Usage
|
## Advanced Usage
|
||||||
|
|
||||||
@ -135,14 +136,22 @@ Setting `mizu-resources-namespace=mizu` resets Mizu to its default behavior
|
|||||||
|
|
||||||
### User agent filtering
|
### User agent filtering
|
||||||
|
|
||||||
User-agent filtering (like health checks) - can be configured:
|
User-agent filtering (like health checks) - can be configured using command-line options:
|
||||||
|
|
||||||
Any request that contains one of those values in the user-agent header will not be captured
|
```shell
|
||||||
|
|
||||||
```bash
|
|
||||||
$ mizu tap "^ca.*" --set ignored-user-agents=kube-probe --set ignored-user-agents=prometheus
|
$ mizu tap "^ca.*" --set ignored-user-agents=kube-probe --set ignored-user-agents=prometheus
|
||||||
+carts-66c77f5fbb-fq65r
|
+carts-66c77f5fbb-fq65r
|
||||||
+catalogue-5f4cb7cf5-7zrmn
|
+catalogue-5f4cb7cf5-7zrmn
|
||||||
Web interface is now available at http://localhost:8899
|
Web interface is now available at http://localhost:8899
|
||||||
^C
|
^C
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Any request that contains `User-Agent` header with one of the specified values (`kube-probe` or `prometheus`) will not be captured
|
||||||
|
|
||||||
|
### API Rules validation
|
||||||
|
|
||||||
|
This feature allows you to define set of simple rules, and test the API against them.
|
||||||
|
Such validation may test response for specific JSON fields, headers, etc.
|
||||||
|
|
||||||
|
Please see [API RULES](docs/POLICY_RULES.md) page for more details and syntax.
|
||||||
|
|
||||||
|
15
TESTING.md
Normal file
15
TESTING.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|

|
||||||
|
# TESTING
|
||||||
|
Testing guidelines for Mizu project
|
||||||
|
|
||||||
|
## Unit-tests
|
||||||
|
* TBD
|
||||||
|
* TBD
|
||||||
|
* TBD
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## System tests
|
||||||
|
* TBD
|
||||||
|
* TBD
|
||||||
|
* TBD
|
BIN
assets/validation-example1.png
Normal file
BIN
assets/validation-example1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
BIN
assets/validation-example2.png
Normal file
BIN
assets/validation-example2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 43 KiB |
78
docs/POLICY_RULES.md
Normal file
78
docs/POLICY_RULES.md
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
|
||||||
|
# API rules validation
|
||||||
|
|
||||||
|
This feature allows you to define set of simple rules, and test the API against them.
|
||||||
|
Such validation may test response for specific JSON fields, headers, etc.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
|
||||||
|
Example 1: HTTP request (REST API call) that didn’t pass validation is highlighted in red
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- - -
|
||||||
|
|
||||||
|
|
||||||
|
Example 2: Details pane shows the validation rule details and whether it passed or failed
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
To use this feature - create simple rules file (see details below) and pass this file as parameter to `mizu tap` command. For example, if rules are stored in file named `rules.yaml` — run the following command:
|
||||||
|
|
||||||
|
|
||||||
|
```shell
|
||||||
|
mizu tap --test-rules rules.yaml PODNAME
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Rules file structure
|
||||||
|
|
||||||
|
The structure of the test-rules-file is:
|
||||||
|
|
||||||
|
* `name`: string, name of the rule
|
||||||
|
* `type`: string, type of the rule, must be `json` or `header` or `latency`
|
||||||
|
* `key`: string, [jsonpath](https://code.google.com/archive/p/jsonpath/wikis/Javascript.wiki) used only in `json` or `header` type
|
||||||
|
* `value`: string, [regex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) used only in `json` or `header` type
|
||||||
|
* `service`: string, [regex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) service name to filter
|
||||||
|
* `path`: string, [regex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) URL path to filter
|
||||||
|
* `latency`: integer, time in ms of the expected latency.
|
||||||
|
|
||||||
|
|
||||||
|
### For example:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
rules:
|
||||||
|
- name: holy-in-name-property
|
||||||
|
type: json
|
||||||
|
key: "$.name"
|
||||||
|
value: "Holy"
|
||||||
|
service: "catalogue.*"
|
||||||
|
path: "catalogue.*"
|
||||||
|
- name: content-length-header
|
||||||
|
type: header
|
||||||
|
key: "Content-Le.*"
|
||||||
|
value: "(\\d+(?:\\.\\d+)?)"
|
||||||
|
- name: latency-test
|
||||||
|
type: latency
|
||||||
|
latency: 1
|
||||||
|
service: "carts.*"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Explanation:
|
||||||
|
|
||||||
|
* First rule `holy-in-name-property`:
|
||||||
|
|
||||||
|
> This rule will be applied to all request made to `catalogue.*` services with `catalogue.*` on the URL path with a json response containing a `$.name` field. If the value of `$.name` is `Holy` than is marked as success, marked as failure otherwise.
|
||||||
|
|
||||||
|
* Second rule `content-length-header`:
|
||||||
|
|
||||||
|
> This rule will be applied to all request that has `Content-Le.*` on header. If the value of `Content-Le.*` is `(\\d+(?:\\.\\d+)?)` (number), will be marked as success, marked as failure otherwise.
|
||||||
|
|
||||||
|
* Third rule `latency-test`:
|
||||||
|
|
||||||
|
> This rule will be applied to all request made to `carts.*` services. If the latency of the response is greater than `1` will be marked as failure, marked as success otherwise.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user