Skip to content

Commit 7201f45

Browse files
committed
scripts: Implemented the first E2E test.
Clientset instance can be used to connect to cluster, manage resources. With clientset instance we can evaluate the posibility of moving other tests to OTE. The reference to OTE framework: https://docs.google.com/document/d/1cFZj9QdzW8hbHc3H0Nce-2xrJMtpDJrwAse9H7hLiWk/edit?tab=t.0#heading=h.8cf3f4eii1q8
1 parent e3ba184 commit 7201f45

File tree

3 files changed

+54
-5
lines changed

3 files changed

+54
-5
lines changed

.openshift-tests-extension/openshift_payload_cluster-version-operator.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
3-
"name": "[Jira:\"Cluster Version Operator\"] cluster-version-operator-tests should support passing tests",
3+
"name": "[Jira:\"Cluster Version Operator\"] cluster-version-operator-tests should support passing tests the sanity test should pass",
44
"labels": {},
55
"resources": {
66
"isolation": {}

cmd/cluster-version-operator-tests/README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@ It integrates [openshift-tests-extension](https://github.com/openshift-eng/opens
44
cluster-version-operator which allows openshift components to contribute tests to openshift-tests' suites with
55
extension binaries.
66

7+
## Build the executable binary
8+
In root folder, run below command to build executable binary:
9+
```console
10+
$ make build
11+
```
712

813
## Run the tests locally
914

10-
## Using the framework
15+
### Using the binary
16+
- run a test-suite
17+
```console
18+
$ _output/<OS>/<ARCH>/cluster-version-operator-tests run-suite <test suite name>
19+
```
20+
where test suites can be listed by `_output/<OS>/<ARCH>/cluster-version-operator-tests info`.
21+
22+
- run a single test case
1123
```console
12-
$ hack/build-go.sh
13-
$ _output/<OS>/<ARCH>/cluster-version-operator-tests run-suite cluster-version-operator
24+
$ _output/<OS>/<ARCH>/cluster-version-operator-tests run-test <test case name>
1425
```
26+
where test names can be listed by `_output/<OS>/<ARCH>/cluster-version-operator-tests list`.
1527

16-
## Using ginko-cli
28+
### Using ginko-cli
1729

1830
After [installing-ginkgo](https://onsi.github.io/ginkgo/#installing-ginkgo):
1931

test/utilities/connection.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package utilities
2+
3+
import (
4+
"errors"
5+
"fmt"
6+
"os"
7+
8+
"k8s.io/client-go/kubernetes"
9+
"k8s.io/client-go/tools/clientcmd"
10+
)
11+
12+
// getKubeClient creates a Kubernetes clientset.
13+
func getKubeClient() (*kubernetes.Clientset, error) {
14+
configPath, present := os.LookupEnv("KUBECONFIG")
15+
if !present {
16+
return nil, errors.New("the environment variable KUBECONFIG must be set")
17+
}
18+
config, err := clientcmd.BuildConfigFromFlags("", configPath)
19+
if err != nil {
20+
return nil, fmt.Errorf("unable to load build config: %w", err)
21+
}
22+
// Create the Clientset
23+
clientset, err := kubernetes.NewForConfig(config)
24+
if err != nil {
25+
return nil, fmt.Errorf("unable to create a Kubernetes clientset: %w", err)
26+
}
27+
return clientset, nil
28+
}
29+
30+
// MustGetKubeClient creates a Kubernetes clientset, or panics on failures.
31+
func MustGetKubeClient() *kubernetes.Clientset {
32+
clientset, err := getKubeClient()
33+
if err != nil {
34+
panic("unable to create a Kubernetes clientset: " + err.Error())
35+
}
36+
return clientset
37+
}

0 commit comments

Comments
 (0)