Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Use factored out testing lib #5231

Merged
merged 27 commits into from
Jun 6, 2018
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
37c1e0e
[WIP][CI] Use factored out testing lib
unguiculus Apr 24, 2018
867adc9
Incorporate upstream changes
unguiculus Apr 26, 2018
867c401
Update Docker image for CircleCI
unguiculus Apr 30, 2018
2db254e
Update Docker image
unguiculus May 2, 2018
48dfd2e
Update Docker image
unguiculus May 4, 2018
cd3ff2c
Merge remote-tracking branch 'upstream/master' into feature/testing
unguiculus May 7, 2018
a6dd62d
Align with upstream changes
unguiculus May 7, 2018
65939b8
Remove dummy chart and bump a few charts for testing
unguiculus May 7, 2018
d531b40
Fix Dockerfile
unguiculus May 7, 2018
2f7f9e3
Align with upstream changes
unguiculus May 7, 2018
fca430b
Add summary
unguiculus May 7, 2018
98b9931
Update Chart.yaml
May 7, 2018
265493b
Update Docker images
unguiculus May 7, 2018
d414764
Remove chart test bumps
unguiculus May 7, 2018
03bd34a
Merge remote-tracking branch 'upstream/master' into feature/testing
unguiculus May 14, 2018
e98f9d6
Align with upstream changes
unguiculus May 14, 2018
513e8d9
Bump some charts for testing
unguiculus May 14, 2018
b649c81
Create v2.0.0
unguiculus May 23, 2018
e658f2c
Merge remote-tracking branch 'upstream/master' into feature/testing
unguiculus May 23, 2018
73f0aa5
Remove chart version bumps
unguiculus May 23, 2018
0207761
Merge remote-tracking branch 'upstream/master' into feature/testing
unguiculus May 29, 2018
312cf46
Merge remote-tracking branch 'upstream/master' into feature/testing
unguiculus May 30, 2018
7819365
Merge remote-tracking branch 'upstream/master' into feature/testing
unguiculus May 31, 2018
9daafe6
Revert repo-sync.sh in favor of #5847
unguiculus May 31, 2018
1494062
Bump image version
unguiculus Jun 6, 2018
dca6ef5
Use latest chart testing image
unguiculus Jun 6, 2018
2110053
Merge remote-tracking branch 'upstream/master' into feature/testing
unguiculus Jun 6, 2018
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
27 changes: 20 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
version: 2
jobs:
build:
lint-scripts:
docker:
- image: circleci/python:3.6.4
- image: koalaman/shellcheck-alpine
steps:
- checkout
- run:
name: install tools
command: test/circle/install.sh
name: lint
command: |
shellcheck -x test/build.sh
shellcheck -x test/e2e.sh
shellcheck -x test/helm-test-e2e.sh
shellcheck -x test/repo-sync.sh
lint-charts:
docker:
- image: gcr.io/kubernetes-charts-ci/test-image:v2.0.0
steps:
- checkout
- run:
name: lint
command: test/circle/lint.sh
command: |
git remote add k8s https://github.com/kubernetes/charts
git fetch k8s master
chart_test.sh --config test/.testenv --no-install
sync:
docker:
- image: google/cloud-sdk
Expand All @@ -21,9 +33,10 @@ jobs:
command: test/repo-sync.sh
workflows:
version: 2
test:
lint:
jobs:
- build
- lint-scripts
- lint-charts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Since this name is changing from build the required tests for branch will need to change when this goes in.

sync:
triggers:
- schedule:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ Session.vim
.netrwhist

