Skip to content

Commit

Permalink
docs about manual testing in development (#1882) (#1899)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored Mar 10, 2020
1 parent be9c642 commit 8f0bf1a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 9 deletions.
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
```

## 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

0 comments on commit 8f0bf1a

Please sign in to comment.