Skip to content

Commit

Permalink
test (e2e) : Add E2E test for java app deploy workflow using Eclipse …
Browse files Browse the repository at this point in the history
…JKube (#4397)

+ Added new test `application_deployment.feature` that would deploy a
  simple Quarkus application onto existing CRC cluster and verify that
  application is accessible via endpoint.
+ Perform JKube application deploy step in a Pod instead of podman
  container in order to skip oc login

Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia authored and praveenkumar committed Nov 14, 2024
1 parent d231c86 commit d485151
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/e2e/features/application_deployment.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@story_application_deployment
Feature: Application Deployment Test

User deploys a basic java application onto CRC cluster and expects that it's
deployed successfully and is accessible via route

Background:
Given ensuring CRC cluster is running
And ensuring oc command is available
And ensuring user is logged in succeeds

@testdata @linux @windows @darwin @cleanup @needs_namespace
Scenario: Deploy a java application using Eclipse JKube in pod and then verify it's health
When executing "oc new-project testproj" succeeds
And executing "oc create -f jkube-kubernetes-build-resources.yaml" succeeds
And executing "oc start-build jkube-application-deploy-buildconfig --follow" succeeds
And executing "oc rollout status -w dc/jkube-application-deploy-test --timeout=600s" succeeds
Then stdout should contain "successfully rolled out"
And executing "oc logs -lapp=jkube-application-deploy-test -f" succeeds
And executing "oc rollout status -w dc/quarkus --timeout=600s" succeeds
Then stdout should contain "successfully rolled out"
And executing "oc get build -lapp=quarkus" succeeds
Then stdout should contain "quarkus-s2i"
And executing "oc get buildconfig -lapp=quarkus" succeeds
Then stdout should contain "quarkus-s2i"
And executing "oc get imagestream -lapp=quarkus" succeeds
Then stdout should contain "quarkus"
And executing "oc get pods -lapp=quarkus" succeeds
Then stdout should contain "quarkus"
And stdout should contain "1/1 Running"
And executing "oc get svc -lapp=quarkus" succeeds
Then stdout should contain "quarkus"
And executing "oc get routes -lapp=quarkus" succeeds
Then stdout should contain "quarkus"
And with up to "4" retries with wait period of "1m" http response from "http://quarkus-testproj.apps-crc.testing" has status code "200"
Then executing "curl -s http://quarkus-testproj.apps-crc.testing" succeeds
And stdout should contain "{"applicationName":"JKube","message":"Subatomic JKube really whips the llama's ass!"}"
146 changes: 146 additions & 0 deletions test/testdata/jkube-kubernetes-build-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
apiVersion: v1
kind: List
items:
- apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: jkube-application-deploy-role
labels:
app: jkube-application-deploy-test
rules:
- apiGroups:
- ""
resources:
- secrets
- pods
- pods/log
- services
- events
verbs:
- create
- get
- list
- update
- watch
- patch
- apiGroups:
- apps.openshift.io
resources:
- deploymentconfigs
verbs:
- create
- get
- list
- update
- patch
- apiGroups:
- build.openshift.io
resources:
- buildconfigs
- buildconfigs/instantiatebinary
- builds
verbs: ["*"]
- apiGroups:
- image.openshift.io
resources:
- imagestreams
verbs:
- create
- get
- list
- update
- patch
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- create
- get
- list
- update
- patch
- apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: jkube-application-deploy-binding
labels:
app: jkube-application-deploy-test
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: jkube-application-deploy-role
subjects:
- kind: ServiceAccount
name: jkube-application-deploy-sa
- apiVersion: v1
kind: ServiceAccount
metadata:
name: jkube-application-deploy-sa
labels:
app: jkube-application-deploy-test
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
labels:
app: jkube-application-deploy-test
name: jkube-application-deploy-is
- apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: jkube-application-deploy-buildconfig
labels:
app: jkube-application-deploy-test
spec:
output:
to:
kind: ImageStreamTag
name: jkube-application-deploy-is:latest
source:
type: Dockerfile
dockerfile: |
FROM registry.access.redhat.com/ubi9/openjdk-17:1.20-2.1726695177
LABEL org.opencontainers.image.authors="CRCQE <[email protected]>"
USER root
# Install Git
RUN microdnf install -y git
RUN git clone https://github.com/eclipse-jkube/jkube.git
RUN chmod -R 775 /home/default/jkube
WORKDIR /home/default/jkube/quickstarts/maven/quarkus
RUN mkdir foo
ENTRYPOINT ["mvn", "package", "oc:build", "oc:resource", "oc:apply"]
strategy:
type: Docker
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: jkube-application-deploy-test
name: jkube-application-deploy-test
spec:
replicas: 1
selector:
app: jkube-application-deploy-test
template:
metadata:
labels:
app: jkube-application-deploy-test
name: jkube-application-deploy-test
spec:
containers:
- image: jkube-application-deploy-is:latest
imagePullPolicy: IfNotPresent
name: maven-pod
securityContext:
privileged: false
serviceAccount: jkube-application-deploy-sa
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- maven-pod
from:
kind: ImageStreamTag
name: jkube-application-deploy-is:latest
type: ImageChange

0 comments on commit d485151

Please sign in to comment.