k3s-io / kine

Run Kubernetes on MySQL, Postgres, sqlite, dqlite, not etcd.
Apache License 2.0
1.5k stars 228 forks source link

Please document how to run the tests locally without drone CI #239

Open oz123 opened 8 months ago

oz123 commented 8 months ago

I am trying to figure out the right order of running the scripts for testing, under script. It seems the I can use drone.yml as a guidance. However, some variables seem supplied by the drone-ci environemen.

oz123 commented 8 months ago

It seems that make lists a collection of targets from scripts directory?

$ make test-load 

and all other targets fail.

Still, this is really unexpected.

docker build -t kine:test-<git-hash> -f Dockerfile.test .
docker run -i -e ARCH -e REPO -e TAG  -e DRONE_TAG -e IMAGE_NAME -v /var/run/docker.sock:/var/run/docker.sock -v kine-cache:/go/src/github.com/k3s-io/kine/.cache --privileged kine:test--<git-hash>"./scripts/test sqlite"

still works.

brandond commented 8 months ago

You need to set the environment variables (-e ARCH and so on) to the correct values.

Something like this should do it: ARCH=$(go env GOARCH) DRONE_COMMIT=$(git rev-parse HEAD) sh -c 'docker build -t kine:test-${DRONE_COMMIT} -f Dockerfile.test . && docker run -i -e ARCH -e REPO -e TAG -e DRONE_TAG -e IMAGE_NAME -v /var/run/docker.sock:/var/run/docker.sock -v kine-cache:/go/src/github.com/k3s-io/kine/.cache --rm --name kine-test --privileged kine:test-${DRONE_COMMIT} "./scripts/test mysql"'

oz123 commented 8 months ago

Can we add theses as explicit make file targets with proper depencies between the targets? Or at least a Contributing files explaining this?

brandond commented 8 months ago

it would be nice if there were makefile targets, yeah. PR welcome!

dereknola commented 8 months ago

This becomes simplier if you just use the Drone CLI. Then you can just call

drone exec --trusted --pipeline=amd64 --event=pull-request

This will launch all of the DB tests. It runs everything in docker containers on your local machine.

If you want to just run a single test, use the --include flag:

drone exec --trusted --pipeline=amd64 --event=pull-request  --include=test-mysql --include=build --include=test-image