# Chart dependencies
**/charts/*.tgz
**/charts/*.tgz

.history
2 changes: 2 additions & 0 deletions test/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
! .testenv
23 changes: 23 additions & 0 deletions test/.testenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# The name of the Git remote
REMOTE=k8s

# The name of the Git target branch
TARGET_BRANCH=master

# Chart directories separated by a space
CHART_DIRS=(
stable
incubator
)

# Charts that should be skipped
EXCLUDED_CHARTS=(
common
)

# Additional chart repos to add (<name>=<url>), separated by a space
CHART_REPOS=(
incubator=https://kubernetes-charts-incubator.storage.googleapis.com/
)

TIMEOUT=600
54 changes: 14 additions & 40 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2016 The Kubernetes Authors All rights reserved.
# Copyright 2018 The Kubernetes Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,45 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM debian:8.5
FROM gcr.io/kubernetes-charts-ci/chart-testing:v1.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the source for this FROM? It's under our control which is why I'm curious.

Side note, I'm starting to ponder Quay because of the container image security scanning.

Copy link
Member Author

@unguiculus unguiculus Jun 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the image containing the new factored out testing stuff.


ENV CLOUDSDK_CORE_DISABLE_PROMPTS=1 \
PATH=/opt/google-cloud-sdk/bin:$PATH \
GOOGLE_CLOUD_SDK_VERSION=154.0.0 \
GOOGLE_PROJECT=kubernetes-charts-ci
ENV PATH /google-cloud-sdk/bin:$PATH
ARG CLOUD_SDK_VERSION=202.0.0
RUN curl -LO "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-$CLOUD_SDK_VERSION-linux-x86_64.tar.gz" && \
tar xzf "google-cloud-sdk-$CLOUD_SDK_VERSION-linux-x86_64.tar.gz" && \
rm "google-cloud-sdk-$CLOUD_SDK_VERSION-linux-x86_64.tar.gz" && \
ln -s /lib /lib64 && \
rm -rf /google-cloud-sdk/.install/.backup && \
gcloud version

RUN set -x \
&& cd /opt \
&& echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
&& apt-get update \
&& apt-get install --no-install-recommends -y jq wget python git localepurge ca-certificates \
&& wget -q https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& tar zxfv google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& ./google-cloud-sdk/install.sh \
&& gcloud components install kubectl \
&& gcloud config set project ${GOOGLE_PROJECT}
RUN apt-get -y purge localepurge \
&& apt-get clean \
&& cd / \
&& rm -rf \
/opt/google-cloud-sdk-${GOOGLE_CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
/opt/helm-${HELM_VERSION}-linux-amd64.tar.gz \
doc \
man \
info \
locale \
/var/lib/apt/lists/* \
/var/log/* \
/var/cache/debconf/* \
common-licenses \
~/.bashrc \
/etc/systemd \
/lib/lsb \
/lib/udev \
/usr/share/doc/ \
/usr/share/doc-base/ \
/usr/share/man/ \
/tmp/*
RUN gcloud config set core/disable_usage_reporting true && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment github_docker_image

VOLUME "/src"
WORKDIR "/src"
WORKDIR /workdir
13 changes: 2 additions & 11 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,10 @@ The configuration of the Pull Request trigger is [in the config.json](https://gi

This snippet tells Test Infra to run the [test/e2e.sh](https://github.com/kubernetes/charts/blob/master/test/e2e.sh)
when testing is triggered on a pull request. The e2e.sh script will use the [Charts test image](https://github.com/kubernetes/charts/blob/master/test/Dockerfile)
to run the [test/changed.sh](https://github.com/kubernetes/charts/blob/master/test/changed.sh) script. This script
to run the [chart_test.sh](https://github.com/kubernetes-helm/chart-testing/blob/master/chart_test.sh) script. This script
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this chart_test.sh link is broken

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The links should work once helm/chart-testing#1 is merged.

is the main logic for validation of a pull request. It intends to only test charts that have changed in this PR.

The logic is as follows:

1. [Get credentials for the Kubernetes cluster used for testing.](https://github.com/kubernetes/charts/blob/master/test/changed.sh#L128)
1. [Install and initialize Helm](https://github.com/kubernetes/charts/blob/master/test/changed.sh#L143)
1. [For any charts that have changed](https://github.com/kubernetes/charts/blob/master/test/changed.sh#L161):
- Download dependent charts, if any, with `helm dep build`
- Run `helm install` in a new namespace for this PR build
- Use the [test/verify-release.sh](https://github.com/kubernetes/charts/blob/master/test/verify-release.sh) to ensure that if any pods were launched that they get to the `Running` state
- Run `helm test` on the release
- Delete the release
The testing logic has been extrated to the [chart-testing](https://github.com/kubernetes-helm/chart-testing) project. A bash library provides the required logic to lint, install, and test charts. It is provided as a Docker image and can be run by anyone on their own charts.

#### Providing Custom Test Values

Expand Down
74 changes: 74 additions & 0 deletions test/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash

# Copyright 2018 The Kubernetes Authors. All rights reserved.
#
# Licensed 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.

set -o errexit
set -o nounset
set -o pipefail

readonly IMAGE_TAG=v2.0.0
readonly IMAGE_REPOSITORY="gcr.io/kubernetes-charts-ci/test-image"
readonly SCRIPT_DIR=$(dirname "$(readlink -f "$0")")

show_help() {
cat << EOF
Usage: ${0##*/} <args>
-h, --help Display help
-v, --verbose Display verbose output
-p, --push Push image to registry
EOF
}

main() {
local verbose=
local push=

while :; do
case "${1:-}" in
-h|--help)
show_help
exit
;;
-v|--verbose)
verbose=true
;;
-p|--push)
push=true
;;
-?*)
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
;;
*)
break
;;
esac

shift
done

[[ -n "$verbose" ]] && set -o xtrace

pushd "$SCRIPT_DIR"

docker build --tag "$IMAGE_REPOSITORY:$IMAGE_TAG" .

if [[ -n "$push" ]]; then
docker push "$IMAGE_REPOSITORY:$IMAGE_TAG"
fi

popd
}

main "$@"
Loading