Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for testing more perl-versions. #106

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ metadata:
template: dancer-example
name: {{ .Values.name }}
spec:
{{ if .Values.registry.enabled }}
output:
to:
kind: DockerImage
name: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest"
pushSecret:
name: {{ .Values.registry.push_secret }}
{{ else }}
output:
to:
kind: ImageStreamTag
name: {{ .Values.name }}:latest
{{ end }}
postCommit:
script: perl -I extlib/lib/perl5 -I lib t/*
source:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: Deployment
metadata:
annotations:
description: Defines how to deploy the application server
{{ if not .Values.registry.enabled }}
image.openshift.io/triggers: |-
[
{
Expand All @@ -13,6 +14,7 @@ metadata:
"fieldPath": "spec.template.spec.containers[0].image"
}
]
{{ end }}
template.alpha.openshift.io/wait-for-ready: "true"
labels:
app: dancer-example
Expand All @@ -35,7 +37,11 @@ spec:
- env:
- name: PERL_APACHE2_RELOAD
value: {{ .Values.perl_apache2_reload }}
{{ if .Values.registry.enabled }}
image: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest"
{{ else }}
image: " "
{{ end }}
livenessProbe:
httpGet:
path: /
Expand Down
20 changes: 20 additions & 0 deletions charts/redhat/perl-dancer-application/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@
"source_repository_ref": {
"type": "string",
"description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
},
"registry": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"name": {
"type": "string",
"description": "The name of registry that will be used for pushing built image."
},
"namespace": {
"type": "string",
"description": "The namespace of registry that will be used for pushing built image."
},
"push_secret": {
"type": "string",
"description": "The push secret to push image to registry."
}
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions charts/redhat/perl-dancer-application/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ perl_version: 5.30-ubi8
secret_key_base: "" # TODO: must define a default value for .secret_key_base
source_repository_ref: master # TODO: must define a default value for .source_repository_ref
source_repository_url: https://github.com/sclorg/dancer-ex.git
registry:
enabled: false
name: "quay.io"
namespace: ""
push_secret: ""
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@ metadata:
template: dancer-mysql-persistent
name: {{ .Values.name }}
spec:
{{ if .Values.registry.enabled }}
output:
to:
kind: DockerImage
name: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest"
pushSecret:
name: {{ .Values.registry.push_secret }}
pullSecret:
name:
{{ else }}
output:
to:
kind: ImageStreamTag
name: {{ .Values.name }}:latest
{{ end }}
postCommit:
script: perl -I extlib/lib/perl5 -I lib t/*
source:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: Deployment
metadata:
annotations:
description: Defines how to deploy the application server
{{ if not .Values.registry.enabled }}
image.openshift.io/triggers: |-
[
{
Expand All @@ -13,6 +14,7 @@ metadata:
"fieldPath": "spec.template.spec.containers[0].image"
}
]
{{ end }}
template.alpha.openshift.io/wait-for-ready: "true"
labels:
app: dancer-mysql-persistent
Expand Down Expand Up @@ -53,7 +55,11 @@ spec:
name: {{ .Values.name }}
- name: PERL_APACHE2_RELOAD
value: {{ .Values.perl_apache2_reload }}
image: ' '
{{ if .Values.registry.enabled }}
image: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest"
{{ else }}
image: " "
{{ end }}
livenessProbe:
httpGet:
path: /health
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
{{ if .Values.pvc.netapp_nfs }}
annotations:
trident.netapp.io/reclaimPolicy: Delete
{{ end }}
labels:
app: dancer-mysql-persistent
template: dancer-mysql-persistent
{{ if .Values.pvc.netapp_nfs }}
paas.redhat.com/appcode: {{ .Values.pvc.app_code }}
{{ end }}
name: {{ .Values.database_service_name }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.volume_capacity }}
storage: {{ .Values.pvc.volume_capacity }}
{{ if .Values.pvc.netapp_nfs }}
storageClassName: netapp-nfs
volumeMode: Filesystem
{{ end }}
47 changes: 39 additions & 8 deletions charts/redhat/perl-dancer-mysql-persistent/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,45 @@
"type": "string",
"description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
},
"volume_capacity": {
"type": "string",
"title": "Persistent Volume Size",
"form": true,
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderUnit": "Gi"
"registry": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"name": {
"type": "string",
"description": "The name of registry that will be used for pushing built image."
},
"namespace": {
"type": "string",
"description": "The namespace of registry that will be used for pushing built image."
},
"push_secret": {
"type": "string",
"description": "The push secret to push image to registry."
}
}
},
"pvc": {
"type": "object",
"properties": {
"volume_capacity": {
"type": "string",
"title": "Persistent Volume Size",
"form": true,
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderUnit": "Gi"
},
"netapp_nfs": {
"type": "boolean"
},
"app_code": {
"type": "string"
}
}
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions charts/redhat/perl-dancer-mysql-persistent/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ perl_version: 5.30-ubi8
secret_key_base: "" # TODO: must define a default value for .secret_key_base
source_repository_ref: master # TODO: must define a default value for .source_repository_ref
source_repository_url: https://github.com/sclorg/dancer-ex.git
volume_capacity: 1Gi

registry:
enabled: false
name: "quay.io"
namespace: ""
push_secret: ""
pvc:
volume_capacity: 1Gi
app_code: "something"
netapp_nfs: false
38 changes: 29 additions & 9 deletions tests/test_perl_dancer_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,57 @@ def setup_method(self):
def teardown_method(self):
self.hc_api.delete_project()

def test_dancer_application_curl_output(self):
@pytest.mark.parametrize(
"version",
[
"5.32-ubi9",
"5.32-ubi8",
"5.26-ubi8",
]
)
def test_dancer_application_curl_output(self, version):
if self.hc_api.oc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
self.hc_api.package_name = "perl-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "perl-dancer-application"
pod_name = f"dancer-ex-{version}".replace(".", "-")
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation(
values={
"perl_version": "5.32-ubi8",
"namespace": self.hc_api.namespace
"perl_version": version,
"namespace": self.hc_api.namespace,
"name": pod_name
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="dancer-example")
assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=600)
assert self.hc_api.test_helm_curl_output(
route_name="dancer-example",
route_name=pod_name,
expected_str="Welcome to your Dancer application"
)

def test_dancer_application_helm_test(self):
@pytest.mark.parametrize(
"version",
[
"5.32-ubi9",
"5.32-ubi8",
"5.26-ubi8",
]
)
def test_dancer_application_helm_test(self, version):
self.hc_api.package_name = "perl-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "perl-dancer-application"
assert self.hc_api.helm_package()
pod_name = f"dancer-ex-{version}".replace(".", "-")
assert self.hc_api.helm_installation(
values={
"perl_version": "5.32-ubi8",
"namespace": self.hc_api.namespace
"perl_version": version,
"namespace": self.hc_api.namespace,
"name": pod_name
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="dancer-example")
assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=600)
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Dancer application"])
39 changes: 29 additions & 10 deletions tests/test_perl_dancer_mysql_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,57 @@ def setup_method(self):
def teardown_method(self):
self.hc_api.delete_project()

def test_dancer_application(self):
@pytest.mark.parametrize(
"version",
[
"5.32-ubi9",
"5.32-ubi8",
"5.26-ubi8",
]
)
def test_dancer_application(self, version):
if self.hc_api.oc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
self.hc_api.package_name = "perl-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "perl-dancer-application"
assert self.hc_api.helm_package()
pod_name = f"dancer-ex-{version}".replace(".", "-")
assert self.hc_api.helm_installation(
values={
"perl_version": "5.32-ubi8",
"namespace": self.hc_api.namespace
"perl_version": version,
"namespace": self.hc_api.namespace,
"name": pod_name
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="dancer-example")
assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=600)
assert self.hc_api.test_helm_curl_output(
route_name="dancer-example",
route_name=pod_name,
expected_str="Welcome to your Dancer application"
)


def test_dancer_application_helm_test(self):
@pytest.mark.parametrize(
"version",
[
"5.32-ubi9",
"5.32-ubi8",
"5.26-ubi8",
]
)
def test_dancer_application_helm_test(self, version):
self.hc_api.package_name = "perl-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "perl-dancer-application"
assert self.hc_api.helm_package()
pod_name = f"dancer-ex-{version}".replace(".", "-")
assert self.hc_api.helm_installation(
values={
"perl_version": "5.32-ubi8",
"namespace": self.hc_api.namespace
"perl_version": version,
"namespace": self.hc_api.namespace,
"name": pod_name
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="dancer-example")
assert self.hc_api.is_s2i_pod_running(pod_name_prefix=pod_name, timeout=600)
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Dancer application"])
Loading