istio
119 строк · 3.9 Кб
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 helmupgrade
19
20import (
21"testing"
22
23"github.com/Masterminds/semver/v3"
24
25"istio.io/istio/pkg/test/env"
26"istio.io/istio/pkg/test/framework"
27"istio.io/istio/pkg/test/framework/resource"
28"istio.io/istio/pkg/util/image"
29)
30
31var (
32previousSupportedVersion string
33nMinusTwoVersion string
34)
35
36const imageToCheck = "gcr.io/istio-release/pilot"
37
38func initVersions(ctx resource.Context) error {
39versionFromFile, err := env.ReadVersion()
40if err != nil {
41return err
42}
43
44v, err := semver.NewVersion(versionFromFile)
45if err != nil {
46return err
47}
48
49previousVersion := semver.New(v.Major(), v.Minor()-1, v.Patch(), v.Prerelease(), v.Metadata())
50
51// If the previous version is not published yet, use the latest one
52if exists, err := image.Exists(imageToCheck + ":" + previousVersion.String()); err != nil {
53return err
54} else if !exists {
55previousVersion = semver.New(v.Major(), v.Minor()-2, v.Patch(), v.Prerelease(), v.Metadata())
56}
57
58previousSupportedVersion = previousVersion.String()
59nMinusTwoVersion = semver.New(previousVersion.Major(), previousVersion.Minor()-1, previousVersion.Patch(),
60previousVersion.Prerelease(), previousVersion.Metadata()).String()
61
62// Workaround publish issues
63if previousSupportedVersion == "1.17.0" {
64previousSupportedVersion = "1.17.1"
65}
66if nMinusTwoVersion == "1.17.0" {
67nMinusTwoVersion = "1.17.1"
68}
69
70return nil
71}
72
73// TestDefaultInPlaceUpgradeFromPreviousMinorRelease tests Istio upgrade using Helm with default options for Istio 1.(n-1)
74func TestDefaultInPlaceUpgradeFromPreviousMinorRelease(t *testing.T) {
75framework.
76NewTest(t).
77Features("installation.helm.default.upgrade").
78Run(performInPlaceUpgradeFunc(previousSupportedVersion, false))
79}
80
81// TestCanaryUpgradeFromPreviousMinorRelease tests Istio upgrade using Helm with default options for Istio 1.(n-1)
82func TestCanaryUpgradeFromPreviousMinorRelease(t *testing.T) {
83framework.
84NewTest(t).
85Features("installation.helm.default.upgrade").
86Run(performCanaryUpgradeFunc(previousSupportedVersion))
87}
88
89// TestCanaryUpgradeFromTwoMinorRelease tests Istio upgrade using Helm with default options for Istio 1.(n-2)
90func TestCanaryUpgradeFromTwoMinorRelease(t *testing.T) {
91framework.
92NewTest(t).
93Features("installation.helm.default.upgrade").
94Run(performCanaryUpgradeFunc(nMinusTwoVersion))
95}
96
97// TestStableRevisionLabelsUpgradeFromPreviousMinorRelease tests Istio upgrade using Helm with default options for Istio 1.(n-1)
98func TestStableRevisionLabelsUpgradeFromPreviousMinorRelease(t *testing.T) {
99framework.
100NewTest(t).
101Features("installation.helm.default.upgrade").
102Run(performRevisionTagsUpgradeFunc(previousSupportedVersion))
103}
104
105// TestStableRevisionLabelsUpgradeFromTwoMinorRelease tests Istio upgrade using Helm with default options for Istio 1.(n-2)
106func TestStableRevisionLabelsUpgradeFromTwoMinorRelease(t *testing.T) {
107framework.
108NewTest(t).
109Features("installation.helm.default.upgrade").
110Run(performRevisionTagsUpgradeFunc(nMinusTwoVersion))
111}
112
113// TestAmbientInPlaceUpgradeFromPreviousMinorRelease tests Istio upgrade using Helm with ambient profile for Istio 1.(n-1)
114func TestAmbientInPlaceUpgradeFromPreviousMinorRelease(t *testing.T) {
115framework.
116NewTest(t).
117Features("installation.helm.ambient.upgrade").
118Run(performInPlaceUpgradeFunc(previousSupportedVersion, true))
119}
120