Skip to content

Commit 1712338

Browse files
committed
Added CONTRIBUTING.md
1 parent 6952c95 commit 1712338

File tree

1 file changed

+203
-0
lines changed

1 file changed

+203
-0
lines changed

CONTRIBUTING.md

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# Contributing guide
2+
3+
Welcome to Percona ClusterSync for MongoDB!
4+
5+
1. [Prerequisites](#prerequisites)
6+
2. [Submitting a pull request](#submitting-a-pull-request)
7+
3. [Building Percona ClusterSync for MongoDB](#building-percona-clustersync-for-mongodb)
8+
4. [Running PCSM locally](#running-pcsm-locally)
9+
5. [Running tests locally](#running-tests-locally)
10+
6. [Contributing to documentation](#contributing-to-documentation)
11+
12+
We're glad that you would like to become a Percona community member and participate in keeping open source open.
13+
14+
Percona ClusterSync for MongoDB (PCSM) is a tool for cloning and replicating data between MongoDB clusters. It supports both replica sets and sharded clusters, handling initial data cloning followed by continuous change replication.
15+
16+
You can contribute in one of the following ways:
17+
18+
1. Reach us on our [Forums](https://forums.percona.com/c/mongodb/percona-clustersync-for-mongodb).
19+
2. [Submit a bug report or a feature request](https://jira.percona.com/projects/PCSM)
20+
3. Submit a pull request (PR) with the code patch
21+
4. Contribute to documentation
22+
23+
## Prerequisites
24+
25+
Before submitting code contributions, we ask you to complete the following prerequisites.
26+
27+
### 1. Sign the CLA
28+
29+
Before you can contribute, we kindly ask you to sign our [Contributor License Agreement](https://cla-assistant.percona.com/percona/percona-clustersync-mongodb) (CLA). You can do this in one click using your GitHub account.
30+
31+
**Note**: You can sign it later, when submitting your first pull request. The CLA assistant validates the PR and asks you to sign the CLA to proceed.
32+
33+
### 2. Code of Conduct
34+
35+
Please make sure to read and agree to our [Code of Conduct](https://github.com/percona/community/blob/main/content/contribute/coc.md).
36+
37+
## Submitting a pull request
38+
39+
All bug reports, enhancements and feature requests are tracked in [Jira issue tracker](https://jira.percona.com/projects/PCSM). Though not mandatory, we encourage you to first check for a bug report among Jira issues and in the PR list: perhaps the bug has already been addressed.
40+
41+
For feature requests and enhancements, we do ask you to create a Jira issue, describe your idea and discuss the design with us. This way we align your ideas with our vision for the product development.
42+
43+
If the bug hasn't been reported / addressed, or we've agreed on the enhancement implementation with you, do the following:
44+
45+
1. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) this repository
46+
2. Clone this repository on your machine
47+
3. Create a separate branch for your changes. If you work on a Jira issue, please include the issue number in the branch name so it reads as `pcsm-XXX-my-branch`. This makes it easier to track your contribution.
48+
4. Make your changes. Please follow the guidelines outlined in the [Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments) to improve code readability.
49+
5. Test your changes locally. See the [Running tests locally](#running-tests-locally) section for more information
50+
6. Commit the changes. Add the Jira issue number at the beginning of your message subject so that it reads as `PCSM-XXX - My subject`. The [commit message guidelines](https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53) will help you with writing great commit messages
51+
7. Open a PR to Percona
52+
8. Our team will review your code and if everything is correct, will merge it. Otherwise, we will contact you for additional information or with the request to make changes.
53+
54+
## Building Percona ClusterSync for MongoDB
55+
56+
To build Percona ClusterSync for MongoDB from source code, you require the following:
57+
58+
* Go 1.25 or above. See [Installing and setting up Go tools](https://golang.org/doc/install) for more information
59+
* make
60+
61+
To build the project, run the following commands:
62+
63+
```sh
64+
git clone https://github.com/<your_name>/percona-clustersync-mongodb
65+
cd percona-clustersync-mongodb
66+
make build
67+
```
68+
69+
After `make` completes, you can find the `pcsm` binary in the `./bin` directory:
70+
71+
```sh
72+
./bin/pcsm version
73+
```
74+
75+
By running `pcsm version`, you can verify if Percona ClusterSync for MongoDB has been built correctly and is ready for use.
76+
77+
For development with race detection and debugging enabled, use:
78+
79+
```sh
80+
make test-build
81+
```
82+
83+
## Running PCSM locally
84+
85+
To run PCSM locally for development and testing, follow these steps:
86+
87+
### 1. Deploy MongoDB clusters
88+
89+
Start the source and target sharded clusters using Docker Compose:
90+
91+
```sh
92+
MONGO_VERSION="8.0" ./hack/sh/run.sh
93+
```
94+
95+
For replica set clusters instead of sharded:
96+
97+
```sh
98+
MONGO_VERSION="8.0" ./hack/rs/run.sh
99+
```
100+
101+
### 2. Update /etc/hosts
102+
103+
Add the following entries to your `/etc/hosts` file to resolve the container hostnames:
104+
105+
```
106+
# pcsm test clusters
107+
127.0.0.1 rs00 rs01 rs02 rs10 rs11 rs12
108+
127.0.0.1 src-rs00 src-rs10 src-cfg0 src-mongos
109+
127.0.0.1 tgt-rs00 tgt-rs10 tgt-cfg0 tgt-mongos
110+
```
111+
112+
### 3. Start PCSM
113+
114+
Run PCSM connecting to the source and target clusters:
115+
116+
```sh
117+
make pcsm-start SOURCE="mongodb://src-mongos:27017" TARGET="mongodb://tgt-mongos:29017"
118+
```
119+
120+
## Running tests locally
121+
122+
When you work, you should periodically run tests to check that your changes don't break existing code.
123+
124+
### Go Unit Tests
125+
126+
Run all unit tests with race detection:
127+
128+
```sh
129+
go test -race ./...
130+
```
131+
132+
Or using make:
133+
134+
```sh
135+
make test
136+
```
137+
138+
To run a single test:
139+
140+
```sh
141+
go test -race -run TestName ./package
142+
```
143+
144+
For example:
145+
146+
```sh
147+
go test -race -run TestFilter ./sel
148+
go test -race -v -run TestSanitizeConnString ./topo
149+
```
150+
151+
### Python E2E Tests
152+
153+
Python E2E tests require MongoDB clusters to be running and PCSM to be available.
154+
155+
#### 1. Deploy MongoDB clusters and run PCSM
156+
157+
Follow the steps in [Running PCSM locally](#running-pcsm-locally).
158+
159+
#### 2. Set environment variables
160+
161+
```sh
162+
export TEST_SOURCE_URI="mongodb://src-mongos:27017"
163+
export TEST_TARGET_URI="mongodb://tgt-mongos:29017"
164+
export TEST_PCSM_URL="http://localhost:2242"
165+
```
166+
167+
You don't have to run PCSM manualy, you can let pytest to automatically manage PCSM process. Just export this:
168+
169+
```sh
170+
export TEST_PCSM_BIN="./bin/pcsm"
171+
```
172+
173+
#### 3. Run tests
174+
175+
Run all E2E tests:
176+
177+
```sh
178+
poetry run pytest
179+
```
180+
181+
Run a single test:
182+
183+
```sh
184+
poetry run pytest tests/test_collections.py::test_clone_collection
185+
```
186+
187+
Run tests including slow tests (disabled by default):
188+
189+
```sh
190+
poetry run pytest --runslow
191+
```
192+
193+
## Contributing to documentation
194+
195+
We welcome contributions to our documentation.
196+
197+
Documentation source files are in the [dedicated docs repository](https://github.com/percona/pcsm-docs).
198+
199+
Please follow the contributing guidelines in that repository for how to contribute to documentation.
200+
201+
## After your pull request is merged
202+
203+
Once your pull request is merged, you are an official Percona Community Contributor. Welcome to the community!

0 commit comments

Comments
 (0)