This is an automated email from the ASF dual-hosted git repository.

lewismc pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika-helm.git


The following commit(s) were added to refs/heads/main by this push:
     new a713d53  TIKA-4232 Create and execute unit tests for tika-helm (#17)
a713d53 is described below

commit a713d531225aac115a8a17e280834de616ad699d
Author: Lewis John McGibbney <[email protected]>
AuthorDate: Fri May 10 14:27:54 2024 -0700

    TIKA-4232 Create and execute unit tests for tika-helm (#17)
---
 .github/workflows/lint-test.yaml | 30 ++++++++++++++++++-
 .github/workflows/pluto.yaml     |  2 ++
 .gitignore                       |  1 +
 .helmignore                      |  1 +
 README.md                        | 14 +++++----
 templates/networkpolicy.yaml     | 18 ++++++++++++
 tests/deployment_test.yaml       | 62 ++++++++++++++++++++++++++++++++++++++++
 tests/hpa_test.yaml              | 41 ++++++++++++++++++++++++++
 tests/ingress_test.yaml          | 40 ++++++++++++++++++++++++++
 tests/networkpolicy_test.yaml    | 38 ++++++++++++++++++++++++
 tests/service_test.yaml          | 41 ++++++++++++++++++++++++++
 tests/serviceaccount_test.yaml   | 32 +++++++++++++++++++++
 values.yaml                      |  2 +-
 13 files changed, 314 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml
index a98fa5f..e1cc61e 100644
--- a/.github/workflows/lint-test.yaml
+++ b/.github/workflows/lint-test.yaml
@@ -45,11 +45,39 @@ jobs:
           if [[ -n "$changed" ]]; then
             echo "::set-output name=changed::true"
           fi
+        shell: bash
       - name: Run chart-testing (lint)
         run: ct lint --target-branch ${{ 
github.event.repository.default_branch }} --charts .
+        shell: bash
       - name: Create kind cluster
         uses: helm/[email protected]
         if: steps.list-changed.outputs.changed == 'true'
+      - name: Uninstall helm-unittest if present
+        run: |
+          helm plugin uninstall unittest >/dev/null 2>/dev/null \
+            || echo "Failed to uninstall plugin, assuming it's not present."
+        shell: bash
+      - name: Install latest helm-unittest
+        run: |
+          echo "Installing latest version of helm-unittest"
+          helm plugin install https://github.com/helm-unittest/helm-unittest 
>/dev/null 2>/dev/null
+        shell: bash
+      - name: Assemble list of chart directories to test
+        run: |
+          tr ' ' '\n' <<< . | grep -v '^$' > charts-to-test || true
+          find . -type f -name 'Chart.yaml' -exec dirname {} \; > all-charts
+          [ -z . ] && mv all-charts charts-to-test || true
+        shell: bash
+      - name: Fetch chart dependencies
+        run: |
+          for chart in $(cat charts-to-test); do
+            helm dependency update "$chart" >/dev/null
+          done
+        shell: bash
+      - name: Run unit tests
+        run: helm unittest --color $(cat charts-to-test)
+        shell: bash
       - name: Run chart-testing (install)
+        if: steps.list-changed.outputs.changed == 'true'
         run: ct install --target-branch ${{ 
github.event.repository.default_branch }} --charts .
-        if: steps.list-changed.outputs.changed == 'true'
\ No newline at end of file
+        shell: bash
diff --git a/.github/workflows/pluto.yaml b/.github/workflows/pluto.yaml
index b3cd69c..d246f5e 100644
--- a/.github/workflows/pluto.yaml
+++ b/.github/workflows/pluto.yaml
@@ -35,8 +35,10 @@ jobs:
           wget https://github.com/FairwindsOps/pluto/releases/download/v${{ 
env.PLUTO_VERSION }}/pluto_${{ env.PLUTO_VERSION }}_linux_amd64.tar.gz -O - | 
tar -xz
           mv pluto /usr/local/bin/pluto
           chmod +x /usr/local/bin/pluto
+        shell: bash
       - name: Set up Helm
         uses: azure/[email protected]
       - name: verify helm chart
         run: |
           helm template . | pluto detect -omarkdown - >> $GITHUB_STEP_SUMMARY
