Skip to content

Commit c1b7052

Browse files
committed
e2e: Quick and simple test case.
1 parent 1585d97 commit c1b7052

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

test/e2e/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# How to run e2e test
2+
3+
## Prerequisites
4+
5+
Prepare a client connected to K8S.
6+
7+
## Hands-on Lab
8+
9+
### Step 1: Configure environment variables
10+
11+
```
12+
export KUBECONFIG=$HOME/.kube/config
13+
```
14+
15+
### Step 2: Run test
16+
17+
```
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
61+
```

test/e2e/simplecase/list_namespace.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2021 RadonDB.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package simplecase
18+
19+
import (
20+
"context"
21+
"fmt"
22+
23+
. "github.com/onsi/ginkgo"
24+
. "github.com/onsi/gomega"
25+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26+
27+
"github.com/radondb/radondb-mysql-kubernetes/test/e2e/framework"
28+
)
29+
30+
// Simple and quick test case, used to verify that the E2E framework is available.
31+
var _ = Describe("Namespece test", func() {
32+
f := framework.NewFramework("mc-1")
33+
34+
BeforeEach(func() {
35+
By("before each")
36+
})
37+
38+
It("test list namespace", func() {
39+
namespaces, err := f.ClientSet.CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{})
40+
Expect(err).Should(BeNil())
41+
Expect(len(namespaces.Items)).ShouldNot(BeZero())
42+
for _, ns := range namespaces.Items {
43+
fmt.Fprintln(GinkgoWriter, ns.Name)
44+
}
45+
})
46+
})

0 commit comments

Comments
 (0)