Unverified Commit 97c69546 authored by ShylajaDevadiga's avatar ShylajaDevadiga Committed by GitHub

add arm tests and upgrade tests (#5526)

parent a693071c
...@@ -19,7 +19,8 @@ RUN apk update && \ ...@@ -19,7 +19,8 @@ RUN apk update && \
WORKDIR $GOPATH/src/github.com/k3s-io/k3s WORKDIR $GOPATH/src/github.com/k3s-io/k3s
COPY . . COPY . .
RUN go install github.com/gruntwork-io/terratest/modules/terraform RUN go get github.com/gruntwork-io/terratest/modules/terraform
RUN go install -u github.com/onsi/gomega RUN go get -u github.com/onsi/gomega
RUN go install -u github.com/onsi/ginkgo/v2 RUN go get -u github.com/onsi/ginkgo/v2
RUN go install -u golang.org/x/crypto/... RUN go get -u golang.org/x/crypto/...
RUN go get -u github.com/Thatooine/go-test-html-report
apiVersion: extensions/v1beta1 apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
name: ingress name: test-ingress
spec: spec:
rules: rules:
- host: foo1.bar.com - host: foo1.bar.com
http: http:
paths: paths:
- path: /name.html - backend:
backend: service:
serviceName: nginx-ingress-svc name: nginx-ingress-svc
servicePort: 80 port:
number: 80
path: /
pathType: ImplementationSpecific
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: nginx-ingress-svc name: nginx-ingress-svc
labels: labels:
k8s-app: nginx-app-ingress k8s-app: nginx-app-ingress
spec: spec:
ports: ports:
- port: 80 - port: 80
targetPort: 80 targetPort: 80
protocol: TCP protocol: TCP
name: http name: http
selector: selector:
k8s-app: nginx-app-ingress k8s-app: nginx-app-ingress
--- ---
apiVersion: v1 apiVersion: v1
kind: ReplicationController kind: ReplicationController
metadata: metadata:
name: test-ingress name: test-ingress
spec: spec:
replicas: 2 replicas: 2
selector: selector:
k8s-app: nginx-app-ingress k8s-app: nginx-app-ingress
template: template:
metadata: metadata:
labels: labels:
k8s-app: nginx-app-ingress k8s-app: nginx-app-ingress
spec: spec:
terminationGracePeriodSeconds: 60 terminationGracePeriodSeconds: 60
containers: containers:
- name: testcontainer - name: testcontainer
image: shylajarancher19/shylajaarm64:v1.0 image: shylajarancher19/shylajaarm64:v1.0
ports: ports:
- containerPort: 80 - containerPort: 80
...@@ -3,6 +3,7 @@ package e2e ...@@ -3,6 +3,7 @@ package e2e
import ( import (
"flag" "flag"
"fmt" "fmt"
"path/filepath" "path/filepath"
"testing" "testing"
...@@ -17,6 +18,7 @@ var clusterType = flag.String("cluster_type", "etcd", "a string") ...@@ -17,6 +18,7 @@ var clusterType = flag.String("cluster_type", "etcd", "a string")
var resourceName = flag.String("resource_name", "etcd", "a string") var resourceName = flag.String("resource_name", "etcd", "a string")
var sshuser = flag.String("sshuser", "ubuntu", "a string") var sshuser = flag.String("sshuser", "ubuntu", "a string")
var sshkey = flag.String("sshkey", "", "a string") var sshkey = flag.String("sshkey", "", "a string")
var failed = false
var ( var (
kubeConfigFile string kubeConfigFile string
...@@ -24,8 +26,7 @@ var ( ...@@ -24,8 +26,7 @@ var (
workerIPs string workerIPs string
) )
func BuildCluster(nodeOs, clusterType, externalDb, resourceName string, t *testing.T, destroy bool) (string, string, string, error) { func BuildCluster(nodeOs, clusterType, externalDb, resourceName string, t *testing.T, destroy bool, arch string) (string, string, string, error) {
tDir := "./modules/k3scluster" tDir := "./modules/k3scluster"
vDir := "/config/" + nodeOs + clusterType + ".tfvars" vDir := "/config/" + nodeOs + clusterType + ".tfvars"
......
...@@ -14,19 +14,16 @@ import ( ...@@ -14,19 +14,16 @@ import (
func Test_E2EClusterCreateValidation(t *testing.T) { func Test_E2EClusterCreateValidation(t *testing.T) {
RegisterFailHandler(Fail) RegisterFailHandler(Fail)
flag.Parse() flag.Parse()
RunSpecs(t, "Create Cluster Test Suite") RunSpecs(t, "Create Cluster Test Suite")
} }
var _ = Describe("Test:", func() { var _ = Describe("Test:", func() {
Context("Build Cluster:", func() { Context("Build Cluster:", func() {
It("Starts up with no issues", func() { It("Starts up with no issues", func() {
kubeConfigFile, masterIPs, workerIPs, err = BuildCluster(*nodeOs, *clusterType, *externalDb, *resourceName, &testing.T{}, *destroy) kubeConfigFile, masterIPs, workerIPs, err = BuildCluster(*nodeOs, *clusterType, *externalDb, *resourceName, &testing.T{}, *destroy, *arch)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
defer GinkgoRecover() defer GinkgoRecover()
if *destroy {
fmt.Printf("\nCluster is being Deleted\n")
return
}
fmt.Println("\nCLUSTER CONFIG:\nOS", *nodeOs, "BACKEND", *clusterType, *externalDb) fmt.Println("\nCLUSTER CONFIG:\nOS", *nodeOs, "BACKEND", *clusterType, *externalDb)
fmt.Printf("\nIPs:\n") fmt.Printf("\nIPs:\n")
fmt.Println("Server Node IPS:", masterIPs) fmt.Println("Server Node IPS:", masterIPs)
...@@ -62,7 +59,7 @@ var _ = Describe("Test:", func() { ...@@ -62,7 +59,7 @@ var _ = Describe("Test:", func() {
}) })
It("Verifies ClusterIP Service", func() { It("Verifies ClusterIP Service", func() {
_, err := DeployWorkload("clusterip.yaml", kubeConfigFile, false) _, err := DeployWorkload("clusterip.yaml", kubeConfigFile, *arch)
Expect(err).NotTo(HaveOccurred(), "Cluster IP manifest not deployed") Expect(err).NotTo(HaveOccurred(), "Cluster IP manifest not deployed")
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
...@@ -81,13 +78,13 @@ var _ = Describe("Test:", func() { ...@@ -81,13 +78,13 @@ var _ = Describe("Test:", func() {
res, err := RunCmdOnNode(cmd, ip, *sshuser, *sshkey) res, err := RunCmdOnNode(cmd, ip, *sshuser, *sshkey)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
g.Expect(res).Should(ContainSubstring("test-clusterip")) g.Expect(res).Should(ContainSubstring("test-clusterip"))
fmt.Println(res)
}, "420s", "10s").Should(Succeed()) }, "420s", "10s").Should(Succeed())
} }
}) })
It("Verifies NodePort Service", func() { It("Verifies NodePort Service", func() {
_, err := DeployWorkload("nodeport.yaml", kubeConfigFile, false) _, err := DeployWorkload("nodeport.yaml", kubeConfigFile, *arch)
Expect(err).NotTo(HaveOccurred(), "NodePort manifest not deployed") Expect(err).NotTo(HaveOccurred(), "NodePort manifest not deployed")
nodeExternalIP := FetchNodeExternalIP(kubeConfigFile) nodeExternalIP := FetchNodeExternalIP(kubeConfigFile)
cmd := "kubectl get service nginx-nodeport-svc --kubeconfig=" + kubeConfigFile + " --output jsonpath=\"{.spec.ports[0].nodePort}\"" cmd := "kubectl get service nginx-nodeport-svc --kubeconfig=" + kubeConfigFile + " --output jsonpath=\"{.spec.ports[0].nodePort}\""
...@@ -109,12 +106,13 @@ var _ = Describe("Test:", func() { ...@@ -109,12 +106,13 @@ var _ = Describe("Test:", func() {
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
fmt.Println(res) fmt.Println(res)
g.Expect(res).Should(ContainSubstring("test-nodeport")) g.Expect(res).Should(ContainSubstring("test-nodeport"))
fmt.Println(res)
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
} }
}) })
It("Verifies LoadBalancer Service", func() { It("Verifies LoadBalancer Service", func() {
_, err := DeployWorkload("loadbalancer.yaml", kubeConfigFile, false) _, err := DeployWorkload("loadbalancer.yaml", kubeConfigFile, *arch)
Expect(err).NotTo(HaveOccurred(), "Loadbalancer manifest not deployed") Expect(err).NotTo(HaveOccurred(), "Loadbalancer manifest not deployed")
nodeExternalIP := FetchNodeExternalIP(kubeConfigFile) nodeExternalIP := FetchNodeExternalIP(kubeConfigFile)
cmd := "kubectl get service nginx-loadbalancer-svc --kubeconfig=" + kubeConfigFile + " --output jsonpath=\"{.spec.ports[0].port}\"" cmd := "kubectl get service nginx-loadbalancer-svc --kubeconfig=" + kubeConfigFile + " --output jsonpath=\"{.spec.ports[0].port}\""
...@@ -136,12 +134,13 @@ var _ = Describe("Test:", func() { ...@@ -136,12 +134,13 @@ var _ = Describe("Test:", func() {
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
fmt.Println(res) fmt.Println(res)
g.Expect(res).Should(ContainSubstring("test-loadbalancer")) g.Expect(res).Should(ContainSubstring("test-loadbalancer"))
fmt.Println(res)
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
} }
}) })
It("Verifies Ingress", func() { It("Verifies Ingress", func() {
_, err := DeployWorkload("ingress.yaml", kubeConfigFile, false) _, err := DeployWorkload("ingress.yaml", kubeConfigFile, *arch)
Expect(err).NotTo(HaveOccurred(), "Ingress manifest not deployed") Expect(err).NotTo(HaveOccurred(), "Ingress manifest not deployed")
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
...@@ -162,12 +161,13 @@ var _ = Describe("Test:", func() { ...@@ -162,12 +161,13 @@ var _ = Describe("Test:", func() {
res, err := RunCommand(cmd) res, err := RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
g.Expect(res).Should(ContainSubstring("test-ingress")) g.Expect(res).Should(ContainSubstring("test-ingress"))
fmt.Println(res)
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
} }
}) })
It("Verifies Daemonset", func() { It("Verifies Daemonset", func() {
_, err := DeployWorkload("daemonset.yaml", kubeConfigFile, false) _, err := DeployWorkload("daemonset.yaml", kubeConfigFile, *arch)
Expect(err).NotTo(HaveOccurred(), "Daemonset manifest not deployed") Expect(err).NotTo(HaveOccurred(), "Daemonset manifest not deployed")
nodes, _ := ParseNodes(kubeConfigFile, false) nodes, _ := ParseNodes(kubeConfigFile, false)
...@@ -184,7 +184,7 @@ var _ = Describe("Test:", func() { ...@@ -184,7 +184,7 @@ var _ = Describe("Test:", func() {
}) })
It("Verifies Local Path Provisioner storage ", func() { It("Verifies Local Path Provisioner storage ", func() {
_, err := DeployWorkload("local-path-provisioner.yaml", kubeConfigFile, false) _, err := DeployWorkload("local-path-provisioner.yaml", kubeConfigFile, *arch)
Expect(err).NotTo(HaveOccurred(), "local-path-provisioner manifest not deployed") Expect(err).NotTo(HaveOccurred(), "local-path-provisioner manifest not deployed")
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
...@@ -200,7 +200,6 @@ var _ = Describe("Test:", func() { ...@@ -200,7 +200,6 @@ var _ = Describe("Test:", func() {
cmd := "kubectl get pod volume-test --kubeconfig=" + kubeConfigFile cmd := "kubectl get pod volume-test --kubeconfig=" + kubeConfigFile
res, err := RunCommand(cmd) res, err := RunCommand(cmd)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
fmt.Println(res)
g.Expect(res).Should(ContainSubstring("volume-test")) g.Expect(res).Should(ContainSubstring("volume-test"))
g.Expect(res).Should(ContainSubstring("Running")) g.Expect(res).Should(ContainSubstring("Running"))
}, "420s", "2s").Should(Succeed()) }, "420s", "2s").Should(Succeed())
...@@ -215,7 +214,7 @@ var _ = Describe("Test:", func() { ...@@ -215,7 +214,7 @@ var _ = Describe("Test:", func() {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
fmt.Println(res) fmt.Println(res)
_, err = DeployWorkload("local-path-provisioner.yaml", kubeConfigFile, false) _, err = DeployWorkload("local-path-provisioner.yaml", kubeConfigFile, *arch)
Expect(err).NotTo(HaveOccurred(), "local-path-provisioner manifest not deployed") Expect(err).NotTo(HaveOccurred(), "local-path-provisioner manifest not deployed")
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
...@@ -244,7 +243,7 @@ var _ = Describe("Test:", func() { ...@@ -244,7 +243,7 @@ var _ = Describe("Test:", func() {
}) })
It("Verifies dns access", func() { It("Verifies dns access", func() {
_, err := DeployWorkload("dnsutils.yaml", kubeConfigFile, false) _, err := DeployWorkload("dnsutils.yaml", kubeConfigFile, *arch)
Expect(err).NotTo(HaveOccurred(), "dnsutils manifest not deployed") Expect(err).NotTo(HaveOccurred(), "dnsutils manifest not deployed")
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
...@@ -260,15 +259,11 @@ var _ = Describe("Test:", func() { ...@@ -260,15 +259,11 @@ var _ = Describe("Test:", func() {
res, _ := RunCommand(cmd) res, _ := RunCommand(cmd)
fmt.Println(res) fmt.Println(res)
g.Expect(res).Should(ContainSubstring("kubernetes.default.svc.cluster.local")) g.Expect(res).Should(ContainSubstring("kubernetes.default.svc.cluster.local"))
fmt.Println(res)
}, "420s", "2s").Should(Succeed()) }, "420s", "2s").Should(Succeed())
}) })
It("Validate Rebooting nodes", func() { It("Validate Rebooting nodes", func() {
if *destroy {
return
}
defer GinkgoRecover()
nodeExternalIP := FetchNodeExternalIP(kubeConfigFile) nodeExternalIP := FetchNodeExternalIP(kubeConfigFile)
for _, ip := range nodeExternalIP { for _, ip := range nodeExternalIP {
fmt.Println("\nRebooting node: ", ip) fmt.Println("\nRebooting node: ", ip)
...@@ -303,16 +298,23 @@ var _ = Describe("Test:", func() { ...@@ -303,16 +298,23 @@ var _ = Describe("Test:", func() {
}) })
}) })
var failed = false
var _ = AfterEach(func() { var _ = AfterEach(func() {
failed = failed || CurrentGinkgoTestDescription().Failed failed = failed || CurrentGinkgoTestDescription().Failed
}) })
var _ = BeforeEach(func() {
failed = failed || CurrentGinkgoTestDescription().Failed
if *destroy {
fmt.Printf("\nCluster is being Deleted\n")
Skip("Cluster is being Deleted")
}
})
var _ = AfterSuite(func() { var _ = AfterSuite(func() {
if failed { if failed {
fmt.Println("FAILED!") fmt.Println("FAILED!")
} else { } else {
kubeConfigFile, masterIPs, workerIPs, err = BuildCluster(*nodeOs, *clusterType, *externalDb, *resourceName, &testing.T{}, true) kubeConfigFile, masterIPs, workerIPs, err = BuildCluster(*nodeOs, *clusterType, *externalDb, *resourceName, &testing.T{}, true, *arch)
if err != nil { if err != nil {
fmt.Println("Error Destroying Cluster", err) fmt.Println("Error Destroying Cluster", err)
} }
......
...@@ -34,16 +34,16 @@ pipeline { ...@@ -34,16 +34,16 @@ pipeline {
vpc_id="${env.VPC_ID}" vpc_id="${env.VPC_ID}"
subnets="${env.SUBNETS}" subnets="${env.SUBNETS}"
qa_space="${env.QA_SPACE}" qa_space="${env.QA_SPACE}"
ec2_instance_class="${env.EC2_INSTANCE_CLASS}" ec2_instance_class="${env.AWS_INSTANCE_TYPE}"
access_key="/config/$AWS_SSH_KEY_NAME" access_key="/config/$AWS_SSH_KEY_NAME"
no_of_worker_nodes="${env.NO_OF_WORKER_NODES}" no_of_worker_nodes="${env.NO_OF_WORKER_NODES}"
key_name="jenkins-rke-validation" key_name="jenkins-rke-validation"
server_flags="${env.SERVER_FLAGS}" server_flags="${env.K3S_SERVER_FLAGS}"
worker_flags="${env.WORKER_FLAGS}" worker_flags="${env.K3S_WORKER_FLAGS}"
k3s_version="${env.K3S_VERSION}" k3s_version="${env.K3S_VERSION}"
availability_zone="${env.AVAILABILITY_ZONE}" availability_zone="${env.AVAILABILITY_ZONE}"
sg_id="${env.SG_ID}" sg_id="${env.SG_ID}"
install_mode="${env.INSTALL_MODE}" install_mode="${env.K3S_INSTALL_MODE}"
resource_name="${env.RESOURCE_NAME}" resource_name="${env.RESOURCE_NAME}"
no_of_server_nodes="${env.NO_OF_SERVER_NODES}" no_of_server_nodes="${env.NO_OF_SERVER_NODES}"
username="${env.RHEL_USERNAME}" username="${env.RHEL_USERNAME}"
...@@ -51,8 +51,8 @@ pipeline { ...@@ -51,8 +51,8 @@ pipeline {
db_username="${env.DB_USERNAME}" db_username="${env.DB_USERNAME}"
db_password="${env.DB_PASSWORD}" db_password="${env.DB_PASSWORD}"
node_os="${env.NODE_OS}" node_os="${env.NODE_OS}"
environment="${env.ENVIRONMENT}" environment="${env.DB_ENVIRONMENT}"
engine_mode="${env.ENGINE_MODE}" engine_mode="${env.DB_ENGINE_MODE}"
external_db="${env.EXTERNAL_DB}" external_db="${env.EXTERNAL_DB}"
external_db_version="${env.EXTERNAL_DB_VERSION}" external_db_version="${env.EXTERNAL_DB_VERSION}"
instance_class="${env.DB_INSTANCE_CLASS}" instance_class="${env.DB_INSTANCE_CLASS}"
......
...@@ -17,6 +17,7 @@ type Node struct { ...@@ -17,6 +17,7 @@ type Node struct {
Name string Name string
Status string Status string
Roles string Roles string
Version string
InternalIP string InternalIP string
ExternalIP string ExternalIP string
} }
...@@ -92,7 +93,6 @@ func runsshCommand(cmd string, conn *ssh.Client) (string, error) { ...@@ -92,7 +93,6 @@ func runsshCommand(cmd string, conn *ssh.Client) (string, error) {
// RunCmdOnNode executes a command from within the given node // RunCmdOnNode executes a command from within the given node
func RunCmdOnNode(cmd string, ServerIP string, SSHUser string, SSHKey string) (string, error) { func RunCmdOnNode(cmd string, ServerIP string, SSHUser string, SSHKey string) (string, error) {
Server := ServerIP + ":22" Server := ServerIP + ":22"
fmt.Println(Server, SSHUser, SSHKey)
conn := ConfigureSSH(Server, SSHUser, SSHKey) conn := ConfigureSSH(Server, SSHUser, SSHKey)
res, err := runsshCommand(cmd, conn) res, err := runsshCommand(cmd, conn)
res = strings.TrimSpace(res) res = strings.TrimSpace(res)
...@@ -117,10 +117,10 @@ func CountOfStringInSlice(str string, pods []Pod) int { ...@@ -117,10 +117,10 @@ func CountOfStringInSlice(str string, pods []Pod) int {
return count return count
} }
func DeployWorkload(workload, kubeconfig string, arch bool) (string, error) { func DeployWorkload(workload, kubeconfig string, arch string) (string, error) {
resourceDir := "./amd64_resource_files" resourceDir := "./amd64_resource_files"
if arch { if arch == "arm64" {
resourceDir = "./arm64_resource_files" resourceDir = "./arm_resource_files"
} }
files, err := ioutil.ReadDir(resourceDir) files, err := ioutil.ReadDir(resourceDir)
if err != nil { if err != nil {
...@@ -186,6 +186,7 @@ func ParseNodes(kubeConfig string, print bool) ([]Node, error) { ...@@ -186,6 +186,7 @@ func ParseNodes(kubeConfig string, print bool) ([]Node, error) {
Name: fields[0], Name: fields[0],
Status: fields[1], Status: fields[1],
Roles: fields[2], Roles: fields[2],
Version: fields[4],
InternalIP: fields[5], InternalIP: fields[5],
ExternalIP: fields[6], ExternalIP: fields[6],
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment