Skip to content

Commit 1b9eacc

Browse files
authored
Add docs on running tests (kubernetes#2006)
Took me a while to figure out how to run these locally, particularly when I don't have (easy) access to a GCE project. Add rough notes to the docs, in the hopes that it'll ease the process for others. Signed-off-by: Stephen Finucane <[email protected]> Signed-off-by: Stephen Finucane <[email protected]>
1 parent 68f4a3e commit 1b9eacc

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

docs/developers-guide.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,48 @@ If you are ready for code contribution, you need to have development environment
5858
1. IDE. You can choose any IDE that supports Golang, e.g. Visual Studio Code, GoLand, etc.
5959
1. Install [Docker Engine](https://docs.docker.com/engine/install/) or other tools that could build container images such as [podman](https://podman.io/). After writing the code, the best way to test openstack-cloud-controller-manager is to replace the container image specified in its Deployment/StatefulSet/DaemonSet manifest in the kubernetes cluster. We are using docker in this guide.
6060

61+
### Testing
62+
63+
*cloud-provider-openstack* includes a number of different types of test. As is usual for Kubernetes projects, jobs definitions live in the [test-infra](https://github.com/kubernetes/test-infra/tree/master/config/jobs/kubernetes/cloud-provider-openstack) project. A variety of tests run on each PR, however, you can also run your tests locally.
64+
65+
### Unit tests
66+
67+
Unit tests require a go environment with a suitable go version, as noted previously. Assuming you have this, you can run unit tests using the `unit` Makefile target.
68+
69+
```
70+
make unit
71+
```
72+
73+
### E2E tests
74+
75+
End-to-end or _e2e_ tests are more complex to run as they require a functioning OpenStack cloud and Kubernetes (well, k3s) deployment. Fortunately, you can rely on the infrastructure used for CI to run this on your own machines.
76+
77+
For example, to run the Cinder CSI e2e tests, the CI calls the `tests/ci-csi-cinder-e2e.sh` script. Inspecting this, you'll note that a lot of the commands in here are simply provisioning an instance on GCE, using [Boskos](https://github.com/kubernetes-sigs/boskos) to manage static resources (projects, in this case) if needed. If you have a set of GCE credentials, then in theory you could run this script as-is. However, all you need is a VM with sufficient resources and network connectivity running the correct image (Ubuntu 20.04 cloud image as of writing - check `tests/scripts/create-gce-vm.sh` for the latest info). For example, using OpenStack:
78+
79+
```
80+
openstack server create \
81+
--image ubuntu2004 \
82+
--flavor m1.large \
83+
--key-name <key-name> \
84+
--network <network> \
85+
--wait \
86+
${USER}-csi-cinder-e2e-tests
87+
openstack server add floating ip <server> <ip-address>
88+
```
89+
90+
Once done, you can run the same Ansible commands seen in `tests/ci-csi-cinder-e2e.sh`:
91+
92+
```
93+
ansible-playbook \
94+
-v \
95+
--user ubuntu \
96+
--inventory 10.0.110.127, \
97+
--ssh-common-args "-o StrictHostKeyChecking=no" \
98+
tests/playbooks/test-csi-cinder-e2e.yaml
99+
```
100+
101+
As you can see, this whole area needs improvement to make this a little more approachable for non-CI use cases. This should be enough direction to get started though.
102+
61103
### Build openstack-cloud-controller-manager image
62104
In cloud-provider-openstack repo directory, run:
63105

@@ -96,7 +138,7 @@ IMAGE_NAMES=openstack-cloud-controller-manager \
96138
make upload-image-amd64
97139
```
98140

99-
Now, you can change openstack-cloud-controller-manager image in the kubernetes cluster, assuming the openstack-cloud-controller-manager is running as a DaemonSet:
141+
Now you can change openstack-cloud-controller-manager image in the kubernetes cluster, assuming the openstack-cloud-controller-manager is running as a DaemonSet:
100142

101143
```
102144
kubectl -n kube-system set image \

0 commit comments

Comments
 (0)