Skip to content

[FLINK-37669][HELM] Add Helm chart unit tests to flink kubernetes operator #971

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

Open
wants to merge 2 commits 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
67 changes: 63 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,84 @@
# limitations under the License.
################################################################################


# We need to specify repo related information here since Apache INFRA doesn't differentiate
# between several workflows with the same names while preparing a report for GHA usage
# https://infra-reports.apache.org/#ghactions
name: Flink Kubernetes Operator CI

on:
push:
branches:
- main
- release-*
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

env:
HELM_CHART_DIR: helm
FLINK_OPERATOR_CHART: flink-kubernetes-operator

jobs:
helm_lint_test:
runs-on: ubuntu-latest

name: Helm Lint Test

steps:
- name: Determine branch name
id: get_branch
run: |
BRANCH=""
if [ "${{ github.event_name }}" == "push" ]; then
BRANCH=${{ github.ref_name }}
elif [ "${{ github.event_name }}" == "pull_request" ]; then
BRANCH=${{ github.base_ref }}
fi
echo "BRANCH=$BRANCH" >> "$GITHUB_OUTPUT"

- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/[email protected]
with:
version: v3.17.3

- name: Install Helm unittest plugin
run: helm plugin install https://github.com/helm-unittest/helm-unittest.git --version 0.8.1

- name: Run Helm unittest
run: helm unittest ${{ env.HELM_CHART_DIR }}/${{ env.FLINK_OPERATOR_CHART }} --file "tests/**/*_test.yaml" --strict --debug

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
env:
BRANCH: ${{ steps.get_branch.outputs.BRANCH }}
run: |
changed=$(ct list-changed --target-branch $BRANCH --chart-dirs ${{ env.HELM_CHART_DIR }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Run Helm lint
if: steps.list-changed.outputs.changed == 'true'
run: |
helm lint ${{ env.HELM_CHART_DIR }}/${{ env.FLINK_OPERATOR_CHART }} --strict --debug

- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
env:
BRANCH: ${{ steps.get_branch.outputs.BRANCH }}
run: ct lint --target-branch $BRANCH --chart-dirs ${{ env.HELM_CHART_DIR }} --check-version-increment=false --validate-maintainers=false

test_ci:
runs-on: ubuntu-latest
name: maven build
Expand All @@ -53,9 +115,6 @@ jobs:
echo "Please generate the java doc via 'mvn clean install -DskipTests -Pgenerate-docs' again"
exit 1
fi
- name: Validate helm chart linting
run: |
helm lint helm/flink-kubernetes-operator
- name: Tests in flink-kubernetes-operator
run: |
cd flink-kubernetes-operator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
################################################################################
# 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 Cert Manager Certificate

templates:
- cert-manager/certificate.yaml

release:
name: flink-operator
namespace: flink-operator

tests:
- it: Should create certificate
asserts:
- containsDocument:
apiVersion: cert-manager.io/v1
kind: Certificate
name: flink-operator-serving-cert

- it: Should use self signed issuer
asserts:
- equal:
path: spec.issuerRef
value:
kind: Issuer
name: flink-operator-selfsigned-issuer
34 changes: 34 additions & 0 deletions helm/flink-kubernetes-operator/tests/cert-manager/issuer_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
################################################################################
# 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 Cert Manager Issuer

templates:
- cert-manager/issuer.yaml

release:
name: flink-operator
namespace: flink-operator

tests:
- it: Should create self signed Issuer
asserts:
- containsDocument:
apiVersion: cert-manager.io/v1
kind: Issuer
name: flink-operator-selfsigned-issuer
Original file line number Diff line number Diff line change
@@ -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 ConfigMap

templates:
- controller/configmap.yaml

release:
name: flink-operator
namespace: flink-operator

tests:
- it: Should create a configmap with default configuration if `defaultConfiguration.create` is `true`
set:
defaultConfiguration:
create: true
asserts:
- containsDocument:
apiVersion: v1
kind: ConfigMap
name: flink-operator-config
namespace: flink-operator
Loading