Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Support for verification of the Helm charts using BDD approach #100

Merged
merged 67 commits into from
Mar 25, 2020

Conversation

mdelapenya
Copy link
Contributor

@mdelapenya mdelapenya commented Mar 12, 2020

What is this PR doing?

It creates the first feature file and the implementation of the steps for verifying that the Elastic's Helm charts for Metricbeat are correct.

For that, each step in the feature file will represent each of the verification points required for the Helm chart.

The implementation of each step will leverage the local binaries for helm and kubectl, so each step will run different commands for these tools reading the output and checking those values.

The test cluster will be managed by kind, and the binaries needed for it (kind, kubectl, helm) are installed by the shell script that runs the e2e tests.

Why is it important?

We are going to manually verify the Helm charts, but adding this automated test suite will support the verification of the charts with any frequency: with a PR, on each release, on feature freeze, etc.

How to test this PR?

  1. Please check that you have helm and kubectl installed in your local machine.
  2. From the e2e directory, run:
$ godog -t helm

Related issues

@mdelapenya mdelapenya self-assigned this Mar 12, 2020
@mdelapenya mdelapenya requested review from a team and jsoriano March 12, 2020 10:08

func (ts *HelmChartTestSuite) podsManagedByDaemonSet() error {
args := []string{
"get", "daemonsets", "--namespace=default", "-l", "app=" + ts.Name + "-" + ts.Name, "-o", "jsonpath='{.items[0].metadata.labels.chart}'",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kuisathaverat is this enough to check that a DaemonSet exists for the chart?

Copy link
Contributor

Choose a reason for hiding this comment

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

This only ensures that the DaemonSet is deployed, but the DaemonSet pods can be in fail, so you have to check if the number of scheduled pods is the same as the pods ready(maybe is redundant) and the pods available.

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#daemonset-v1-apps

kubectl get -n kube-system daemonset metricbeat -o jsonpath='{.status.currentNumberScheduled}'
kubectl get -n kube-system daemonset metricbeat -o jsonpath='{.status.numberAvailable}'
kubectl get -n kube-system daemonset metricbeat -o jsonpath='{.status.numberReady}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't it mean we are checking that k8s is doing its job? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

no, you are checking the configuration settings of the pods are correct and can deploy

# install kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we use sudo in a worker? Otherwise this will fail

Copy link
Contributor

Choose a reason for hiding this comment

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

no, we can not, because of that we install everything in the Jenkins workspace job

@mdelapenya
Copy link
Contributor Author

Sample execution:
Screenshot 2020-03-12 at 15 20 26

.ci/scripts/install-test-dependencies.sh Outdated Show resolved Hide resolved
cli/internal/git.go Outdated Show resolved Hide resolved
cli/internal/git.go Outdated Show resolved Hide resolved
@kuisathaverat
Copy link
Contributor

this will work only with Helm 2.x, the commands are a little different for Helm 3.x

@mdelapenya
Copy link
Contributor Author

this will work only with Helm 2.x, the commands are a little different for Helm 3.x

I'm using Helm 3:

$ helm version
version.BuildInfo{Version:"v3.1.1", GitCommit:"afe70585407b420d0097d07b21c47dc511525ac8", GitTreeState:"clean", GoVersion:"go1.13.8"}

@kuisathaverat
Copy link
Contributor

I'm using Helm 3:

ouch!!, in that case, is the other way around would not work on Helm 2.x

We will make the test to fail, instead of making the build to fail.
On the other hand, we should add those tools to the linux workers to make
the tests pass
It would be an implementation detail, so meaningless at high level perspective
e2e/helm_charts_test.go Outdated Show resolved Hide resolved
e2e/helm_charts_test.go Outdated Show resolved Hide resolved
@mdelapenya mdelapenya changed the title [WIP] Support for verification of the Helm charts using BDD approach Support for verification of the Helm charts using BDD approach Mar 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate Helm charts
5 participants