Permalink
Newer
Older
100644 174 lines (136 sloc) 7.42 KB
1
# Contributing to Cockroach
2
3
## Getting and Building
5
1. Install the following prerequisites, as necessary:
6
- A C++ compiler that supports C++11. Note that GCC prior to 6.0 doesn't
7
work due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891
8
- A Go environment with a recent 64-bit version of the toolchain. Note that
9
the Makefile enforces the specific version required, as it is updated
10
frequently.
12
- Bash (4+ is preferred)
Apr 18, 2017
13
- GNU Make (3.81+ is known to work)
14
- CMake 2.8.12+
15
- XZ Utils (5.2.3+ is known to work), except on macOS, where xz support is
16
built in to `tar`.
17
- Optional: NodeJS 6.x and Yarn 0.22.0+. Required when compiling protocol
18
buffers.
20
Note that at least 4GB of RAM is required to build from source and run tests.
21
24
```shell
25
go get -d github.com/cockroachdb/cockroach
26
cd $GOPATH/src/github.com/cockroachdb/cockroach
27
```
29
3. Run `make build`, `make test`, or anything else our Makefile offers. Note
30
that the first time you run `make`, it can take some time to download and
31
install various dependencies. After running `make build`, the `cockroach`
32
executable will be in your current directory and can be run as shown in the
33
[README](README.md).
35
### Other Considerations
37
- The default binary contains core open-source functionally covered by the
38
Apache License 2 (APL2) and enterprise functionality covered by the
39
CockroachDB Community License (CCL). To build a pure open-source (APL2)
40
version excluding enterprise functionality, use `make buildoss`. See this
41
[blog post] for more details.
42
43
[blog post]: https://www.cockroachlabs.com/blog/how-were-building-a-business-to-last/
45
- If you edit a `.proto` or `.ts` file, you will need to manually regenerate
46
the associated `.pb.{go,cc,h}` or `.js` files using `make generate`.
48
- We advise to run `make generate` using our embedded Docker setup.
49
`build/builder.sh` is a wrapper script designed to make this convenient. You
50
can run `build/builder.sh make generate` from the repository root to get the
51
intended result.
53
- If you plan on working on the UI, check out [the UI README](pkg/ui).
55
- To add or update a Go dependency:
56
- See [`build/README.md`](build/README.md) for details on adding or updating
57
dependencies.
58
- Run `make generate` to update generated files.
59
- Create a PR with all the changes.
63
[Style Guide](STYLE.md)
65
## Code Review Workflow
67
+ All contributors need to sign the [Contributor License Agreement](https://cla-assistant.io/cockroachdb/cockroach).
69
+ Create a local feature branch to do work on, ideally on one thing at a time.
70
If you are working on your own fork, see [this tip](http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html)
71
on forking in Go, which ensures that Go import paths will be correct.
73
`git checkout -b update-readme`
74
75
+ Hack away and commit your changes locally using `git add` and `git commit`.
76
Remember to write tests! The following are helpful for running specific
77
subsets of tests:
79
```shell
80
make test
81
# Run all tests in ./pkg/storage
82
make test PKG=./pkg/storage
83
# Run all kv tests matching '^TestFoo' with a timeout of 10s
84
make test PKG=./pkg/kv TESTS='^TestFoo' TESTTIMEOUT=10s
85
# Run the sql logic tests
86
make test PKG=./pkg/sql TESTS='TestLogic$$'
87
# or, using a shortcut,
88
make logictest
89
# Run a specific sql logic subtest
90
make test PKG=./pkg/sql TESTS='TestLogic$$/select$$'
91
# or, using a shortcut,
92
make logictest FILES=select
93
```
94
95
Logs are disabled during tests by default. To enable them, include
96
`TESTFLAGS="-v -show-logs"` as an argument the test command:
97
98
```shell
99
make test ... TESTFLAGS="-v -show-logs"
100
```
101
102
When you're ready to commit, be sure to write a Good Commit Message™. Consult
103
https://github.com/erlang/otp/wiki/Writing-good-commit-messages if you're
104
not sure what constitutes a Good Commit Message™.
105
In addition to the general rules referenced above, please also prefix your
106
commit subject line with the affected package, if one can easily be chosen.
107
For example, the subject line of a commit mostly affecting the
108
`server/serverpb` package might read: "server/serverpb: made great again".
109
Commits which affect many packages as a result of a shared dependency change
110
should probably begin their subjects with the name of the shared dependency.
111
Finally, some commits may need to affect many packages in a way which does
112
not point to a specific package; those commits may begin with "*:" or "all:"
113
to indicate their reach.
115
+ Run the test suite locally:
116
117
`make generate check test testrace`
118
119
+ When you’re ready for review, groom your work: each commit should pass tests
120
and contain a substantial (but not overwhelming) unit of work. You may also
121
want to `git fetch origin` and run
122
`git rebase -i --exec "make check test" origin/master` to make sure you're
123
submitting your changes on top of the newest version of our code. Next, push
124
to your fork:
125
126
`git push -u <yourfork> update-readme`
Sep 10, 2014
127
128
+ Then [create a pull request using GitHub’s UI](https://help.github.com/articles/creating-a-pull-request). If you know of
129
another GitHub user particularly suited to reviewing your pull request, be
130
sure to mention them in the pull request body. If you possess the necessary
131
GitHub privileges, please also [assign them to the pull request using
132
GitHub's UI](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users/).
133
This will help focus and expedite the code review process.
Sep 10, 2014
134
135
+ If you get a test failure in CircleCI, check the Test Failure tab to see why
136
the test failed. When the failure is logged in `excerpt.txt`, you can find
137
the file from the Artifacts tab and see log messages. (You need to sign in to
138
see the Artifacts tab.)
Sep 10, 2014
139
140
+ Address feedback by amending your commits. If your change contains multiple
141
commits, address each piece of feedback by amending that commit to which the
142
particular feedback is aimed. Wait (or ask) for new feedback on those
143
commits if they are not straightforward. An `LGTM` ("looks good to me") by
144
someone qualified is usually posted when you're free to go ahead and merge.
145
Most new contributors aren't allowed to merge themselves; in that case, we'll
146
do it for you.
Oct 28, 2015
147
Oct 28, 2015
149
150
Peeking into a running cluster can be done in several ways:
151
152
* the [net/trace](https://godoc.org/golang.org/x/net/trace) endpoint at
153
`/debug/requests`. It has a breakdown of the recent traced requests, in
154
particularly slow ones. Two families are traced: `node` and `coord`, the
155
former (and likely more interesting one) containing what happens inside of
156
`Node`/`Store`/`Replica` and the other inside of the coordinator
157
(`TxnCoordSender`).
158
* [pprof](https://golang.org/pkg/net/http/pprof/) gives us (among other things)
159
heap and cpu profiles; [this golang blog post](http://blog.golang.org/profiling-go-programs) explains it extremely well and
160
[this one by Dmitry Vuykov](https://software.intel.com/en-us/blogs/2014/05/10/debugging-performance-issues-in-go-programs)
161
goes into even more detail.
Oct 28, 2015
162
163
An easy way to locally run a workload against a cluster are the acceptance
164
tests. For example,
Oct 28, 2015
165
166
```shell
Oct 28, 2015
167
make acceptance TESTS='TestPut$$' TESTFLAGS='-v -d 1200s -l .' TESTTIMEOUT=1210s
168
```
169
170
runs the `Put` acceptance test for 20 minutes with logging (useful to look at
171
the stack trace in case of a node dying). When it starts, all the relevant
172
commands for `pprof`, `trace` and logs are logged to allow for convenient
173
inspection of the cluster.