-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Install a simple application and check it in different upgrade scenari. Signed-off-by: Loic Devulder <ldevulder@suse.com>
- Loading branch information
Showing
7 changed files
with
282 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
annotations: | ||
labels: | ||
workload.user.cattle.io/workloadselector: apps.deployment-default-hello-world | ||
app: hello-world | ||
name: hello-world | ||
namespace: default | ||
spec: | ||
progressDeadlineSeconds: 600 | ||
replicas: 3 | ||
revisionHistoryLimit: 10 | ||
selector: | ||
matchLabels: | ||
workload.user.cattle.io/workloadselector: apps.deployment-default-hello-world | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 25% | ||
maxUnavailable: 25% | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
workload.user.cattle.io/workloadselector: apps.deployment-default-hello-world | ||
namespace: default | ||
spec: | ||
containers: | ||
- image: rancher/hello-world | ||
imagePullPolicy: Always | ||
name: container-0 | ||
ports: | ||
- containerPort: 80 | ||
name: 80tcp8080 | ||
protocol: TCP | ||
resources: {} | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
privileged: false | ||
readOnlyRootFilesystem: false | ||
runAsNonRoot: false | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
schedulerName: default-scheduler | ||
securityContext: {} | ||
terminationGracePeriodSeconds: 30 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
field.cattle.io/targetWorkloadIds: '["default/hello-world"]' | ||
management.cattle.io/ui-managed: "true" | ||
name: hello-world | ||
namespace: default | ||
spec: | ||
internalTrafficPolicy: Cluster | ||
ipFamilies: | ||
- IPv4 | ||
ipFamilyPolicy: SingleStack | ||
ports: | ||
- name: 80tcp8080 | ||
port: 80 | ||
protocol: TCP | ||
targetPort: 80 | ||
selector: | ||
workload.user.cattle.io/workloadselector: apps.deployment-default-hello-world | ||
sessionAffinity: None | ||
type: ClusterIP | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
cloudprovider.harvesterhci.io/ipam: dhcp | ||
field.cattle.io/targetWorkloadIds: '["default/hello-world"]' | ||
management.cattle.io/ui-managed: "true" | ||
finalizers: | ||
- service.kubernetes.io/load-balancer-cleanup | ||
name: hello-world-loadbalancer | ||
namespace: default | ||
spec: | ||
allocateLoadBalancerNodePorts: true | ||
externalTrafficPolicy: Cluster | ||
internalTrafficPolicy: Cluster | ||
ipFamilies: | ||
- IPv4 | ||
ipFamilyPolicy: SingleStack | ||
ports: | ||
- name: 80tcp8080 | ||
port: 8080 | ||
protocol: TCP | ||
targetPort: 80 | ||
selector: | ||
workload.user.cattle.io/workloadselector: apps.deployment-default-hello-world | ||
sessionAffinity: None | ||
type: LoadBalancer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
Copyright © 2023 SUSE LLC | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e_test | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"strings" | ||
"time" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/rancher-sandbox/ele-testhelpers/kubectl" | ||
"github.com/rancher/elemental/tests/e2e/helpers/misc" | ||
) | ||
|
||
var _ = Describe("E2E - Install a simple application", Label("install-app"), func() { | ||
It("Install HelloWorld application", func() { | ||
kubeConfig, err := misc.SetClientKubeConfig(clusterNS, clusterName) | ||
defer os.Remove(kubeConfig) | ||
Expect(err).To(Not(HaveOccurred())) | ||
|
||
By("Installing application", func() { | ||
err := kubectl.Apply("default", appYaml) | ||
Expect(err).To(Not(HaveOccurred())) | ||
}) | ||
}) | ||
}) | ||
|
||
var _ = Describe("E2E - Checking a simple application", Label("check-app"), func() { | ||
It("Check HelloWorld application", func() { | ||
appName := "hello-world" | ||
|
||
// File where to host client cluster kubeconfig | ||
kubeConfig, err := misc.SetClientKubeConfig(clusterNS, clusterName) | ||
defer os.Remove(kubeConfig) | ||
Expect(err).To(Not(HaveOccurred())) | ||
|
||
By("Waiting for deployment to be rollout", func() { | ||
// Wait for application to be started | ||
status, err := kubectl.Run("rollout", "status", "deployment/"+appName) | ||
Expect(err).To(Not(HaveOccurred())) | ||
Expect(status).To(ContainSubstring("successfully rolled out")) | ||
}) | ||
|
||
By("Checking application", func() { | ||
// Get load balancer IPs | ||
appIPs, err := kubectl.Run("get", "svc", | ||
appName+"-loadbalancer", | ||
"-o", "jsonpath={.status.loadBalancer.ingress[*].ip}") | ||
Expect(err).To(Not(HaveOccurred())) | ||
Expect(appIPs).To(Not(BeEmpty())) | ||
|
||
// Loop on each IP to check the application | ||
for _, ip := range strings.Fields(appIPs) { | ||
GinkgoWriter.Printf("Checking node with IP %s...\n", ip) | ||
|
||
// Retry if needed, could take some times if a pod is restarted for example | ||
var htmlPage []byte | ||
Eventually(func() error { | ||
htmlPage, err = exec.Command("curl", "http://"+ip+":8080").CombinedOutput() | ||
return err | ||
}, misc.SetTimeout(2*time.Minute), 5*time.Second).Should(Not(HaveOccurred())) | ||
|
||
// Check HTML page content | ||
Expect(string(htmlPage)).To(And( | ||
ContainSubstring("Hello world!"), | ||
ContainSubstring("My hostname is hello-world-"), | ||
ContainSubstring(ip+":8080"), | ||
), string(htmlPage)) | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.