Skip to content

Commit 2d8c0fc

Browse files
authored
Merge pull request #360 from runkecheng/ginkgo_v2
e2e: Upgrade Ginkgo to V2 version.
2 parents 456e5e1 + 46b81cf commit 2d8c0fc

File tree

14 files changed

+337
-437
lines changed

14 files changed

+337
-437
lines changed

controllers/suite_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ import (
2020
"path/filepath"
2121
"testing"
2222

23-
. "github.com/onsi/ginkgo"
23+
. "github.com/onsi/ginkgo/v2"
2424
. "github.com/onsi/gomega"
2525
"k8s.io/client-go/kubernetes/scheme"
2626
"sigs.k8s.io/controller-runtime/pkg/client"
2727
"sigs.k8s.io/controller-runtime/pkg/envtest"
28-
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
2928
logf "sigs.k8s.io/controller-runtime/pkg/log"
3029
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3130

@@ -44,9 +43,7 @@ var (
4443
func TestAPIs(t *testing.T) {
4544
RegisterFailHandler(Fail)
4645

47-
RunSpecsWithDefaultAndCustomReporters(t,
48-
"Controller Suite",
49-
[]Reporter{printer.NewlineReporter{}})
46+
RunSpecs(t, "Controllers Suite")
5047
}
5148

5249
var _ = BeforeSuite(func() {
@@ -73,7 +70,7 @@ var _ = BeforeSuite(func() {
7370
k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
7471
Expect(err).NotTo(HaveOccurred())
7572
Expect(k8sClient).NotTo(BeNil())
76-
}, 60)
73+
})
7774

7875
var _ = AfterSuite(func() {
7976
By("tearing down the test environment")

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/golang/glog v1.0.0
1313
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
1414
github.com/imdario/mergo v0.3.12
15-
github.com/onsi/ginkgo v1.16.5
15+
github.com/onsi/ginkgo/v2 v2.0.0
1616
github.com/onsi/gomega v1.17.0
1717
github.com/presslabs/controller-util v0.3.0
1818
github.com/spf13/cobra v1.1.3

go.sum

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OI
200200
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
201201
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
202202
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
203+
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
203204
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
204205
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
205206
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
@@ -246,6 +247,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
246247
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 h1:ECW73yc9MY7935nNYXUkK7Dz17YuSUI9yqRqYS8aBww=
247248
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
248249
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
250+
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
249251
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
250252
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
251253
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
@@ -324,9 +326,10 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
324326
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
325327
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
326328
github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E=
329+
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
327330
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
328-
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
329-
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
331+
github.com/onsi/ginkgo/v2 v2.0.0 h1:CcuG/HvWNkkaqCUpJifQY8z7qEMBJya6aLPx6ftGyjQ=
332+
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
330333
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
331334
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
332335
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=

test/e2e/README.md

Lines changed: 25 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
## Prerequisites
44

5-
Prepare a client connected to K8S.
5+
- Prepare a client connected to K8S.
6+
- Make sure [Ginkgo V2](https://onsi.github.io/ginkgo/MIGRATING_TO_V2) is installed.
67

78
## Hands-on Lab
89

@@ -14,48 +15,28 @@ export KUBECONFIG=$HOME/.kube/config
1415

1516
### Step 2: Run test
1617

18+
> The Ginkgo version of the following examples is V2.
19+
20+
- Running all cases.
21+
22+
```
23+
ginkgo test/e2e/
24+
```
25+
26+
- Running all cases labeled `simplecase`.
27+
28+
```
29+
ginkgo --label-filter=simplecase test/e2e/
30+
```
31+
32+
- Skip the cases of describing information contains `Namespace`.
33+
34+
```
35+
ginkgo --skip "list namespace" test/e2e/
36+
```
37+
38+
- Just run the description information contains `Namespace`'s cases.
39+
1740
```
18-
make e2e-local
19-
```
20-
Example output of simplecase:
21-
```
22-
$ make e2e-local
23-
=== RUN TestE2E
24-
STEP: Creating framework with timeout: 1200
25-
Running Suite: MySQL Operator E2E Suite
26-
=======================================
27-
Random Seed: 1640785115 - Will randomize all specs
28-
Will run 1 of 1 specs
29-
30-
Namespece test
31-
test list namespace
32-
/home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/simplecase/list_namespace.go:38
33-
[BeforeEach] Namespece test
34-
/home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/framework/framework.go:62
35-
STEP: creating a kubernetes client
36-
STEP: create a namespace api object (e2e-mc-1-cnkbs)
37-
[BeforeEach] Namespece test
38-
/home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/simplecase/list_namespace.go:34
39-
STEP: before each
40-
[It] test list namespace
41-
/home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/simplecase/list_namespace.go:38
42-
default
43-
kube-public
44-
kube-system
45-
kubesphere-controls-system
46-
kubesphere-devops-system
47-
kubesphere-devops-worker
48-
kubesphere-monitoring-federated
49-
kubesphere-monitoring-system
50-
kubesphere-system
51-
radondb-mysql
52-
radondb-mysql-kubernetes-system
53-
[AfterEach] Namespece test
54-
/home/runkecheng/goCode/src/radondb-mysql-kubernetes/test/e2e/framework/framework.go:63
55-
STEP: Collecting logs
56-
STEP: Run cleanup actions
57-
STEP: Delete testing namespace
58-
59-
Ran 1 of 1 Specs in 0.743 seconds
60-
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
41+
ginkgo --focus "list namespace" test/e2e/
6142
```

test/e2e/e2e.go

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)