mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-06-10 12:23:45 +03:00
Compare commits
2 Commits
test/test-
...
ci-change-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab7fa6482a | ||
|
|
8a571257d6 |
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@@ -33,7 +33,8 @@ jobs:
|
||||
name: ${{ matrix.os }}-${{ matrix.arch }}
|
||||
permissions:
|
||||
contents: read
|
||||
runs-on: ubuntu-latest
|
||||
# Runs on dedicated runner with extra resources to increase build speed.
|
||||
runs-on: 'vm-runner'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
||||
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
@@ -30,7 +30,8 @@ jobs:
|
||||
name: lint
|
||||
permissions:
|
||||
contents: read
|
||||
runs-on: ubuntu-latest
|
||||
# Runs on dedicated runner with extra resources since golangci-lint requires extra memory
|
||||
runs-on: 'vm-runner'
|
||||
steps:
|
||||
- name: Code checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
@@ -64,7 +65,8 @@ jobs:
|
||||
name: unit
|
||||
permissions:
|
||||
contents: read
|
||||
runs-on: ubuntu-latest
|
||||
# Runs on dedicated runner with extra resources to increase tests speed.
|
||||
runs-on: 'vm-runner'
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -95,6 +97,7 @@ jobs:
|
||||
name: apptest
|
||||
permissions:
|
||||
contents: read
|
||||
# Runs on dedicated runner to isolate app tests from other tests.
|
||||
runs-on: apptest
|
||||
|
||||
steps:
|
||||
|
||||
2
Makefile
2
Makefile
@@ -471,7 +471,7 @@ test-full-386:
|
||||
|
||||
apptest:
|
||||
$(MAKE) victoria-metrics-race vmagent-race vmalert-race vmauth-race vmctl-race vmbackup-race vmrestore-race
|
||||
VM_APPTEST=1 go test ./apptest/... -skip="^Test(Cluster|Legacy).*"
|
||||
go test ./apptest/... -skip="^Test(Cluster|Legacy).*"
|
||||
|
||||
apptest-legacy: victoria-metrics-race vmbackup-race vmrestore-race
|
||||
OS=$$(uname | tr '[:upper:]' '[:lower:]'); \
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// check if necessary binaries are there.
|
||||
checkBinaryRequirement("../../bin/victoria-metrics-race")
|
||||
checkBinaryRequirement("../../bin/vmagent-race")
|
||||
checkBinaryRequirement("../../bin/vmauth-race")
|
||||
checkBinaryRequirement("../../bin/vmctl-race")
|
||||
checkBinaryRequirement("../../bin/vmbackup-race")
|
||||
checkBinaryRequirement("../../bin/vmrestore-race")
|
||||
|
||||
// check if the test is run via make command
|
||||
checkIntegrationTestEnv()
|
||||
|
||||
// start the integration test.
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
// checkBinaryRequirement panic if required binary not exist.
|
||||
func checkBinaryRequirement(path string) {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
panic(fmt.Sprintf("apptest failed: %s not found. please run `make apptest` to execute apptest. check how different tests are executed: https://docs.victoriametrics.com/victoriametrics/contributing/#testing", path))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkIntegrationTestEnv() {
|
||||
if os.Getenv("VM_APPTEST") == "" {
|
||||
logger.Warnf("executing apptest with potential outdated binaries. it's recommended to execute via `make apptest` command. check this doc for more details: https://docs.victoriametrics.com/victoriametrics/contributing/#testing")
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,8 @@ Pull requests requirements:
|
||||
1. A link to the issue(s) related to the change, if any. Use `Fixes [issue link]` if the PR resolves the issue, or `Related to [issue link]` for reference.
|
||||
1. Tests proving that the change is effective. Tests are expected for non-trivial new functionality or non-trivial modifications.
|
||||
Bug fixes must include tests unless a maintainer explicitly agrees otherwise.
|
||||
See [this style guide](https://itnext.io/f-tests-as-a-replacement-for-table-driven-tests-in-go-8814a8b19e9e) for tests. See [this section](#testing) for how to run tests.
|
||||
See [this style guide](https://itnext.io/f-tests-as-a-replacement-for-table-driven-tests-in-go-8814a8b19e9e) for tests.
|
||||
To run tests and code checks locally, execute commands `make test-full` and `make check-all`.
|
||||
1. Try to not extend the scope of the pull requests outside the issue, do not make unrelated changes.
|
||||
1. Update [docs](https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master/docs) if needed. For example, adding a new flag or changing behavior of existing flags or features
|
||||
requires reflecting these changes in the documentation. For new features add `{{%/* available_from "#" */%}}` shortcode to the documentation.
|
||||
@@ -125,27 +126,3 @@ Due to `KISS`, [cluster version of VictoriaMetrics](https://docs.victoriametrics
|
||||
- Automatic cluster resizing, which may cost you a lot of money if improperly configured.
|
||||
- Automatic discovering and addition of new nodes in the cluster, which may mix data between dev and prod clusters :)
|
||||
- Automatic leader election, which may result in split brain disaster on network errors.
|
||||
|
||||
## Testing
|
||||
|
||||
There are two categories of tests within VictoriaMetrics projects: unit tests and integration tests.
|
||||
|
||||
Since different tests impose distinct requirements on the environment and pre-built binaries,
|
||||
we recommend checking the test-related commands defined in the [`Makefile`](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/Makefile) to understand how each test suite is executed.
|
||||
|
||||
For example, unit tests should be executed via `make test-full`. And the integration tests should be executed using `make apptest`.
|
||||
|
||||
You can check the Makefile for the step-by-step binary build process and run these tests via the `go test` command.
|
||||
However, since the build and execution commands are subject to change, it is recommended that you run the tests using the commands mentioned above.
|
||||
|
||||
We recommend running the following sequence of checks and tests before submitting a pull request:
|
||||
```sh
|
||||
# static checks
|
||||
make check-all
|
||||
|
||||
# unit test
|
||||
make test-full
|
||||
|
||||
# integration test
|
||||
make apptest
|
||||
```
|
||||
Reference in New Issue
Block a user