Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs about manual testing in development #1882

Merged
merged 4 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ $ export GOPATH=$HOME/go
$ export PATH=$PATH:$GOPATH/bin
```

## Dependency management

TiDB Operator uses [retool](https://github.com/twitchtv/retool) to manage Go related tools.

```sh
$ go get -u github.com/twitchtv/retool
```
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retool will be installed when necessary (make check-setup), no need to install manually.


## Workflow

### Step 1: Fork TiDB Operator on GitHub
Expand Down Expand Up @@ -112,6 +104,49 @@ $ make check
This will show errors if your code change does not pass checks (e.g. fmt,
lint). Please fix them before submitting the PR.

#### Start tidb-operator locally and do manual tests

We uses [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) to
start a Kubernetes cluster locally and
[kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) must be
installed to access Kubernetes cluster.

You can refer to their official references to install them on your machine, or
run the following command to install them into our local binary directory:
`output/bin`.

```
$ hack/install-up-operator.sh -i
$ export PATH=$(pwd)/output/bin:$PATH
```

Make sure they are installed correctly:

```
$ kind --version
...
$ kubectl version --client
...
```

Create a Kubernetes cluster with `kind`:

```
$ kind create cluster
```

Build and run tidb-operator:

```
$ ./hack/local-up-operator.sh
```

Start a basic TiDB cluster:

```
$ kubectl apply -f examples/basic/tidb-cluster.yaml
```

#### Run unit tests

Before running your code in a real Kubernetes cluster, make sure it passes all unit tests.
Expand Down
12 changes: 11 additions & 1 deletion hack/local-up-operator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ This commands run tidb-operator in Kubernetes.
Usage: hack/local-up-operator.sh [-hd]

-h show this message and exit
-i install dependencies only

Environments:

Expand All @@ -48,12 +49,16 @@ Environments:
EOF
}

while getopts "h?" opt; do
installOnly=false
while getopts "h?i" opt; do
case "$opt" in
h|\?)
usage
exit 0
;;
i)
installOnly=true
;;
esac
done

Expand All @@ -67,8 +72,13 @@ IMAGE_TAG=${IMAGE_TAG:-latest}
SKIP_IMAGE_BUILD=${SKIP_IMAGE_BUILD:-}

hack::ensure_kubectl
hack::ensure_kind
hack::ensure_helm

if [[ "$installOnly" == "true" ]]; then
exit 0
fi

function hack::create_namespace() {
local ns="$1"
$KUBECTL_BIN create namespace $ns
Expand Down