Skip to content

Commit bcb1d61

Browse files
authored
docs(readme): update "Quick testing" section (#47)
1 parent 3c4858b commit bcb1d61

File tree

1 file changed

+54
-10
lines changed

1 file changed

+54
-10
lines changed

README.md

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,24 +235,39 @@ All the tests are read from an YAML file or a directory (step **1**) and the res
235235

236236
## Quick testing
237237

238+
### Spinning up the environment
239+
238240
- Make sure you have installed [`kind`](https://kind.sigs.k8s.io/) and its prerequisites
239241
- Make sure you have also installed [`just`](https://github.com/casey/just/releases)
240-
- Download the `NetAssert` binary from the [release](https://github.com/controlplaneio/netassert/releases) page
242+
- Download the `NetAssert` binary from the [release](https://github.com/controlplaneio/netassert/releases) page:
243+
244+
```bash
245+
❯ VERSION="v2.1.3" # change it to the version you want to install
246+
❯ OS_DISTRO=linux_amd64 # change it to your OS_DISTRO (for reference check the NetAssert release page)
247+
❯ curl -L -o netassert.tar.gz https://github.com/controlplaneio/netassert/releases/download/${VERSION}/netassert_${VERSION}_${OS_ARCH}.tar.gz
248+
249+
❯ tar -xzf netassert.tar.gz -C bin/netassert
250+
```
241251

242-
- If you want to quickly test `NetAssert`, you can make use of the sample test(s) and manifests provided
252+
- Alternatively, you can build `NetAssert` from source:
253+
```bash
254+
❯ just build
255+
```
243256

244-
- You will also need a working kubernetes cluster with ephemeral/debug container support and a CNI that supports Network Policies, you can spin one quickly using the `justfile` included in the repo
257+
- You will also need a working kubernetes cluster with ephemeral/debug container support and a CNI that supports Network Policies, you can spin one quickly using the `justfile` included in the repo:
245258

246259
```bash
247260
❯ just kind-down ; just kind-up
248261
❯ just calico-apply
249262
```
250263

251-
- wait for all the nodes to become ready
264+
- wait for all the nodes to become ready:
252265
```bash
253-
❯ kubectl get nodes
266+
❯ kubectl get nodes -w
254267
```
255268

269+
### Running the sample tests
270+
256271
- In order to use the sample tests, you need to create network policies and kubernetes resources:
257272

258273
```bash
@@ -274,17 +289,43 @@ All the tests are read from an YAML file or a directory (step **1**) and the res
274289

275290
```bash
276291
❯ just netpol-apply
292+
kubectl apply -f ./e2e/manifests/networkpolicies.yaml
293+
networkpolicy.networking.k8s.io/web created
277294
```
278295

279-
- Wait for the workload to become ready
296+
- Wait for the workload to become ready (note that the workload pods are the ones created after running `just k8s-apply` in a previous step):
280297
```bash
281298
❯ kubectl get pods -A
299+
busybox busybox-6c85d76fdc-r8gtp 1/1 Running 0 76s
300+
echoserver echoserver-64bd7c5dc6-ldwh9 1/1 Running 0 76s
301+
fluentd fluentd-5pp9c 1/1 Running 0 76s
302+
fluentd fluentd-8vvp9 1/1 Running 0 76s
303+
fluentd fluentd-9jblb 1/1 Running 0 76s
304+
fluentd fluentd-jnlql 1/1 Running 0 76s
305+
kube-system calico-kube-controllers-565c89d6df-8mwk9 1/1 Running 0 117s
306+
kube-system calico-node-2sqhw 1/1 Running 0 117s
307+
kube-system calico-node-4sxpn 1/1 Running 0 117s
308+
kube-system calico-node-5gtg7 1/1 Running 0 117s
309+
kube-system calico-node-kxjq8 1/1 Running 0 117s
310+
kube-system coredns-7d764666f9-74xgb 1/1 Running 0 2m29s
311+
kube-system coredns-7d764666f9-jvnr4 1/1 Running 0 2m29s
312+
kube-system etcd-packet-test-control-plane 1/1 Running 0 2m35s
313+
kube-system kube-apiserver-packet-test-control-plane 1/1 Running 0 2m35s
314+
kube-system kube-controller-manager-packet-test-control-plane 1/1 Running 0 2m35s
315+
kube-system kube-proxy-4xjp2 1/1 Running 0 2m27s
316+
kube-system kube-proxy-b28pw 1/1 Running 0 2m29s
317+
kube-system kube-proxy-p9smj 1/1 Running 0 2m27s
318+
kube-system kube-proxy-xb2wq 1/1 Running 0 2m27s
319+
kube-system kube-scheduler-packet-test-control-plane 1/1 Running 0 2m35s
320+
local-path-storage local-path-provisioner-67b8995b4b-jf8lc 1/1 Running 0 2m29s
321+
pod1 pod1 1/1 Running 0 75s
322+
pod2 pod2 1/1 Running 0 76s
323+
web web-0 1/1 Running 0 75s
324+
web web-1 1/1 Running 0 31s
282325
```
283-
- Run the netassert binary pointing it to the test cases, one of the test cases will fail and this is by design:
326+
- Run the netassert binary pointing it to the test cases:
284327

285328
```bash
286-
❯ just build ## from the root of the project
287-
288329
❯ bin/netassert run --input-file ./e2e/manifests/test-cases.yaml
289330

290331
❯ cat results.tap
@@ -301,10 +342,13 @@ ok 8 - test-from-pod1-to-pod2
301342
ok 9 - busybox-deploy-to-fake-host
302343
```
303344

304-
- To see the results when a check fails
345+
- To see the results when a check fails, run:
305346

306347
```bash
307348
❯ just netpol-rm-apply
349+
kubectl delete -f ./e2e/manifests/networkpolicies.yaml
350+
networkpolicy.networking.k8s.io "web" deleted
351+
308352
❯ bin/netassert run --input-file ./e2e/manifests/test-cases.yaml
309353

310354
❯ cat results.tap

0 commit comments

Comments
 (0)