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 testing Ruby Helm Charts on Shared Cluster. #109

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions charts/redhat/ruby-rails-application/src/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ description: This content is experimental, do not use it in production. An examp
using this template, including OpenShift considerations, see https://github.com/sclorg/rails-ex/blob/master/README.md.
name: ruby-rails-application
tags: quickstart,ruby,rails
version: 0.0.1
version: 0.0.2
kubeVersion: '>=1.20.0'
annotations:
charts.openshift.io/name: Red Hat Apache Rails application with no database (experimental)
charts.openshift.io/provider: Red Hat
charts.openshift.io/providerType: redhat
apiVersion: v2
appVersion: 0.0.1
appVersion: 0.0.2
sources:
- https://github.com/sclorg/helm-charts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ metadata:
template: rails-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
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: rails-example
Expand All @@ -35,7 +37,11 @@ spec:
- env:
- name: RAILS_ENV
value: {{ .Values.rails_env }}
image: "{{ .Values.name }}:latest"
{{ 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/ruby-rails-application/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@
"rubygem_mirror": {
"type": "string",
"description": "The custom RubyGems mirror URL."
},
"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."
}
}
}
}
}
5 changes: 5 additions & 0 deletions charts/redhat/ruby-rails-application/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ rubygem_mirror: "" # TODO: must define a default value for .rubygem_mirror
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/rails-ex.git
registry:
enabled: false
name: "quay.io"
namespace: "something"
push_secret: ""
14 changes: 9 additions & 5 deletions tests/test_ruby_rails_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,18 @@ def test_curl_connection(self, version, branch):
assert self.hc_api.helm_installation()
self.hc_api.package_name = "ruby-rails-application"
assert self.hc_api.helm_package()
pod_name = f"rails-ex-{version}".replace(".", "-")
assert self.hc_api.helm_installation(
values={
"ruby_version": f"{version}",
"source_repository_ref": f"{branch}",
"namespace": self.hc_api.namespace
"namespace": self.hc_api.namespace,
"name": pod_name
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example", timeout=300)
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="rails-example",
route_name=pod_name,
expected_str="Welcome to your Rails application"
)

Expand All @@ -67,12 +69,14 @@ def test_by_helm_test(self, version, branch):
assert self.hc_api.helm_installation()
self.hc_api.package_name = "ruby-rails-application"
assert self.hc_api.helm_package()
pod_name = f"rails-ex-{version}".replace(".", "-")
assert self.hc_api.helm_installation(
values={
"ruby_version": f"{version}",
"source_repository_ref": f"{branch}",
"namespace": self.hc_api.namespace
"namespace": self.hc_api.namespace,
"name": pod_name
}
)
assert self.hc_api.is_s2i_pod_running(pod_name_prefix="rails-example", timeout=300)
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 Rails application"])