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
Copy file name to clipboardExpand all lines: e2e.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
This article outlines steps to run e2e tests on remote clusters for controllers created using `kubebuilder`. For example, after developing a database controller, the developer may want to run some e2e tests on a GKE cluster to verify the controller is working as expected. Currently, `kubebuilder` does not provide a template for running the e2e tests. This article serves to address this deficit.
4
4
5
5
The steps are as follow:
6
-
1. Create a test file named `<some-file-name>_test.go` populated with template below (refer[this](https://github.com/foxish/application/blob/master/e2e/main_test.go)):
6
+
1. Create a test file named `<some-file-name>_test.go` populated with template below (referring[this](https://github.com/foxish/application/blob/master/e2e/main_test.go)):
7
7
```
8
8
import (
9
9
"k8s.io/client-go/tools/clientcmd"
@@ -36,24 +36,22 @@ var _ = Describe("<some-controller-name> should work", func() {
36
36
}
37
37
38
38
BeforeEach(func() {
39
-
// Create controller image StatefulSet using kubernetes client
40
-
// Note: Refer `install.yaml` created via `kubebuilder create config`
41
-
// to have an idea on what the StatefulSet's fields should look like
42
-
......
43
-
44
-
// Create other necessary resources before starting each test
39
+
// Create environment-specific resources such as controller image StatefulSet,
40
+
// CRDs etc. Note: refer "install.yaml" created via "kubebuilder create config"
41
+
// command to have an idea of what resources to be created.
45
42
......
46
43
})
47
44
48
45
AfterEach(func() {
49
-
// Delete all created resources for testing purpose
46
+
// Delete all test-specific resources
50
47
......
51
48
52
-
// Delete controller image StatefulSet
49
+
// Delete all environment-specific resources
53
50
......
54
51
})
55
52
56
-
// Declare a list of testing specifications and corresponding test functions
53
+
// Declare a list of testing specifications with corresponding test functions
54
+
// Note: test-specific resources are normally created within the test functions
57
55
It("should do something", func() {
58
56
testDoSomething(k8sClient, roClient)
59
57
})
@@ -62,4 +60,4 @@ var _ = Describe("<some-controller-name> should work", func() {
62
60
```
63
61
2. Write some controller-specific e2e tests
64
62
3. Build controller image and upload it to an image storage website such as [gcr.io](https://cloud.google.com/container-registry/)
0 commit comments