Skip to content

Commit

Permalink
Fix ruby-helm chart for using shared cluster properly.
Browse files Browse the repository at this point in the history
Rename 'ruby-imagestreams' -> 'redhat-ruby-imagestreams'
Rename 'ruby-rails-application' -> 'redhat-ruby-rails-application'

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
  • Loading branch information
phracek committed Dec 5, 2024
1 parent 559c281 commit af388f8
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 17 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ annotations:
apiVersion: v2
appVersion: 0.0.3
kubeVersion: '>=1.20.0'
name: ruby-imagestreams
name: redhat-ruby-imagestreams
tags: builder,ruby
sources:
- https://github.com/sclorg/helm-charts
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
description: This content is experimental, do not use it in production. An example Rails application with no database. For more information about
using this template, including OpenShift considerations, see https://github.com/sclorg/rails-ex/blob/master/README.md.
name: ruby-rails-application
name: redhat-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 @@ -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
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."
}
}
}
}
}
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: ""
2 changes: 1 addition & 1 deletion tests/test_ruby_imagestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.fixture(scope="module")
def helm_api(request):
helm_api = HelmChartsAPI(path=test_dir / "../charts/redhat", package_name="ruby-imagestreams", tarball_dir=test_dir)
helm_api = HelmChartsAPI(path=test_dir / "../charts/redhat", package_name="redhat-ruby-imagestreams", tarball_dir=test_dir)
print(request)
# app_name = os.path.basename(request.param)
yield helm_api
Expand Down
30 changes: 19 additions & 11 deletions tests/test_ruby_rails_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
test_dir = Path(os.path.abspath(os.path.dirname(__file__)))


class TestHelmCakePHPTemplate:
class TestHelmRubyExTemplate:

def setup_method(self):
package_name = "ruby-rails-application"
package_name = "redhat-ruby-rails-application"
path = test_dir / "../charts/redhat"
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)

Expand All @@ -32,21 +32,24 @@ def teardown_method(self):
def test_curl_connection(self, version, branch):
if self.hc_api.oc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
self.hc_api.package_name = "ruby-imagestreams"
self.hc_api.package_name = "redhat-ruby-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "ruby-rails-application"
self.hc_api.package_name = "redhat-ruby-rails-application"
assert self.hc_api.helm_package()
pod_name = f"rails-{version.replace(".", "")}"
assert self.hc_api.helm_installation(
values={
"ruby_version": f"{version}",
"source_repository_ref": f"{branch}",
"namespace": self.hc_api.namespace
"source_repository_url": "https://github.com/sclorg/rails-ex.git",
"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=480)
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 @@ -62,17 +65,22 @@ def test_curl_connection(self, version, branch):
],
)
def test_by_helm_test(self, version, branch):
self.hc_api.package_name = "ruby-imagestreams"
if self.hc_api.oc_api.shared_cluster:
pytest.skip("Do NOT test on shared cluster")
self.hc_api.package_name = "redhat-ruby-imagestreams"
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
self.hc_api.package_name = "ruby-rails-application"
self.hc_api.package_name = "redhat-ruby-rails-application"
assert self.hc_api.helm_package()
pod_name = f"rails-{version.replace(".", "")}"
assert self.hc_api.helm_installation(
values={
"ruby_version": f"{version}",
"source_repository_ref": f"{branch}",
"namespace": self.hc_api.namespace
"source_repository_url": "https://github.com/sclorg/rails-ex.git",
"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=480)
assert self.hc_api.test_helm_chart(expected_str=["Welcome to your Rails application"])

0 comments on commit af388f8

Please sign in to comment.