Skip to content

Commit eec94ae

Browse files
committed
fixup markdownlint findings
Signed-off-by: Toni Finger <toni.finger@cloudandheat.com>
1 parent e8d6556 commit eec94ae

File tree

1 file changed

+66
-88
lines changed

1 file changed

+66
-88
lines changed
Lines changed: 66 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
---
2-
title: SCS Conformance Test KaaS Sonobuoy
3-
type:
4-
status: Draft
5-
track: Global
6-
---
1+
# SCS Conformance Test KaaS Sonobuoy
72

83
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.
94
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
149
> A more detailed description of why the SCS has decided to use sonobuoys can be found on the corresponding [Decsision Record][sonbouy-decision-record].
1510
> In addition, sonobuoy is also used as the toolset for executing Kubernetes very own [conformance tests][k8s-conformance].
1611
17-
1812
This document is intended to assist conformance test authors to integrate their tests into the sonobuoy framework.
1913
This requires a user to write the conformance tests in Golang, as this is the language provided by the framework itself.
2014

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`
2316

2417
> This guide refers to the brief instructions provided in the [standards repository][scs-sonobuoy-example-guide]
2518
26-
27-
## Prerequisite
19+
### Prerequisite
2820

2921
* [docker][docker-installation]
3022
* [kind][kind-installation]
31-
* [sonobuoy][sonobuoy-installation]
23+
* [sonobuoy][sonobuoy-installation]
3224

33-
```
25+
```bash
3426
go install github.com/vmware-tanzu/sonobuoy@latest
3527
```
3628

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
4130

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`
4232

43-
```
33+
```bash
4434
git clone https://github.com/SovereignCloudStack/standards
4535
cd standards/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/
4636
```
4737

48-
49-
2. Check the prerequisites
38+
#### 2. Check the prerequisites
5039

5140
Within this directory you will find a `Makefile`, which is also used to create the test images.
5241
To begin with, this can be used to check whether all the requirements for the development environment are met.
5342

54-
```
43+
```bash
5544
make dev-prerequests
5645
```
5746

58-
59-
3. Create a kind cluster
47+
#### 3. Create a kind cluster
6048

6149
Once all the prerequisite software is installed, you can proceed by starting an kind cluster using the `Makefile` as follows:
6250

63-
```
51+
```bash
6452
make dev-setup
6553
```
6654

55+
#### 4. Setting environment variables for the image build process
6756

68-
4. Setting environment variables for the image build process
69-
70-
```
57+
```bash
7158
kubectl config view
7259
```
7360

74-
```
61+
```bash
7562
export IMAGE_VERSION_TAG="dev"
7663
export K8S_HOST=<kind-cluster-ip>
7764
export K8S_PORT=<kind-cluster-port>
7865
```
7966

80-
## Create a test:
81-
82-
83-
67+
### Create a test
8468

8569
In general, SCS tests for KaaS are derived from standards that define certain expected behaviors and functionalities of Kubernetes.
8670
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".
8771
Pretend that the fictitious standard here stipulates that at least one pod MUST run in the namespace "namespace-test-a".
8872

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.
9074
> 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.
9175
92-
93-
94-
95-
96-
1. Create example test
76+
#### 1. Create example test
9777

9878
The `scs_k8s_tests` directory contains the Golang files that define the tests.
9979

100-
```
80+
```bash
10181
cd standards/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework/scs_k8s_tests
10282
```
10383

@@ -111,11 +91,11 @@ First create a test file according to your standard and adhere to the naming con
11191
11292
As an example, we will create a file for the fictitious standard "scs-0299-v1-example-standard.md" as follows:
11393

114-
```
94+
```bash
11595
touch scs_0299_v1_example_standard_test.go
11696
```
11797

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.
11999
As an example, we test here whether there are more than zero pods in the namespace "namespace-test-a".
120100
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.
121101
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
125105
126106
Copy the following text into the file `scs_0299_v1_example_standard_test.go`:
127107

128-
```
108+
```go
129109
package scs_k8s_tests
130110

131111
import (
132-
"context"
133-
"testing"
134-
"time"
135-
"fmt"
136-
plugin_helper "github.com/vmware-tanzu/sonobuoy-plugins/plugin-helper"
137-
corev1 "k8s.io/api/core/v1"
138-
"sigs.k8s.io/e2e-framework/pkg/envconf"
139-
"sigs.k8s.io/e2e-framework/pkg/features"
112+
"context"
113+
"testing"
114+
//~ "time"
115+
//~ "fmt"
116+
//~ plugin_helper "github.com/vmware-tanzu/sonobuoy-plugins/plugin-helper"
117+
corev1 "k8s.io/api/core/v1"
118+
"sigs.k8s.io/e2e-framework/pkg/envconf"
119+
"sigs.k8s.io/e2e-framework/pkg/features"
140120
)
141121

