Knitter comes with a Makefile
which defines following targets:
- build - Build all knitter related binaries(e.g. knitter-manager,knitter-agent,knitter-plugin,knitter-mornitor)
- test-ut - Test knitter with unit test
- test-e2e - Test knitter with e2e test
- clean - Clean all output artifacts
- verify - Execute the source code verification tools(e.g. gofmt,lint,govet)
- install-extra - Install tools used by verify(e.g. gometalinter)
Knitter uses two levels of testing - unit tests and e2e tests, both of them are run on each pull request, so make sure to run those before submitting one.
Unit tests follow standard Go conventions and are intended to test the behavior and output of a single package in isolation. All code is expected to be easily testable with mock interfaces and stubs, and when they are not it usually means that there's a missing interface or abstraction in the code. A unit test should focus on testing that branches and error conditions are properly returned and that the interface and code flows work as described. Unit tests can depend on other packages but should not depend on other components.
Run the unit tests with:
$ make test-ut
or an individual package unit test with:
$ hack/test-ut.sh pkg/adapter
To run only a certain regex of tests in a package, use:
$ hack/test-ut.sh pkg/SpecificPackage -test.run=TestSpecificCase
To get verbose output add -v
to the end:
$ hack/test-ut.sh pkg/SpecificPackage -test.run=TestSpecificCase -v
The second category are e2e tests which verify the whole Knitter flow.
Run the integration tests with:
$ hack/test-e2e.sh
Knitter uses govendor for dependency package management.
To install godep
locally run:
$ go get github.com/kardianos/govendor
If you are not updating packages you should not need govendor installed.
To build a Knitter release you run make release
,
which will create a build environment image and then execute a cross platform Go build within it. The build
output will be copied to _output/releases
as a set of tars containing each version.
- Create a new git tag
git tag vX.X.X -a -m "vX.X.X" HEAD
- Push the tag to GitHub
git push origin --tags
whereorigin
isgithub.com/ZTE/knitter.git
- Run
make release
- Upload the binary artifacts generated by that build to GitHub release page.
- Send an email to the dev list, including the important changes prior to the release.