-
Notifications
You must be signed in to change notification settings - Fork 39
Move pmm-api-tests #772
Move pmm-api-tests #772
Changes from 250 commits
8f86451
5c25c7b
22c32ad
1a5e0d1
3d449f4
0e4d949
344cc27
b8c73f4
4df92e9
8a74755
c457ea4
01d5675
2e4821b
ebe1d04
c7b9324
b3f7021
726c144
3203d0e
f37d4c4
d59b8f0
8abf1f9
1836d38
cf57527
50ec88b
b4a06b5
f057748
c803b38
15ab0aa
8609c51
9231324
2af4430
944fbdc
eeccdb6
2e9ff20
5abc697
06c7e4b
978701c
e63475b
c885961
c0fa7b7
4abd14e
94e5c9b
57cb43c
62abfc6
917eb01
f958f1a
173d368
5cf5308
b2f90c9
60b25a2
4c376b5
60012f7
68558f4
866e792
97035ae
31852b6
463bdca
640891d
e55b7ac
faa1712
f402dab
85eec71
c63d70d
60d8816
47bf28a
e86e47f
83f8fae
e84e6ae
786b29b
5c9be4e
59f467e
579167e
c8eb38a
bd59897
c3ed5cf
3ad4aa8
7970236
3d7e29d
e1662a6
9b4a0c5
4f37c8d
9c043d9
1213b16
9092779
ca16bcd
3be10d5
6cd5c63
c401079
940704f
5768e36
aa02546
2b7c7f6
169fb87
8cf4016
c1c431e
b5f592a
c5110ba
8141e7b
0464f0a
3ce5149
3945df0
7ed7752
0ef84e6
18f48d7
f0fa18a
ebe9655
a4a3c1b
c0fd578
547be81
e699fb5
f592086
c828b9e
1004cfb
ec0aa0a
db05dfe
822668e
e05dbc5
fa841b6
9d74617
89437a2
8fdfe4b
5743cc5
d8e5742
ff580ac
172040b
877d537
b8f65f9
af10b6d
8fca9a9
e8d5025
94a43bf
51dd8e5
d50f231
cd20b0f
e283d09
84c7f6a
8d94b48
fc90c2a
294b3c8
c5b7b3e
bfacbf9
83df07b
1f0c987
1667b90
c2550f6
3d77615
5176861
f564520
11403bd
3d29340
d2bed96
365bc2b
9a09319
57380cb
837e6d5
0054a51
f35db7b
1cb4875
0c35596
ac0926f
43f4c0b
dbae12d
d72a90f
0eb3d8e
9b55324
6eaaf3f
4b44bfa
de49b0d
1fd5c61
8be34b3
a9b3bba
f78521b
082ac7d
925997b
3e58538
fa0f783
4e8d57e
ae4ba6a
d76c0d2
07fbc4f
0ee3b68
60cb2e8
ce10713
0ed5914
354d7fa
7459217
c7ddb4b
d1697ba
68111af
fd4ca67
ccb7223
55d4016
c1180dc
1e1f396
f338ecb
0889415
2c85bbf
0c3f533
e87e2b3
527bafc
d9673d3
5a87b87
5209eab
6ce152e
199b833
0a3cb27
9d6f5d9
4628fa2
d4dbbc3
8872787
dad9d43
d6b4b26
cf793fb
eb9cd09
f63b6de
052a472
130b8dd
5480edf
319cee0
36c3265
72e9323
b6420c2
0cc961a
8298348
6421054
eb4280f
acf26ad
f468b66
faf7392
a825990
d0b8490
0aec792
de8ff4c
3d69a92
b9fc498
f1d87ab
6544eb7
df10b55
15851f7
9fd5877
7d6d1c6
77e11bd
8b72a1d
ff9fe28
0a242d6
663bf4d
fac9e32
3f57fbe
99234e9
9e13831
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * @BupycHuk |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| .idea/ | ||
| .vscode/ | ||
|
|
||
| bin/ | ||
| *.test | ||
|
|
||
| pmm-api-tests-output.txt | ||
| pmm-api-tests-junit-report.xml | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that we can remove this file.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are u sure? In this repo it is unusued, but it is used in makefile, it can be maybe used in some jenkins pipeline |
||
| # The most valuable linters; they are required to pass for PR to be merged. | ||
|
|
||
| linters-settings: | ||
| depguard: | ||
| list-type: blacklist | ||
| include-go-root: true | ||
| packages: | ||
| # use "github.com/pkg/errors" instead | ||
| - errors | ||
| # use "github.com/golang/protobuf/proto" instead | ||
| - github.com/gogo/protobuf/proto | ||
|
|
||
| goimports: | ||
| local-prefixes: github.com/Percona-Lab/pmm-api-tests | ||
|
|
||
| linters: | ||
| disable-all: true | ||
| enable: | ||
| - depguard | ||
| - goimports | ||
| - ineffassign | ||
| - govet | ||
| - staticcheck | ||
|
|
||
| issues: | ||
| exclude-use-default: false | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --- | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove |
||
| linters-settings: | ||
| depguard: | ||
| list-type: blacklist | ||
| include-go-root: true | ||
| packages: | ||
| # use "github.com/pkg/errors" instead | ||
| - errors | ||
| # use "github.com/golang/protobuf/proto" instead | ||
| - github.com/gogo/protobuf/proto | ||
|
|
||
| goimports: | ||
| local-prefixes: github.com/Percona-Lab/pmm-api-tests | ||
|
|
||
| lll: | ||
| line-length: 170 | ||
| tab-width: 4 | ||
|
|
||
| unused: | ||
| check-exported: true | ||
|
|
||
| unparam: | ||
| check-exported: true | ||
|
|
||
| linters: | ||
| enable-all: true | ||
| disable: | ||
| - wsl # too annoying | ||
| - lll # too annoying | ||
| - unused # very annoying false positive: https://github.com/golangci/golangci-lint/issues/791 | ||
| - goerr113 # we use different approach for errors | ||
| - testpackage # senseless | ||
| - exhaustivestruct # too annoying | ||
|
|
||
| issues: | ||
| exclude-use-default: false | ||
| exclude: | ||
| # gas: Duplicated errcheck checks | ||
| - 'G104: Errors unhandled' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| dist: bionic | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this one, we need to move this jobs to the main CI |
||
| language: go | ||
| os: linux | ||
|
|
||
| go: | ||
| - 1.15.x | ||
| - tip | ||
|
|
||
| env: | ||
| global: | ||
| # REVIEWDOG_GITHUB_API_TOKEN | ||
| secure: UDUOb+m3zOSfih/ai4WX5G9mIbNGDqh1ypKqPd0QiDwsVS7q1pSm9f0ZvboNTvGJFlREDLNznLD3TMlbqgNz3V73I/B+Ior8Ct8EVZdGlUlQoyIx78GNZpQ+xBkBZeIni9luoSODES9p2Snz5jASqintr+4jXKd6kTN5YmdBRYV9Ivs2GbCaMo/bvf85610mZtUaTm0aHLGdJ89VW2AZk4wxC4N0FUaEupzv/IoAIRZ75paX1ZrwniuReH26z5AvpPrCOOSYep482jo3KhpqCEoJuNOhHcLSfGpwVIKinBCJwnQrt9BvC3NJlJNkr21LwjUgUpjokKIrIifS3CiowjoklcvDk7QF9XqFO5SUw6OOKDJGQoZ7BLcOPVKJkRaa07sD/wftjZtUzw/7FjqPiXtgJVsHOX6vrH9Lnqv8t4ke3P12iJ9V5DfMd3Y0V+EtkJ/Z0rokLP5TmOwKkZKqKJSq7vUrBc4nHlhbfLdtuYwCS4Qo7+0EPiwYKaFFousYG0KLsqWtwqpgVKZLGcwRx2HTHMvxj/D52PkW7g7ZvX0fUdyTCyK/ZVsrwM+KG63Vc55jJGf7B+g3ZtxExGkoZxnjxYeo7yPxa4PCAilP8aOwqcvPk2CS71QvxkHdW7NSBnzOdtHaqj53Ju1P+cx+soxULGTl+JuSh7kbBUUiBos= | ||
|
|
||
| jobs: | ||
| fast_finish: true | ||
| allow_failures: | ||
| - go: tip | ||
|
|
||
| # skip non-trunk PMM-XXXX branch builds, but still build pull requests | ||
| branches: | ||
| except: | ||
| - /^PMM\-\d{4}/ | ||
|
|
||
| go_import_path: github.com/Percona-Lab/pmm-api-tests | ||
|
|
||
| before_cache: | ||
| - go clean -testcache | ||
|
|
||
| cache: | ||
| directories: | ||
| - /home/travis/.cache/go-build | ||
| - /home/travis/gopath/pkg | ||
|
|
||
| install: skip | ||
|
|
||
| before_script: | ||
| - make init | ||
| # static analyze | ||
| - make ci-reviewdog | ||
|
|
||
| script: | ||
| - make build | ||
|
|
||
| notifications: | ||
| slack: | ||
| on_success: change | ||
| on_failure: always | ||
| rooms: | ||
| secure: nvqu/KY2K0yNZv9WzqPP49RmkQzvscteV9AsECgIWXZziQhHkyn/yWCAeYPP6nnn76wzQkXfDLGQedGB3ceVebzWdrbcqG091x5FFIGz5YU4mSaWZHKfmS7CWbImDr+1vMJGDFfDBspYahx50PhtwURBA4WUw2C1wfiIMs79+JhxVbcYJqxDHLaaCddAf58TPtNGLibXLKkX0MLXsXfxp1ipheweT7n3jugzKNMgckxYzxrZwlq7ZZOA4IxuwrBkHBDaxrukWAgT+qB9Y6HEJRI6jDuDcaIBfpafhh+4kFyawMm7iODfpe1Gl0WeIqogGNp2rOZ8vynG9RSRtMC7A1o/I0CQQskrSHn78GPTb0eLODNn9iElEfHg5xolb9Cju/qUGDE2/psTWtjWkwSpxpySMlkCnc+AYm6eSunB5cxBkjXA1Q5AA5YP4j9ewHcYkbAcabY7DPPZCinGEb9xwm2F/5xscguYi6DGY/NeNH5QeJxSXIAYYFaY6AuQslXaRzc4CSH94mJGQ/dWO12B3OJnoprTYUTPZNrHICSC8eeKBtzzE+Y+OeA3hr1LcxbtfxkTY3o2eyFmVc0zgcXNeXlbNxHsQtEpdt+7GUHYAj/H1b/tOZE2LShFRQo1MrTbubggcvlbCq/oTerbXC0WJjJQOY5t7jTRXChAhvTiHNE= | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| FROM golang:1.15 | ||
|
oter marked this conversation as resolved.
Outdated
|
||
|
|
||
| RUN mkdir -p $GOPATH/src/github.com/Percona-Lab/pmm-api-tests | ||
|
|
||
| WORKDIR $GOPATH/src/github.com/Percona-Lab/pmm-api-tests/ | ||
| COPY . $GOPATH/src/github.com/Percona-Lab/pmm-api-tests/ | ||
|
|
||
| CMD make init run-race | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| BASE_PATH = $(shell pwd) | ||
| BIN_PATH := $(BASE_PATH)/bin | ||
|
|
||
| export PATH := $(BIN_PATH):$(PATH) | ||
|
|
||
| all: build | ||
|
|
||
| init: ## Installs development tools | ||
| go build -modfile=tools/go.mod -o $(BIN_PATH)/goimports golang.org/x/tools/cmd/goimports | ||
| go build -modfile=tools/go.mod -o $(BIN_PATH)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint | ||
| go build -modfile=tools/go.mod -o $(BIN_PATH)/go-junit-report github.com/jstemmer/go-junit-report | ||
| go build -modfile=tools/go.mod -o $(BIN_PATH)/reviewdog github.com/reviewdog/reviewdog/cmd/reviewdog | ||
|
|
||
| build: | ||
| go install -v ./... | ||
| go test -c -v ./inventory | ||
| go test -c -v ./management | ||
| go test -c -v ./server | ||
|
|
||
| dev-test: ## Run test on dev env. Use `PMM_KUBECONFIG=/path/to/kubeconfig.yaml make dev-test` to run tests for DBaaS. | ||
| go test -count=1 -p 1 -v ./... -pmm.server-insecure-tls | ||
|
|
||
| run: | ||
| go test -count=1 -p 1 -v ./... 2>&1 | tee pmm-api-tests-output.txt | ||
| cat pmm-api-tests-output.txt | $(BIN_PATH)/go-junit-report > pmm-api-tests-junit-report.xml | ||
|
|
||
| run-race: | ||
| go test -count=1 -p 1 -v -race ./... 2>&1 | tee pmm-api-tests-output.txt | ||
| cat pmm-api-tests-output.txt | $(BIN_PATH)/go-junit-report > pmm-api-tests-junit-report.xml | ||
|
|
||
| FILES = $(shell find . -type f -name '*.go') | ||
|
|
||
| format: ## Format source code. | ||
| gofmt -w -s $(FILES) | ||
| $(BIN_PATH)/goimports -local github.com/Percona-Lab/pmm-api-tests -l -w $(FILES) | ||
|
|
||
| clean: | ||
| rm -f ./pmm-api-tests-output.txt | ||
| rm -f ./pmm-api-tests-junit-report.xml | ||
|
|
||
| check-all: ## Run golang ci linter to check new changes from master. | ||
| $(BIN_PATH)/golangci-lint run -c=.golangci.yml --new-from-rev=master | ||
|
|
||
| ci-reviewdog: ## Runs reviewdog checks. | ||
| $(BIN_PATH)/golangci-lint run -c=.golangci-required.yml --out-format=line-number | $(BIN_PATH)/reviewdog -f=golangci-lint -level=error -reporter=github-pr-check | ||
| $(BIN_PATH)/golangci-lint run -c=.golangci.yml --out-format=line-number | $(BIN_PATH)/reviewdog -f=golangci-lint -level=error -reporter=github-pr-review |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # pmm-api-tests | ||
|
|
||
| [](https://travis-ci.com/Percona-Lab/pmm-api-tests) | ||
|
|
||
| API tests for PMM 2.x | ||
|
|
||
| # Setup Instructions | ||
|
|
||
| Make sure you have Go 1.15.x installed on your systems, execute the following steps | ||
| to setup API-tests in your local systems. | ||
|
|
||
| 1. Run PMM Server. | ||
| 2. Fetch the Repo: `go get -u -v github.com/Percona-Lab/pmm-api-tests` | ||
| 3. Navigate to the tests root folder: `cd ~/go/src/github.com/Percona-Lab/pmm-api-tests` | ||
|
|
||
| # Usage | ||
|
|
||
| Run the tests using the following command: | ||
|
|
||
| ``` | ||
| go test ./... -pmm.server-url **pmm-server-url** -v | ||
| ``` | ||
|
|
||
| where `pmm-server-url` should be pointing to pmm-server. | ||
|
|
||
| # Docker | ||
|
|
||
| Build Docker image using the following command: | ||
|
|
||
| ``` | ||
| docker build -t IMAGENAME . | ||
| ``` | ||
|
|
||
| Run Docker container using the following command: | ||
|
|
||
| ``` | ||
| docker run -e PMM_SERVER_URL=**pmm-server-url** IMAGENAME | ||
| ``` | ||
|
|
||
| where `PMM_SERVER_URL` should be pointing to pmm-server. | ||
|
|
||
| If pmm-server located locally: | ||
|
|
||
| - Use --network=host while running docker container or add both containers to the same docker network. | ||
| - Use the insecure url if you default to a self-generated certificate. | ||
|
|
||
| # Contributing | ||
|
|
||
| All tests should follow these rules: | ||
|
|
||
| - Tests can work in parallel and in real system, so take into account that there might be records in database. | ||
| - Always revert changes made by test. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| --- | ||
| # FIXME This file is not used yet; see https://jira.percona.com/browse/PMM-5106 | ||
|
|
||
| version: '3.7' | ||
|
|
||
| services: | ||
| pmm-server: | ||
| image: ${PMM_SERVER_IMAGE:-perconalab/pmm-server:dev-latest} | ||
| container_name: pmm-agent_pmm-server | ||
| ports: | ||
| - 127.0.0.1:80:80 | ||
| - 127.0.0.1:443:443 | ||
| environment: | ||
| - PMM_DEBUG=1 | ||
| - PERCONA_TEST_CHECKS_INTERVAL=10s | ||
| # for local development | ||
| # - PERCONA_TEST_CHECKS_FILE=/srv/checks/custom-checks.yml | ||
| # for check-dev | ||
| - PERCONA_TEST_SAAS_HOST=check-dev.percona.com:443 | ||
| - PERCONA_TEST_CHECKS_PUBLIC_KEY=RWTg+ZmCCjt7O8eWeAmTLAqW+1ozUbpRSKSwNTmO+exlS5KEIPYWuYdX | ||
| volumes: | ||
| - ./testdata/checks:/srv/checks | ||
|
|
||
| test_db: | ||
| image: aleksi/test_db:1.1.0 | ||
| container_name: pmm-agent_test_db | ||
| volumes: | ||
| - test_db_mysql:/test_db/mysql/world:ro | ||
| - test_db_postgres:/test_db/postgresql/world:ro | ||
|
|
||
| # It is essential to have an extra directory `/slowlogs/` between host and container; | ||
| # and to not have a trailing slash at `./testdata/mysql`. | ||
| # Otherwise, MySQL in Docker for Mac completely locks during/after slowlog rotation tests. | ||
| mysql: | ||
| image: ${MYSQL_IMAGE:-percona:5.7} | ||
| container_name: pmm-agent_mysql | ||
| command: > | ||
| --sql-mode="ANSI_QUOTES" | ||
| --performance-schema --innodb_monitor_enable=all | ||
| --slow_query_log --slow_query_log_file=/mysql/slowlogs/slow.log --long_query_time=0 | ||
| ports: | ||
| - 127.0.0.1:3306:3306 | ||
| environment: | ||
| - MYSQL_ROOT_PASSWORD=root-password | ||
| - MYSQL_USER=pmm-agent | ||
| - MYSQL_PASSWORD=pmm-agent-password | ||
| - UMASK=0777 # for slowlog file | ||
| volumes: | ||
| - test_db_mysql:/docker-entrypoint-initdb.d/:ro | ||
| - ./testdata/mysql:/mysql | ||
|
|
||
| mongo: | ||
| image: ${MONGO_IMAGE:-percona/percona-server-mongodb:4.2} | ||
| container_name: pmm-agent_mongo | ||
| command: --profile 2 | ||
| ports: | ||
| - 127.0.0.1:27017:27017 | ||
| environment: | ||
| - MONGO_INITDB_ROOT_USERNAME=root | ||
| - MONGO_INITDB_ROOT_PASSWORD=root-password | ||
|
|
||
| postgres: | ||
| image: ${POSTGRES_IMAGE:-postgres:11} | ||
| container_name: pmm-agent_postgres | ||
| command: > | ||
| -c shared_preload_libraries=pg_stat_statements | ||
| -c track_activity_query_size=2048 | ||
| -c pg_stat_statements.max=10000 | ||
| -c pg_stat_statements.track=all | ||
| -c pg_stat_statements.save=off | ||
| -c track_io_timing=on | ||
| ports: | ||
| - 127.0.0.1:5432:5432 | ||
| environment: | ||
| - POSTGRES_USER=pmm-agent | ||
| - POSTGRES_PASSWORD=pmm-agent-password | ||
| volumes: | ||
| - test_db_postgres:/docker-entrypoint-initdb.d/ | ||
|
|
||
| sysbench: | ||
| image: perconalab/sysbench | ||
| container_name: pmm-agent_sysbench | ||
|
|
||
| volumes: | ||
| test_db_mysql: | ||
| test_db_postgres: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| module github.com/Percona-Lab/pmm-api-tests | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need separate modules configuration for tests?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think it's better to keep own go module for each "micro-service". API tests are standalone. We don't need dependencies from API tests inside pmm-managed. |
||
|
|
||
| go 1.16 | ||
|
|
||
| // Use for local development, but do not commit: | ||
| // replace github.com/percona/pmm => ../../pmm | ||
|
|
||
| // Update with: | ||
| // go get -v github.com/percona/pmm@PMM-2.0 | ||
|
|
||
| require ( | ||
| github.com/AlekSi/pointer v1.1.0 | ||
| github.com/brianvoe/gofakeit/v6 v6.2.2 | ||
| github.com/davecgh/go-spew v1.1.1 | ||
| github.com/go-openapi/runtime v0.19.20 | ||
| github.com/go-openapi/spec v0.19.9 // indirect | ||
| github.com/percona-platform/saas v0.0.0-20210122115803-1b32ca1828e1 | ||
| github.com/percona/pmm v0.0.0-20210707115905-36eb37dae44c | ||
| github.com/prometheus/client_golang v1.9.0 | ||
| github.com/sirupsen/logrus v1.6.0 | ||
| github.com/stretchr/testify v1.6.1 | ||
| golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e | ||
| google.golang.org/grpc v1.35.0 | ||
| gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.