142122

143123
// This function checks if there are any pods in 'namespace-test-a'.
144124
// The check should fail as there should be no pods present in this namespace.
145125
// The purpose of this function is to display the handling of failed tests.
146126
func Test_scs_0299_TestListPodsFailing(t *testing.T) {
147-
f := features.New("pod list").Assess(
148-
"pods from namespace 'namespace-test-a'",
149-
func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
150-
var pods corev1.PodList
151-
err := cfg.Client().Resources("namespace-test-a").List(context.TODO(), &pods)
152-
if err != nil {
153-
t.Fatal(err)
154-
}
155-
t.Logf("found %d pods", len(pods.Items))
156-
if len(pods.Items) == 0 {
157-
t.Fatal("no pods in namespace 'namespace-test-a'")
158-
}
159-
return ctx
160-
})
161-
162-
testenv.Test(t, f.Feature())
127+
f := features.New("pod list").Assess(
128+
"pods from namespace 'namespace-test-a'",
129+
func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
130+
var pods corev1.PodList
131+
err := cfg.Client().Resources("namespace-test-a").List(context.TODO(), &pods)
132+
if err != nil {
133+
t.Fatal(err)
134+
}
135+
t.Logf("found %d pods", len(pods.Items))
136+
if len(pods.Items) == 0 {
137+
t.Fatal("no pods in namespace 'namespace-test-a'")
138+
}
139+
return ctx
140+
})
141+
142+
testenv.Test(t, f.Feature())
163143
}
164144

165145
```
166146

167-
3. Build the test image, upload it to the art cluster and run it
168-
147+
#### 3. Build the test image, upload it to the art cluster and run it
169148

170149
To create the image, execute the following:
171-
```
150+
151+
```bash
172152
make dev-build
173153
```
174-
This creates the Sonobuoy image and automatically uploads it to the image register of the kind cluster.
175154

155+
This creates the Sonobuoy image and automatically uploads it to the image register of the kind cluster.
176156

177157
You can then run the tests by:
178-
```
158+
159+
```bash
179160
make dev-run
180161
```
181162

182-
Depending on how extensive the tests are, this may take some time.
163+
Depending on how extensive the tests are, this may take some time.
183164
To check the current test status manually, you can use the following command:
184165

185-
```
166+
```bash
186167
sonobuoy status
187168
```
188169

170+
#### 4. Retrieving the results
189171

190-
4. Retrieving the results
172+
```bash
173+
make dev-result
174+
cat results/plugins/scsconformance/results/global/out.json
175+
cat results/plugins/scsconformance/sonobuoy_results.yaml
176+
```
191177

192178
Once all tests have been executed successfully, you can read the results and receive feedback.
193179
You can call up the results as follows:
194180

195181
> TODO:!!! to be described in more detail
196182
197-
198-
199-
200-
## Clean up after:
183+
### Clean up after
201184

202185
To clean up the resourcec used for development, you can use the following commands:
203186

204-
```
187+
```bash
205188
make dev-clean
206189
make dev-purge
207190
```
208191

209-
210192
[sonobuoy]: https://sonobuoy.io/
211193
[sonbouy-decision-record]: https://github.com/SovereignCloudStack/standards/blob/main/Standards/scs-0200-v1-using-sonobuoy-for-kaas-conformance-tests.md
212194
[k8s-conformance]: https://github.com/cncf/k8s-conformance/blob/master/instructions.md
213-
214-
[kaas-sonobuoy-example] https://github.com/SovereignCloudStack/standards/tree/main/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework#sonobuoy-usage-for-development-of-tests
215-
216-
[docker-installation] https://docs.docker.com/engine/install/
217-
[sonobuoy-installation] https://sonobuoy.io/docs/v0.57.1/#installation
218-
[kind-installation]https://kind.sigs.k8s.io/docs/user/quick-start/#installation
219-
220-
[scs-sonobuoy-example-guide] https://github.com/SovereignCloudStack/standards/tree/main/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework#sonobuoy-usage-for-development-of-tests
195+
[docker-installation]: https://docs.docker.com/engine/install/
196+
[sonobuoy-installation]: https://sonobuoy.io/docs/v0.57.1/#installation
197+
[kind-installation]: https://kind.sigs.k8s.io/docs/user/quick-start/#installation
198+
[scs-sonobuoy-example-guide]: https://github.com/SovereignCloudStack/standards/tree/main/Tests/kaas/kaas-sonobuoy-go-example-e2e-framework#sonobuoy-usage-for-development-of-tests

0 commit comments

Comments
 (0)