+        shell: bash
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e3343cd
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+test-output.xml
diff --git a/.helmignore b/.helmignore
index 0e8a0eb..2d9d142 100644
--- a/.helmignore
+++ b/.helmignore
@@ -21,3 +21,4 @@
 .idea/
 *.tmproj
 .vscode/
+tests
diff --git a/README.md b/README.md
index e275329..2881be2 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,6 @@ will work with the version of Tika you are installing.
 <!-- START doctoc generated TOC please keep comment here to allow auto update 
-->
 <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
 
-
 - [tika-helm](#tika-helm)
   - [Requirements](#requirements)
   - [Installing](#installing)
@@ -40,7 +39,6 @@ will work with the version of Tika you are installing.
 <!-- Use this to update TOC: -->
 <!-- docker run --rm -it -v $(pwd):/usr/src jorgeandrada/doctoc --github -->
 
-
 ## Requirements
 
 * Kubernetes >= 1.14
@@ -114,11 +112,14 @@ Please check `artifacthub.io/changes` in `Chart.yaml` 
before upgrading.
 | --------- | ----------- | ------- |
 | `...`     | ...         | ...     |
 
-### Deprecated
+## Testing
 
-| Parameter | Description | Default |
-| --------- | ----------- | ------- |
-| `...`     | ...         | `...`   |
+```
+helm plugin install https://github.com/helm-unittest/helm-unittest.git
+helm unittest .
+```
+
+See [helm-unittest][] for canonical documentation.
 
 ## Contributing
 
@@ -148,6 +149,7 @@ The code is licensed permissively under the [Apache License 
v2.0][].
 [CHANGELOG.md]: https://github.com/apache/tika-helm/blob/master/CHANGELOG.md
 [CONTRIBUTING]: https://github.com/apache/tika#contributing-via-github
 [apache/tika]: https://github.com/apache/tika-docker
+[helm-unittest]: https://github.com/helm-unittest/helm-unittest
 [Helm chart]: https://helm.sh/docs/topics/charts/
 [Kubernetes]: https://kubernetes.io/
 [Tika Docker image]: 
https://hub.docker.com/r/apache/tika/tags?page=1&ordering=last_updated
diff --git a/templates/networkpolicy.yaml b/templates/networkpolicy.yaml
index 5a2089f..4241840 100644
--- a/templates/networkpolicy.yaml
+++ b/templates/networkpolicy.yaml
@@ -1,3 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+---
 {{- if .Values.networkPolicy.enabled }}
 apiVersion: networking.k8s.io/v1
 kind: NetworkPolicy
diff --git a/tests/deployment_test.yaml b/tests/deployment_test.yaml
new file mode 100644
index 0000000..79902cb
--- /dev/null
+++ b/tests/deployment_test.yaml
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+suite: test deployment
+templates:
+  - deployment.yaml
+tests:
+  - it: should pass
+    set:
+      image.tag: latest
+    asserts:
+      - isKind:
+          of: Deployment
+      - isAPIVersion:
+          of: apps/v1
+      - matchRegex:
+          path: metadata.name
+          pattern: RELEASE-NAME-tika
+      - equal:
+          path: spec.template.spec.containers[0].image
+          value: apache/tika:latest
+      - lengthEqual:
+          path: spec.template.spec.containers
+          count: 1
+      - isSubset:
+          path: spec.template.spec.containers[0]
+          content:
+            livenessProbe:
+              httpGet:
+                path: /
+                port: 9998
+                scheme: HTTP
+              initialDelaySeconds: 15
+              timeoutSeconds: 30
+              failureThreshold: 20
+              periodSeconds: 5
+      - isSubset:
+          path: spec.template.spec.containers[0]
+          content:
+            readinessProbe:
+              httpGet:
+                path: /
+                port: 9998
+                scheme: HTTP
+              initialDelaySeconds: 15
+              timeoutSeconds: 30
+              failureThreshold: 20
+              periodSeconds: 5
diff --git a/tests/hpa_test.yaml b/tests/hpa_test.yaml
new file mode 100644
index 0000000..ececb85
--- /dev/null
+++ b/tests/hpa_test.yaml
@@ -0,0 +1,41 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+suite: test hpa
+templates:
+  - hpa.yaml
+tests:
+  - it: should pass
+    set:
+      autoscaling.enabled: true
+    asserts:
+      - isKind:
+          of: HorizontalPodAutoscaler
+      - isAPIVersion:
+          of: autoscaling/v2
+      - matchRegex:
+          path: metadata.name
+          pattern: RELEASE-NAME-tika
+      - equal:
+          path: spec.minReplicas
+          value: 1
+      - equal:
+          path: spec.maxReplicas
+          value: 100
+      - lengthEqual:
+          path: spec.metrics
+          count: 2
diff --git a/tests/ingress_test.yaml b/tests/ingress_test.yaml
new file mode 100644
index 0000000..48c8cf2
--- /dev/null
+++ b/tests/ingress_test.yaml
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+suite: test ingress
+templates:
+  - ingress.yaml
+tests:
+  - it: should pass
+    set:
+      image.tag: latest
+      ingress.enabled: true
+      Capabilities.KubeVersion.GitVersion: 1.20
+      ingress.tls:
+        - secretName: chart-example-tls
+          hosts:
+            - chart-example.local
+    asserts:
+      - containsDocument:
+          kind: Ingress
+          apiVersion: networking.k8s.io/v1
+          metadata.name: RELEASE-NAME-tika
+      - isNotNullOrEmpty:
+          path: spec.tls
+      - lengthEqual:
+          path: spec.rules
+          count: 1
diff --git a/tests/networkpolicy_test.yaml b/tests/networkpolicy_test.yaml
new file mode 100644
index 0000000..5821fa2
--- /dev/null
+++ b/tests/networkpolicy_test.yaml
@@ -0,0 +1,38 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+suite: test networkpolicy
+templates:
+  - networkpolicy.yaml
+tests:
+  - it: should pass
+    set:
+      image.tag: latest
+      networkPolicy.enabled: true
+      networkPolicy.allowExternal: false
+    asserts:
+      - isKind:
+          of: NetworkPolicy
+      - matchRegex:
+          path: metadata.name
+          pattern: RELEASE-NAME-tika
+      - isAPIVersion:
+          of: networking.k8s.io/v1
+      - isNullOrEmpty:
+          path: spec.egress[0]
+      - isNotNullOrEmpty:
+          path: spec.ingress[0].from
diff --git a/tests/service_test.yaml b/tests/service_test.yaml
new file mode 100644
index 0000000..41a3d1e
--- /dev/null
+++ b/tests/service_test.yaml
@@ -0,0 +1,41 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+suite: test service
+templates:
+  - service.yaml
+tests:
+  - it: should pass
+    set:
+      image.tag: latest
+    asserts:
+      - isKind:
+          of: Service
+      - matchRegex:
+          path: metadata.name
+          pattern: RELEASE-NAME-tika
+      - isAPIVersion:
+          of: v1
+      - equal:
+          path: spec.type
+          value: ClusterIP
+      - lengthEqual:
+          path: spec.ports
+          count: 1
+      - equal:
+          path: spec.ports[0].port
+          value: 9998
diff --git a/tests/serviceaccount_test.yaml b/tests/serviceaccount_test.yaml
new file mode 100644
index 0000000..6262685
--- /dev/null
+++ b/tests/serviceaccount_test.yaml
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+suite: test serviceaccount
+templates:
+  - serviceaccount.yaml
+tests:
+  - it: should pass
+    set:
+      image.tag: latest
+    asserts:
+      - isKind:
+          of: ServiceAccount
+      - isAPIVersion:
+          of: v1
+      - matchRegex:
+          path: metadata.name
+          pattern: RELEASE-NAME-tika
diff --git a/values.yaml b/values.yaml
index 2b48aa5..0901e1e 100644
--- a/values.yaml
+++ b/values.yaml
@@ -99,7 +99,7 @@ resources:
     memory: 1500Mi
 
 autoscaling:
-  apiVersion: autoscaling/v2beta1
+  apiVersion: autoscaling/v2
   enabled: false
   minReplicas: 1
   maxReplicas: 100

Reply via email to