-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Use factored out testing lib #5231
Changes from 24 commits
37c1e0e
867adc9
867c401
2db254e
48dfd2e
cd3ff2c
a6dd62d
65939b8
d531b40
2f7f9e3
fca430b
98b9931
265493b
d414764
03bd34a
e98f9d6
513e8d9
b649c81
e658f2c
73f0aa5
0207761
312cf46
7819365
9daafe6
1494062
dca6ef5
2110053
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,6 @@ Session.vim | |
.netrwhist | ||
|
||
# Chart dependencies | ||
**/charts/*.tgz | ||
**/charts/*.tgz | ||
|
||
.history |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
! .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 |
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. | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this chart_test.sh link is broken There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
||
|
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 "$@" |
There was a problem hiding this comment.
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.