mirror of
https://github.com/outbackdingo/kamaji.git
synced 2026-01-27 10:19:29 +00:00
feat(e2e): reporting tcp status and resources in case of failed test
This commit is contained in:
@@ -5,23 +5,48 @@ metadata:
|
||||
spec:
|
||||
controlPlane:
|
||||
deployment:
|
||||
replicas: 1
|
||||
replicas: 2
|
||||
additionalMetadata:
|
||||
annotations:
|
||||
environment.clastix.io: test
|
||||
tier.clastix.io: "0"
|
||||
labels:
|
||||
tenant.clastix.io: test
|
||||
kind.clastix.io: deployment
|
||||
service:
|
||||
additionalMetadata:
|
||||
annotations:
|
||||
environment.clastix.io: test
|
||||
tier.clastix.io: "0"
|
||||
labels:
|
||||
tenant.clastix.io: test
|
||||
kind.clastix.io: service
|
||||
serviceType: LoadBalancer
|
||||
ingress:
|
||||
enabled: false
|
||||
enabled: true
|
||||
hostname: kamaji.local
|
||||
ingressClassName: nginx
|
||||
additionalMetadata:
|
||||
annotations:
|
||||
kubernetes.io/ingress.allow-http: "false"
|
||||
nginx.ingress.kubernetes.io/secure-backends: "true"
|
||||
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
|
||||
kubernetes:
|
||||
version: "v1.23.1"
|
||||
kubelet:
|
||||
cgroupfs: cgroupfs
|
||||
cgroupfs: systemd
|
||||
admissionControllers:
|
||||
- ResourceQuota
|
||||
- LimitRanger
|
||||
networkProfile:
|
||||
address: "127.0.0.1"
|
||||
port: 6443
|
||||
certSANs:
|
||||
- "test.clastix.labs"
|
||||
serviceCidr: "10.96.0.0/16"
|
||||
podCidr: "10.244.0.0/16"
|
||||
dnsServiceIPs:
|
||||
- "10.96.0.10"
|
||||
addons:
|
||||
coreDNS: {}
|
||||
kubeProxy: {}
|
||||
konnectivity:
|
||||
proxyPort: 8134
|
||||
serviceType: LoadBalancer
|
||||
@@ -59,6 +59,7 @@ var _ = Describe("Deploy a TenantControlPlane resource", func() {
|
||||
|
||||
// Delete the TenantControlPlane resource after test is finished
|
||||
JustAfterEach(func() {
|
||||
PrintTenantControlPlaneInfo(&tcp)
|
||||
PrintKamajiLogs()
|
||||
Expect(k8sClient.Delete(context.Background(), &tcp)).Should(Succeed())
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os/exec"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
@@ -15,6 +16,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||
)
|
||||
|
||||
func GetKindIPAddress() string {
|
||||
@@ -24,6 +27,49 @@ func GetKindIPAddress() string {
|
||||
return ep.Subsets[0].Addresses[0].IP
|
||||
}
|
||||
|
||||
func PrintTenantControlPlaneInfo(tcp *kamajiv1alpha1.TenantControlPlane) {
|
||||
kubectlExec := func(args ...string) {
|
||||
cmd := exec.Command("kubectl")
|
||||
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
cmd.Args = args
|
||||
|
||||
Expect(cmd.Run()).ToNot(HaveOccurred())
|
||||
|
||||
for {
|
||||
line, err := out.ReadString('\n')
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprint(GinkgoWriter, ">>> ", line)
|
||||
}
|
||||
}
|
||||
|
||||
if CurrentGinkgoTestDescription().Failed {
|
||||
_, _ = fmt.Fprintln(GinkgoWriter, "DEBUG: Tenant Control Plane definition")
|
||||
kubectlExec(
|
||||
fmt.Sprintf("--namespace=%s", tcp.GetNamespace()),
|
||||
"get",
|
||||
"tcp",
|
||||
tcp.GetName(),
|
||||
)
|
||||
_, _ = fmt.Fprintln(GinkgoWriter, "DEBUG: Tenant Control Plane resources")
|
||||
kubectlExec(
|
||||
fmt.Sprintf("--namespace=%s", tcp.GetNamespace()),
|
||||
"get",
|
||||
"svc,deployment,pods,ep,configmap,secrets",
|
||||
)
|
||||
_, _ = fmt.Fprintln(GinkgoWriter, "DEBUG: Tenant Control Plane pods")
|
||||
kubectlExec(
|
||||
fmt.Sprintf("--namespace=%s", tcp.GetNamespace()),
|
||||
"describe",
|
||||
"pods",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func PrintKamajiLogs() {
|
||||
if CurrentGinkgoTestDescription().Failed {
|
||||
clientset, err := kubernetes.NewForConfig(cfg)
|
||||
|
||||
@@ -92,6 +92,7 @@ var _ = Describe("starting a kind worker with kubeadm", func() {
|
||||
})
|
||||
|
||||
JustAfterEach(func() {
|
||||
PrintTenantControlPlaneInfo(&tcp)
|
||||
PrintKamajiLogs()
|
||||
Expect(workerContainer.Terminate(ctx)).ToNot(HaveOccurred())
|
||||
Expect(k8sClient.Delete(ctx, &tcp)).Should(Succeed())
|
||||
|
||||
@@ -50,7 +50,7 @@ var _ = Describe("validating kubeconfig", func() {
|
||||
},
|
||||
NetworkProfile: kamajiv1alpha1.NetworkProfileSpec{
|
||||
Address: GetKindIPAddress(),
|
||||
Port: 31443,
|
||||
Port: 30001,
|
||||
},
|
||||
Kubernetes: kamajiv1alpha1.KubernetesSpec{
|
||||
Version: "v1.23.6",
|
||||
@@ -75,12 +75,13 @@ var _ = Describe("validating kubeconfig", func() {
|
||||
|
||||
JustAfterEach(func() {
|
||||
PrintKamajiLogs()
|
||||
PrintTenantControlPlaneInfo(tcp)
|
||||
Expect(k8sClient.Delete(ctx, tcp)).Should(Succeed())
|
||||
Expect(os.Remove(kubeconfigFile.Name())).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
It("return kubernetes version", func() {
|
||||
for _, port := range []int32{31444, 31445, 31446} {
|
||||
for _, port := range []int32{30002, 30003, 30004} {
|
||||
Eventually(func() string {
|
||||
By(fmt.Sprintf("ensuring TCP port is set to %d", port), func() {
|
||||
Eventually(func() (err error) {
|
||||
@@ -158,7 +159,7 @@ var _ = Describe("validating kubeconfig", func() {
|
||||
})
|
||||
|
||||
return version.GitVersion
|
||||
}, 5*time.Minute, 5*time.Second).Should(Equal(tcp.Spec.Kubernetes.Version))
|
||||
}, 3*time.Minute, 5*time.Second).Should(Equal(tcp.Spec.Kubernetes.Version))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user