|
| 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 | + // Install local nfd chart |
| 47 | + workingDir, err := os.Getwd() |
| 48 | + chartPath := filepath.Join(workingDir, "../../", "deployment", "helm", "node-feature-discovery") |
| 49 | + Expect(err).NotTo(HaveOccurred()) |
| 50 | + By("helm install " + release_name + " " + chartPath + " --namespace " + f.Namespace.Name + " --wait") |
| 51 | + err = manager.RunInstall( |
| 52 | + helm.WithName(release_name), |
| 53 | + helm.WithNamespace(f.Namespace.Name), |
| 54 | + helm.WithChart(chartPath), |
| 55 | + helm.WithWait(), |
| 56 | + ) |
| 57 | + Expect(err).NotTo(HaveOccurred()) |
| 58 | + |
| 59 | + // Show all pods |
| 60 | + pods, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).List(ctx, v1.ListOptions{}) |
| 61 | + Expect(err).NotTo(HaveOccurred()) |
| 62 | + for _, pod := range pods.Items { |
| 63 | + By("Pod name: " + pod.Name) |
| 64 | + } |
| 65 | + // Get the name of the master pod |
| 66 | + masterPods, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).List(ctx, v1.ListOptions{LabelSelector: "role=master"}) |
| 67 | + Expect(err).NotTo(HaveOccurred()) |
| 68 | + Expect(len(masterPods.Items)).To(Equal(1)) |
| 69 | + // Wait for the master pod to be running |
| 70 | + Expect(e2epod.WaitTimeoutForPodRunningInNamespace(ctx, f.ClientSet, masterPods.Items[0].Name, f.Namespace.Name, time.Minute)).NotTo(HaveOccurred()) |
| 71 | + }) |
| 72 | + |
| 73 | + AfterEach(func(ctx context.Context) { |
| 74 | + // Uninstall nfd |
| 75 | + By("helm uninstall " + release_name + " --namespace " + f.Namespace.Name) |
| 76 | + err := manager.RunUninstall( |
| 77 | + helm.WithReleaseName(release_name), |
| 78 | + helm.WithNamespace(f.Namespace.Name), |
| 79 | + ) |
| 80 | + Expect(err).NotTo(HaveOccurred()) |
| 81 | + }) |
| 82 | + |
| 83 | + // |
| 84 | + // Test nfd deployed by Helm |
| 85 | + // |
| 86 | + Context("and nfd deployed by Helm", func() { |
| 87 | + It("Deployment is running successfully", Label("Helm"), func(ctx context.Context) { |
| 88 | + }) |
| 89 | + |
| 90 | + It("Deployment with helm again is running successfully", Label("Helm"), func(ctx context.Context) { |
| 91 | + }) |
| 92 | + }) |
| 93 | + }) |
| 94 | +}) |
0 commit comments