-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathkubean_bol2_test.go
50 lines (43 loc) · 1.84 KB
/
kubean_bol2_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package kubeanOps_functions_nightlye2e
import (
"context"
"fmt"
"os/exec"
"path/filepath"
"runtime"
"time"
"github.com/kubean-io/kubean/test/tools"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
)
var _ = ginkgo.Describe("kubean ops e2e test for backofflimit=2", func() {
config, err := clientcmd.BuildConfigFromFlags("", tools.Kubeconfig)
gomega.ExpectWithOffset(2, err).NotTo(gomega.HaveOccurred(), "failed build config")
var _, currentFile, _, _ = runtime.Caller(0)
var basepath = filepath.Dir(currentFile)
kubeanNamespace := "kubean-system"
ginkgo.Context("when installation fail then retry, set backofflimit=2", func() {
opsFile := filepath.Join(basepath, "/backofflimit-clusterops/kubeanClusterOps.yml")
kubeanClusterOpsNewName := "backofflimit2-clusterops-test"
tools.UpdateOpsYml(kubeanClusterOpsNewName, opsFile)
tools.UpdateBackoffLimit(2, opsFile)
clusterInstallYamlsPath := "backofflimit-clusterops"
installYamlPath := fmt.Sprint(tools.GetKuBeanPath(), clusterInstallYamlsPath)
cmd := exec.Command("kubectl", "--kubeconfig="+tools.Kubeconfig, "apply", "-f", installYamlPath)
out, _ := tools.DoCmd(*cmd)
fmt.Println("backoffLimit=2 kubeanclusterOps: ", out.String())
time.Sleep(150 * time.Second)
kubeClient, err := kubernetes.NewForConfig(config)
gomega.ExpectWithOffset(2, err).NotTo(gomega.HaveOccurred(), "failed new client set")
pods, _ := kubeClient.CoreV1().Pods(kubeanNamespace).List(context.Background(), metav1.ListOptions{
LabelSelector: fmt.Sprintf("job-name=kubean-%s-job", kubeanClusterOpsNewName),
})
fmt.Println(len(pods.Items))
ginkgo.It("there is 3 kubeanclusterops related pod", func() {
gomega.Expect(len(pods.Items)).Should(gomega.BeNumerically("==", 3))
})
})
})