Skip to content

Commit f0ae10e

Browse files
committed
Implement helm add & install in helm e2e test
1 parent 51f2794 commit f0ae10e

File tree

3 files changed

+101
-2
lines changed

3 files changed

+101
-2
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ require (
106106
github.com/spf13/pflag v1.0.5 // indirect
107107
github.com/stoewer/go-strcase v1.2.0 // indirect
108108
github.com/stretchr/objx v0.5.2 // indirect
109+
github.com/vladimirvivien/gexe v0.2.0 // indirect
109110
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
110111
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
111112
go.etcd.io/etcd/client/v3 v3.5.10 // indirect
@@ -148,6 +149,7 @@ require (
148149
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
149150
k8s.io/mount-utils v0.25.0 // indirect
150151
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 // indirect
152+
sigs.k8s.io/e2e-framework v0.4.0
151153
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
152154
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
153155
)

go.sum

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4
133133
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
134134
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 h1:6UKoz5ujsI55KNpsJH3UwCq3T8kKbZwNZBNPuTTje8U=
135135
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1/go.mod h1:YvJ2f6MplWDhfxiUC3KpyTy76kYUZA4W3pTv/wdKQ9Y=
136-
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
137-
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
136+
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
137+
github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
138138
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
139139
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
140140
github.com/jaypipes/ghw v0.12.0 h1:xU2/MDJfWmBhJnujHY9qwXQLs3DBsf0/Xa9vECY0Tho=
@@ -256,6 +256,8 @@ github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJ
256256
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
257257
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
258258
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
259+
github.com/vladimirvivien/gexe v0.2.0 h1:nbdAQ6vbZ+ZNsolCgSVb9Fno60kzSuvtzVh6Ytqi/xY=
260+
github.com/vladimirvivien/gexe v0.2.0/go.mod h1:LHQL00w/7gDUKIak24n801ABp8C+ni6eBht9vGVst8w=
259261
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
260262
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
261263
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -446,6 +448,8 @@ k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSn
446448
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
447449
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 h1:/U5vjBbQn3RChhv7P11uhYvCSm5G2GaIi5AIGBS6r4c=
448450
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0/go.mod h1:z7+wmGM2dfIiLRfrC6jb5kV2Mq/sK1ZP303cxzkV5Y4=
451+
sigs.k8s.io/e2e-framework v0.4.0 h1:4yYmFDNNoTnazqmZJXQ6dlQF1vrnDbutmxlyvBpC5rY=
452+
sigs.k8s.io/e2e-framework v0.4.0/go.mod h1:JilFQPF1OL1728ABhMlf9huse7h+uBJDXl9YeTs49A8=
449453
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
450454
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
451455
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=

test/e2e/helm_test.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
package e2e
17+
18+
import (
19+
"context"
20+
"os"
21+
"path/filepath"
22+
"time"
23+
24+
. "github.com/onsi/ginkgo/v2"
25+
. "github.com/onsi/gomega"
26+
27+
"k8s.io/kubernetes/test/e2e/framework"
28+
"sigs.k8s.io/e2e-framework/third_party/helm"
29+
30+
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31+
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
32+
admissionapi "k8s.io/pod-security-admission/api"
33+
)
34+
35+
// Helm based test suite
36+
var _ = NFDDescribe(Label("helm"), func() {
37+
f := framework.NewDefaultFramework("node-feature-discovery")
38+
// To avoid the error of violating the PodSecurity
39+
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
40+
41+
manager := helm.New(framework.TestContext.KubeConfig)
42+
release_name := "node-feature-discovery"
43+
44+
Context("when deploying by helm", Ordered, func() {
45+
JustBeforeEach(func(ctx context.Context) {
46+
workingDir, err := os.Getwd()
47+
chartPath := filepath.Join(workingDir, "../../", "deployment", "helm", "node-feature-discovery")
48+
Expect(err).NotTo(HaveOccurred())
49+
By("helm install " + release_name + " " + chartPath + " --namespace " + f.Namespace.Name + " --wait")
50+
err = manager.RunInstall(
51+
helm.WithName(release_name),
52+
helm.WithNamespace(f.Namespace.Name),
53+
helm.WithChart(chartPath),
54+
helm.WithWait(),
55+
)
56+
Expect(err).NotTo(HaveOccurred())
57+
58+
// Show all pods
59+
pods, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).List(ctx, v1.ListOptions{})
60+
Expect(err).NotTo(HaveOccurred())
61+
for _, pod := range pods.Items {
62+
By("Pod name: " + pod.Name)
63+
}
64+
// Get the name of the master pod
65+
masterPods, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).List(ctx, v1.ListOptions{LabelSelector: "role=master"})
66+
Expect(err).NotTo(HaveOccurred())
67+
Expect(len(masterPods.Items)).To(Equal(1))
68+
// Wait for the master pod to be running
69+
Expect(e2epod.WaitTimeoutForPodRunningInNamespace(ctx, f.ClientSet, masterPods.Items[0].Name, f.Namespace.Name, time.Minute)).NotTo(HaveOccurred())
70+
})
71+
72+
AfterEach(func(ctx context.Context) {
73+
manager := helm.New(framework.TestContext.KubeConfig)
74+
By("helm uninstall " + release_name + " --namespace " + f.Namespace.Name)
75+
err := manager.RunUninstall(
76+
helm.WithReleaseName(release_name),
77+
helm.WithNamespace(f.Namespace.Name),
78+
)
79+
Expect(err).NotTo(HaveOccurred())
80+
})
81+
82+
//
83+
// Test nfd deployed by Helm
84+
//
85+
Context("and nfd deployed by Helm", func() {
86+
It("Deployment is running successfully", Label("Helm"), func(ctx context.Context) {
87+
})
88+
89+
It("Deployment with helm again is running successfully", Label("Helm"), func(ctx context.Context) {
90+
})
91+
})
92+
})
93+
})

0 commit comments

Comments
 (0)