Skip to content

Commit

Permalink
Merge pull request #104 from sclorg/httpd_shared_cluster
Browse files Browse the repository at this point in the history
Let's tests shared cluster on Helm Charts first
  • Loading branch information
phracek authored Oct 24, 2024
2 parents c43e6e2 + 852e4c9 commit acb0587
Show file tree
Hide file tree
Showing 21 changed files with 242 additions and 167 deletions.
9 changes: 9 additions & 0 deletions charts/redhat/httpd-template/src/templates/buildconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ metadata:
template: httpd-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 }}
source:
contextDir: {{ .Values.context_dir }}
git:
Expand Down
6 changes: 6 additions & 0 deletions charts/redhat/httpd-template/src/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
description: Defines how to deploy the application server
template.alpha.openshift.io/wait-for-ready: "true"
image.openshift.io/triggers: |-
{{ if not .Values.registry.enabled }}
[
{
"from": {
Expand All @@ -14,6 +15,7 @@ metadata:
"fieldPath": "spec.template.spec.containers[0].image"
}
]
{{ end }}
labels:
app: httpd-example
template: httpd-example
Expand All @@ -33,7 +35,11 @@ spec:
spec:
containers:
- env: []
{{ 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/httpd-template/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@
"context_dir": {
"type": "string",
"description": "Set this to the relative path to your project if it is not in the root of your repository."
},
"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/httpd-template/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ namespace: openshift
source_repository_ref: master # TODO: must define a default value for .source_repository_ref
source_repository_url: https://github.com/sclorg/httpd-ex.git
expected_str: Welcome to your static httpd application on OpenShift
registry:
enabled: false
name: "quay.io"
namespace: "something"
push_secret: ""
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.openshift.io/runtime: mariadb
template: mariadb-persistent-template
{{ 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 }}
31 changes: 21 additions & 10 deletions charts/redhat/mariadb-persistent/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@
"mysql_user": {
"type": "string"
},
"volume_capacity": {
"type": "string",
"title": "Persistent Volume Size",
"form": true,
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderUnit": "Gi"
},
"memory_limit": {
"type": "string",
"title": "Database memory limit",
Expand All @@ -42,7 +33,27 @@
"mariadb_version": {
"type": "string",
"description": "Specify mariadb imagestream tag",
"enum": [ "latest", "10.5-el9", "10.3-el8", "10.5-el8", "10.3" ]
"enum": [ "latest", "10.5-el9", "10.11-el9", "10.3-el8", "10.5-el8", "10.11-el8", "10.3" ]
},
"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
5 changes: 4 additions & 1 deletion charts/redhat/mariadb-persistent/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ mysql_password: testu
mysql_root_password: testur
mysql_user: testu
namespace: openshift
volume_capacity: 1Gi
pvc:
volume_capacity: 1Gi
app_code: "something"
netapp_nfs: false
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
{{ if .Values.pvc.netapp_nfs }}
annotations:
trident.netapp.io/reclaimPolicy: Delete
{{ end }}
labels:
template: mysql-persistent-template
{{ 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 }}
20 changes: 20 additions & 0 deletions charts/redhat/mysql-persistent/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@
"type": "string",
"description": "Specify mysql imagestream tag",
"enum": [ "latest", "8.0-el9", "8.0-el8" ]
},
"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
5 changes: 4 additions & 1 deletion charts/redhat/mysql-persistent/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ mysql_root_password: testur # TODO: must define a default value for .mysql_root_
mysql_user: testu # TODO: must define a default value for .mysql_user'
mysql_version: 8.0-el8
namespace: openshift
volume_capacity: 1Gi
pvc:
volume_capacity: 1Gi
app_code: "something"
netapp_nfs: false
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
{{ if .Values.pvc.netapp_nfs }}
annotations:
trident.netapp.io/reclaimPolicy: Delete
{{ end }}
labels:
template: redis-persistent-template
{{ 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 }}
29 changes: 20 additions & 9 deletions charts/redhat/redis-persistent/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
"redis_password": {
"type": "string"
},
"volume_capacity": {
"type": "string",
"title": "Persistent Volume Size",
"form": true,
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderUnit": "Gi"
},
"memory_limit": {
"type": "string",
"title": "Database memory limit",
Expand All @@ -34,6 +25,26 @@
"type": "string",
"description": "Specify redis imagestream tag",
"enum": [ "latest", "7-el9", "6-el9", "6-el8" ]
},
"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
5 changes: 4 additions & 1 deletion charts/redhat/redis-persistent/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ memory_limit: 512Mi
namespace: redis-persistent-testing
redis_password: testp # TODO: must define a default value for .redis_password'
redis_version: 6-el8
volume_capacity: 1Gi
pvc:
volume_capacity: 1Gi
app_code: "something"
netapp_nfs: false
31 changes: 3 additions & 28 deletions tests/test_httpd_imagestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ def setup_method(self):
package_name = "httpd-imagestreams"
path = test_dir / "../charts/redhat"
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()

def teardown_method(self):
self.hc_api.delete_project()
Expand All @@ -27,32 +29,5 @@ def teardown_method(self):
("2.4-el9", "registry.redhat.io/rhel9/httpd-24", True),
],
)
def test_package_imagestream(self, version, registry, expected):
self.hc_api.set_version("0.0.1")
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected


class TestHelmCentOSHttpdImagestreams:
def setup_method(self):
package_name = "httpd-imagestreams"
path = test_dir / "../charts/centos"
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)

def teardown_method(self):
self.hc_api.delete_project()

@pytest.mark.parametrize(
"version,registry,expected",
[
("2.4-ubi9", "registry.access.redhat.com/ubi9/httpd-24:latest", True),
("2.4-ubi8", "registry.access.redhat.com/ubi8/httpd-24:latest", True),
("2.4-el8", "quay.io/sclorg/httpd-24-c8s:latest", False),
("2.4-el9", "quay.io/sclorg/httpd-24-c9s:latest", True),
]
)
def test_package_imagestream(self, version, registry, expected):
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
def test_httpd_imagestream(self, version, registry, expected):
assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected
Loading

0 comments on commit acb0587

Please sign in to comment.