Skip to content

Commit a57579c

Browse files
authored
[FLINK-37669][HELM] Add Helm chart unit tests to flink kubernetes operator
1 parent 9c49fb2 commit a57579c

15 files changed

+1135
-4
lines changed

.github/workflows/ci.yml

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,84 @@
1616
# limitations under the License.
1717
################################################################################
1818

19-
2019
# We need to specify repo related information here since Apache INFRA doesn't differentiate
2120
# between several workflows with the same names while preparing a report for GHA usage
2221
# https://infra-reports.apache.org/#ghactions
2322
name: Flink Kubernetes Operator CI
23+
2424
on:
2525
push:
2626
branches:
2727
- main
2828
- release-*
2929
pull_request:
30+
3031
concurrency:
3132
group: ${{ github.workflow }}-${{ github.ref_name }}
3233
cancel-in-progress: true
3334

35+
env:
36+
HELM_CHART_DIR: helm
37+
FLINK_OPERATOR_CHART: flink-kubernetes-operator
38+
3439
jobs:
40+
helm_lint_test:
41+
runs-on: ubuntu-latest
42+
43+
name: Helm Lint Test
44+
45+
steps:
46+
- name: Determine branch name
47+
id: get_branch
48+
run: |
49+
BRANCH=""
50+
if [ "${{ github.event_name }}" == "push" ]; then
51+
BRANCH=${{ github.ref_name }}
52+
elif [ "${{ github.event_name }}" == "pull_request" ]; then
53+
BRANCH=${{ github.base_ref }}
54+
fi
55+
echo "BRANCH=$BRANCH" >> "$GITHUB_OUTPUT"
56+
57+
- name: Checkout source code
58+
uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0
61+
62+
- name: Set up Helm
63+
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4
64+
with:
65+
version: v3.17.3
66+
67+
- name: Install Helm unittest plugin
68+
run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version 0.8.1
69+
70+
- name: Run Helm unittest
71+
run: helm unittest ${{ env.HELM_CHART_DIR }}/${{ env.FLINK_OPERATOR_CHART }} --file "tests/**/*_test.yaml" --strict --debug
72+
73+
- name: Set up chart-testing
74+
uses: helm/chart-testing-action@0d28d3144d3a25ea2cc349d6e59901c4ff469b3b
75+
76+
- name: Run chart-testing (list-changed)
77+
id: list-changed
78+
env:
79+
BRANCH: ${{ steps.get_branch.outputs.BRANCH }}
80+
run: |
81+
changed=$(ct list-changed --target-branch $BRANCH --chart-dirs ${{ env.HELM_CHART_DIR }})
82+
if [[ -n "$changed" ]]; then
83+
echo "changed=true" >> "$GITHUB_OUTPUT"
84+
fi
85+
86+
- name: Run Helm lint
87+
if: steps.list-changed.outputs.changed == 'true'
88+
run: |
89+
helm lint ${{ env.HELM_CHART_DIR }}/${{ env.FLINK_OPERATOR_CHART }} --strict --debug
90+
91+
- name: Run chart-testing (lint)
92+
if: steps.list-changed.outputs.changed == 'true'
93+
env:
94+
BRANCH: ${{ steps.get_branch.outputs.BRANCH }}
95+
run: ct lint --target-branch $BRANCH --chart-dirs ${{ env.HELM_CHART_DIR }} --check-version-increment=false --validate-maintainers=false
96+
3597
test_ci:
3698
runs-on: ubuntu-latest
3799
name: maven build
@@ -53,9 +115,6 @@ jobs:
53115
echo "Please generate the java doc via 'mvn clean install -DskipTests -Pgenerate-docs' again"
54116
exit 1
55117
fi
56-
- name: Validate helm chart linting
57-
run: |
58-
helm lint helm/flink-kubernetes-operator
59118
- name: Tests in flink-kubernetes-operator
60119
run: |
61120
cd flink-kubernetes-operator
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
19+
suite: Test Cert Manager Certificate
20+
21+
templates:
22+
- cert-manager/certificate.yaml
23+
24+
release:
25+
name: flink-operator
26+
namespace: flink-operator
27+
28+
tests:
29+
- it: Should create certificate
30+
asserts:
31+
- containsDocument:
32+
apiVersion: cert-manager.io/v1
33+
kind: Certificate
34+
name: flink-operator-serving-cert
35+
36+
- it: Should use self signed issuer
37+
asserts:
38+
- equal:
39+
path: spec.issuerRef
40+
value:
41+
kind: Issuer
42+
name: flink-operator-selfsigned-issuer
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
19+
suite: Test Cert Manager Issuer
20+
21+
templates:
22+
- cert-manager/issuer.yaml
23+
24+
release:
25+
name: flink-operator
26+
namespace: flink-operator
27+
28+
tests:
29+
- it: Should create self signed Issuer
30+
asserts:
31+
- containsDocument:
32+
apiVersion: cert-manager.io/v1
33+
kind: Issuer
34+
name: flink-operator-selfsigned-issuer
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
19+
suite: Test ConfigMap
20+
21+
templates:
22+
- controller/configmap.yaml
23+
24+
release:
25+
name: flink-operator
26+
namespace: flink-operator
27+
28+
tests:
29+
- it: Should create a configmap with default configuration if `defaultConfiguration.create` is `true`
30+
set:
31+
defaultConfiguration:
32+
create: true
33+
asserts:
34+
- containsDocument:
35+
apiVersion: v1
36+
kind: ConfigMap
37+
name: flink-operator-config
38+
namespace: flink-operator

0 commit comments

Comments
 (0)