Skip to content

Commit

Permalink
Rebase on top of upstream/main and squash Red Hat/Openshift downstrea…
Browse files Browse the repository at this point in the history
…m commits

-update pip to pip3

-run openshift tests

-Fix test data deployment version

-Install PV before test setup and fix deamon set tests

-Add helm dir in .acceptance

-Change to use current helm bin

-Disable test for version greater than 3.1

-Create blank.yml

-Enable tests related to Helm 3.2 bin. (#2)

-Add openshift cluster provider (#6)
* Run acceptance tests against provided k8s cluster
* Add openshift cluster provider

-Fix kubeVersion to support kube pre-releases (helm/helm#6190) (#9)

-Remove obsolete and redundand test cases from kubernetes_versions.robot (#12)

-Adjust completion test according to helm 3.4 flags (#11)

-Fixes the completion tests failure by adjusting tests according to new changes flags changes in helm 3.4.

Signed-off-by: Pavel Macík <pavel.macik@gmail.com>
  • Loading branch information
akashshinde authored and pmacik committed Oct 26, 2021
1 parent 6ae13e0 commit 281777b
Show file tree
Hide file tree
Showing 25 changed files with 450 additions and 23 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/blank.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: acceptance-tests

on:
push:
branches:
- master
jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v1

- name: Run acceptance tests
run: make github-actions-ci

- uses: actions/upload-artifact@master
name: Upload test report
with:
name: helm-acceptance-testing-report-${{ github.sha }}
path: acceptance-testing-reports/${{ github.sha }}/
if: always()
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ github-actions-ci-local:
-w /tmp/acceptance-testing \
--privileged -v /var/run/docker.sock:/var/run/docker.sock \
--entrypoint=/bin/bash ubuntu:latest \
-c 'set +e; scripts/github-actions-ci.sh; echo "Exited $?. (Ctrl+D to exit shell)"; bash'
-c 'set +e; scripts/github-actions-ci.sh; echo "Exited $?. (Ctrl+D to exit shell)"; bash'
14 changes: 11 additions & 3 deletions lib/Helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
import common
from ClusterProvider import auth_wrap

TEST_CHARTS_ROOT_DIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) +'/../testdata/charts')
TEST_CHARTS_ROOT_DIR = os.path.abspath(os.path.dirname(
os.path.realpath(__file__)) + '/../testdata/charts')


class Helm(common.CommandRunner):
def get_chart_path(self, test_chart):
provider = os.getenv("CLUSTER_PROVIDER", default='')
if provider == '':
return test_chart
return f'{TEST_CHARTS_ROOT_DIR}/{provider}-{test_chart}'

def install_test_chart(self, release_name, test_chart, extra_args):
chart_path = TEST_CHARTS_ROOT_DIR+'/'+test_chart
cmd = 'helm install '+release_name+' '+chart_path+' '+extra_args
cmd = 'helm install '+release_name+' ' + \
self.get_chart_path(test_chart) + ' '+extra_args
self.run_command(auth_wrap(cmd))
7 changes: 5 additions & 2 deletions lib/Kubectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ def persistent_volume_claim_is_bound(self, namespace, pvc_name):
def pods_with_prefix_are_running(self, namespace, pod_prefix, num_expected):
cmd = '[ `kubectl get pods --namespace='+namespace
cmd += ' | grep ^'+pod_prefix+' | awk \'{print $2 "--" $3}\''
cmd += ' | grep -E "^([1-9][0-9]*)/\\1--Running" | wc -l` == ' + \
num_expected+' ]'
cmd += ' | grep -E "^([1-9][0-9]*)/\\1--Running" | wc -l` == '+num_expected+' ]'
self.run_command(auth_wrap(cmd))

def deamon_set_pods_with_prefix(self, namespace, pod_prefix):
cmd = 'kubectl get nodes | grep Ready | wc -l'
self.run_command(auth_wrap(cmd))
self.pods_with_prefix_are_running(namespace, pod_prefix, self.stdout)
4 changes: 2 additions & 2 deletions scripts/acceptance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set_shell_debug_level 2
REQUIRED_SYSTEM_COMMANDS=(
"kubectl"
"python3"
"pip"
"pip3"
"virtualenv"
)

Expand Down Expand Up @@ -133,7 +133,7 @@ fi
set_shell_debug_level 2
if [[ ! -d ${ROBOT_VENV_DIR} ]]; then
virtualenv -p $(which python3) ${ROBOT_VENV_DIR}
pip install ${ROBOT_PY_REQUIRES}
pip3 install ${ROBOT_PY_REQUIRES}
fi

# Run Robot Framework, output
Expand Down
3 changes: 3 additions & 0 deletions scripts/cluster_providers/openshift_cleanup_all_test_clusters
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "No need to cleanup cluster"
23 changes: 23 additions & 0 deletions scripts/cluster_providers/openshift_create_cluster
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

echo "No need to create cluster"
export KUBECONFIG=$2
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolume
metadata:
name: test-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: standard
nfs:
path: /tmp
server: 172.17.0.2
EOF

echo "Sleep for 10 secs"
sleep 10
5 changes: 5 additions & 0 deletions scripts/cluster_providers/openshift_delete_cluster
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

export KUBECONFIG=$2
kubectl delete pv test-pv
echo "Not deleting external cluster"
3 changes: 3 additions & 0 deletions scripts/cluster_providers/openshift_get_cluster_auth
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "export KUBECONFIG=$2"
3 changes: 3 additions & 0 deletions scripts/cluster_providers/openshift_wait_for_cluster
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "No need to wait for externally created cluster"
2 changes: 1 addition & 1 deletion scripts/completion-tests/test-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,4 @@ if [ "$(uname)" == "Darwin" ]; then
fi

# Indicate if anything failed during the run
exit ${GOT_FAILURE}
exit ${GOT_FAILURE}
36 changes: 36 additions & 0 deletions scripts/ensure-cluster-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash -e
#
# Copyright The Helm Authors.
#
# 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.

# Create a persistance volume with standard storageclass
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolume
metadata:
name: test-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: standard
nfs:
path: /tmp
server: 172.17.0.2
EOF

echo "Sleep for 10 secs"
sleep 10
2 changes: 1 addition & 1 deletion testdata/charts/nginx/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords:
- nginx
- www
- web
kubeVersion: '>=1.2.0'
kubeVersion: '>=1.2.0-0'
maintainers: []
name: nginx
sources:
Expand Down
6 changes: 3 additions & 3 deletions testdata/charts/nginx/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nginx.fullname" . }}-ext
Expand Down Expand Up @@ -37,7 +37,7 @@ spec:
- "echo bar | grep {{ if .Values.breakme }}foo{{ else }}bar{{ end }}"

---
apiVersion: apps/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nginx.fullname" . }}-v1beta1
Expand Down Expand Up @@ -76,7 +76,7 @@ spec:
- "echo bar | grep {{ if .Values.breakme }}foo{{ else }}bar{{ end }}"

---
apiVersion: apps/v1beta2
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nginx.fullname" . }}-v1beta2
Expand Down
5 changes: 5 additions & 0 deletions testdata/charts/openshift-nginx/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
.git
14 changes: 14 additions & 0 deletions testdata/charts/openshift-nginx/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
description: A basic NGINX HTTP server
home: https://github.com/helm/helm
keywords:
- http
- nginx
- www
- web
kubeVersion: '>=1.2.0-0'
maintainers: []
name: nginx
sources:
- https://hub.docker.com/_/nginx/
version: 0.1.0
1 change: 1 addition & 0 deletions testdata/charts/openshift-nginx/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sample notes for {{ .Chart.Name }}
16 changes: 16 additions & 0 deletions testdata/charts/openshift-nginx/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "nginx.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "nginx.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
154 changes: 154 additions & 0 deletions testdata/charts/openshift-nginx/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nginx.fullname" . }}-ext
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ template "nginx.name" . }}-ext
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ template "nginx.name" . }}-ext
template:
metadata:
labels:
app.kubernetes.io/name: {{ template "nginx.name" . }}-ext
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ template "nginx.name" . }}
image: "alpine:latest"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sleep
- "50000"
ports:
- name: http
containerPort: 80
protocol: TCP
readinessProbe:
exec:
command:
- sh
- "-c"
- "echo bar | grep {{ if .Values.breakme }}foo{{ else }}bar{{ end }}"

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nginx.fullname" . }}-v1beta1
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1beta1
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1beta1
template:
metadata:
labels:
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1beta1
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ template "nginx.name" . }}
image: "alpine:latest"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sleep
- "50000"
ports:
- name: http
containerPort: 80
protocol: TCP
readinessProbe:
exec:
command:
- sh
- "-c"
- "echo bar | grep {{ if .Values.breakme }}foo{{ else }}bar{{ end }}"

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nginx.fullname" . }}-v1beta2
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1beta2
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1beta2
template:
metadata:
labels:
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1beta2
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ template "nginx.name" . }}
image: "alpine:latest"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sleep
- "50000"
ports:
- name: http
containerPort: 80
protocol: TCP
readinessProbe:
exec:
command:
- sh
- "-c"
- "echo bar | grep {{ if .Values.breakme }}foo{{ else }}bar{{ end }}"

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nginx.fullname" . }}-v1
labels:
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1
template:
metadata:
labels:
app.kubernetes.io/name: {{ template "nginx.name" . }}-v1
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ template "nginx.name" . }}
image: "alpine:latest"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- sleep
- "50000"
ports:
- name: http
containerPort: 80
protocol: TCP
readinessProbe:
exec:
command:
- sh
- "-c"
- "echo bar | grep {{ if .Values.breakme }}foo{{ else }}bar{{ end }}"

0 comments on commit 281777b

Please sign in to comment.