istio
86 строк · 2.5 Кб
1//go:build integ
2// +build integ
3
4// Copyright Istio Authors
5//
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18package helm
19
20import (
21"fmt"
22"os"
23"path/filepath"
24"testing"
25
26"istio.io/istio/pkg/test/framework"
27kubecluster "istio.io/istio/pkg/test/framework/components/cluster/kube"
28"istio.io/istio/pkg/test/framework/components/namespace"
29"istio.io/istio/pkg/test/helm"
30"istio.io/istio/tests/util/sanitycheck"
31)
32
33// TestDefaultInstall tests Istio installation using Helm with default options
34func TestDefaultInstall(t *testing.T) {
35overrideValuesStr := `
36global:
37hub: %s
38tag: %s
39`
40framework.
41NewTest(t).
42Features("installation.helm.default.install").
43Run(setupInstallation(overrideValuesStr, false))
44}
45
46// TestAmbientInstall tests Istio ambient profile installation using Helm
47func TestAmbientInstall(t *testing.T) {
48framework.
49NewTest(t).
50Features("installation.helm.ambient.install").
51Run(setupInstallation(ambientProfileOverride, true))
52}
53
54func setupInstallation(overrideValuesStr string, isAmbient bool) func(t framework.TestContext) {
55return func(t framework.TestContext) {
56workDir, err := t.CreateTmpDirectory("helm-install-test")
57if err != nil {
58t.Fatal("failed to create test directory")
59}
60cs := t.Clusters().Default().(*kubecluster.Cluster)
61h := helm.New(cs.Filename())
62s := t.Settings()
63overrideValues := fmt.Sprintf(overrideValuesStr, s.Image.Hub, s.Image.Tag)
64overrideValuesFile := filepath.Join(workDir, "values.yaml")
65if err := os.WriteFile(overrideValuesFile, []byte(overrideValues), os.ModePerm); err != nil {
66t.Fatalf("failed to write iop cr file: %v", err)
67}
68t.Cleanup(func() {
69if !t.Failed() {
70return
71}
72if t.Settings().CIMode {
73namespace.Dump(t, IstioNamespace)
74}
75})
76InstallIstio(t, cs, h, overrideValuesFile, "", true, isAmbient)
77
78VerifyInstallation(t, cs, true, isAmbient)
79verifyValidation(t)
80
81sanitycheck.RunTrafficTest(t, t)
82t.Cleanup(func() {
83DeleteIstio(t, h, cs, isAmbient)
84})
85}
86}
87