You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SovereignCloudStack (SCS) makes use of [Sonobuoy][sonobuoy] as a test framework to run its tests on Kubernetes clusters, which are to be audited for compliance.
9
4
The aim of using this framework is to make the execution of tests on a KaaS infrastructure as simple as possible.
@@ -14,90 +9,75 @@ In short this is achieved by storing all tests in a container image, which can t
14
9
> A more detailed description of why the SCS has decided to use sonobuoys can be found on the corresponding [Decsision Record][sonbouy-decision-record].
15
10
> In addition, sonobuoy is also used as the toolset for executing Kubernetes very own [conformance tests][k8s-conformance].
16
11
17
-
18
12
This document is intended to assist conformance test authors to integrate their tests into the sonobuoy framework.
19
13
This requires a user to write the conformance tests in Golang, as this is the language provided by the framework itself.
20
14
21
-
22
-
# Step-by-step instructions for the development of sonobuoy tests using `docker` and `kind`:
15
+
## Step-by-step instructions for the development of sonobuoy tests using `docker` and `kind`
23
16
24
17
> This guide refers to the brief instructions provided in the [standards repository][scs-sonobuoy-example-guide]
25
18
26
-
27
-
## Prerequisite
19
+
### Prerequisite
28
20
29
21
*[docker][docker-installation]
30
22
*[kind][kind-installation]
31
-
*[sonobuoy][sonobuoy-installation]
23
+
*[sonobuoy][sonobuoy-installation]
32
24
33
-
```
25
+
```bash
34
26
go install github.com/vmware-tanzu/sonobuoy@latest
35
27
```
36
28
37
-
## Set up development environment:
38
-
39
-
40
-
1. Clone the standard repository containing the conformance tests and navigate to the Sonobuoy example located at `standards/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework`
29
+
### Set up development environment
41
30
31
+
#### 1. Clone the standard repository containing the conformance tests and navigate to the Sonobuoy example located at `standards/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework`
cd standards/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/
46
36
```
47
37
48
-
49
-
2. Check the prerequisites
38
+
#### 2. Check the prerequisites
50
39
51
40
Within this directory you will find a `Makefile`, which is also used to create the test images.
52
41
To begin with, this can be used to check whether all the requirements for the development environment are met.
53
42
54
-
```
43
+
```bash
55
44
make dev-prerequests
56
45
```
57
46
58
-
59
-
3. Create a kind cluster
47
+
#### 3. Create a kind cluster
60
48
61
49
Once all the prerequisite software is installed, you can proceed by starting an kind cluster using the `Makefile` as follows:
62
50
63
-
```
51
+
```bash
64
52
make dev-setup
65
53
```
66
54
55
+
#### 4. Setting environment variables for the image build process
67
56
68
-
4. Setting environment variables for the image build process
69
-
70
-
```
57
+
```bash
71
58
kubectl config view
72
59
```
73
60
74
-
```
61
+
```bash
75
62
export IMAGE_VERSION_TAG="dev"
76
63
export K8S_HOST=<kind-cluster-ip>
77
64
export K8S_PORT=<kind-cluster-port>
78
65
```
79
66
80
-
## Create a test:
81
-
82
-
83
-
67
+
### Create a test
84
68
85
69
In general, SCS tests for KaaS are derived from standards that define certain expected behaviors and functionalities of Kubernetes.
86
70
As an example for this step-by-step guide, let's assume a scenario in which there is a fictional standard called "scs-0299-v1-example-standard.md".
87
71
Pretend that the fictitious standard here stipulates that at least one pod MUST run in the namespace "namespace-test-a".
88
72
89
-
> The functions and behaviors to be tested MUST be precisely defined in a standard.
73
+
> The functions and behaviors to be tested MUST be precisely defined in a standard.
90
74
> If you as a developer want to test something that you think is best tested but is not yet part of any standard, you MUST update the standard accordingly.
91
75
92
-
93
-
94
-
95
-
96
-
1. Create example test
76
+
#### 1. Create example test
97
77
98
78
The `scs_k8s_tests` directory contains the Golang files that define the tests.
99
79
100
-
```
80
+
```bash
101
81
cd standards/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/scs_k8s_tests
102
82
```
103
83
@@ -111,11 +91,11 @@ First create a test file according to your standard and adhere to the naming con
111
91
112
92
As an example, we will create a file for the fictitious standard "scs-0299-v1-example-standard.md" as follows:
113
93
114
-
```
94
+
```bash
115
95
touch scs_0299_v1_example_standard_test.go
116
96
```
117
97
118
-
In this file, we can define the behavior we want to test for.
98
+
In this file, we can define the behavior we want to test for.
119
99
As an example, we test here whether there are more than zero pods in the namespace "namespace-test-a".
120
100
The execution of this test should fail by default as there should be no pods in the namespace and the namespace itself should not exist.
121
101
The aim is to display the results of a failed test so that we can show their interpretation in a later step.
@@ -125,96 +105,94 @@ The aim is to display the results of a failed test so that we can show their int
125
105
126
106
Copy the following text into the file `scs_0299_v1_example_standard_test.go`:
0 commit comments