Skip to content

Commit 162f146

Browse files
authored
Merge pull request #1042 from mattcary/snapshot-skip
Skip disk image tests before 1.21
2 parents 7a126c2 + c9eb93f commit 162f146

File tree

5 files changed

+41
-16
lines changed

5 files changed

+41
-16
lines changed

pkg/gce-cloud-provider/compute/gce-compute.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,13 @@ func (cloud *CloudProvider) waitForSnapshotCreation(ctx context.Context, project
11171117

11181118
// kmsKeyEqual returns true if fetchedKMSKey and storageClassKMSKey refer to the same key.
11191119
// fetchedKMSKey - key returned by the server
1120-
// example: projects/{0}/locations/{1}/keyRings/{2}/cryptoKeys/{3}/cryptoKeyVersions/{4}
1120+
//
1121+
// example: projects/{0}/locations/{1}/keyRings/{2}/cryptoKeys/{3}/cryptoKeyVersions/{4}
1122+
//
11211123
// storageClassKMSKey - key as provided by the client
1122-
// example: projects/{0}/locations/{1}/keyRings/{2}/cryptoKeys/{3}
1124+
//
1125+
// example: projects/{0}/locations/{1}/keyRings/{2}/cryptoKeys/{3}
1126+
//
11231127
// cryptoKeyVersions should be disregarded if the rest of the key is identical.
11241128
func KmsKeyEqual(fetchedKMSKey, storageClassKMSKey string) bool {
11251129
return removeCryptoKeyVersion(fetchedKMSKey) == removeCryptoKeyVersion(storageClassKMSKey)

pkg/gce-pd-csi-driver/node_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Copyright 2018 The Kubernetes Authors.
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
66
You may obtain a copy of the License at
7-
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
810
Unless required by applicable law or agreed to in writing, software
911
distributed under the License is distributed on an "AS IS" BASIS,
1012
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

test/k8s-integration/main.go

+9
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@ func handle() error {
478478
return fmt.Errorf("Unknown deployment strategy %s", testParams.deploymentStrategy)
479479
}
480480

481+
skipDiskImageSnapshots := false
482+
if mustParseVersion(testParams.clusterVersion).lessThan(mustParseVersion("1.22.0")) {
483+
// Disk image cloning in only supported from 1.22 on.
484+
skipDiskImageSnapshots = true
485+
}
486+
481487
// Run the tests using the k8sSourceDir kubernetes
482488
if len(*storageClassFiles) != 0 {
483489
applicableStorageClassFiles := []string{}
@@ -498,6 +504,9 @@ func handle() error {
498504
}
499505
for _, rawSnapshotClassFile := range strings.Split(*snapshotClassFiles, ",") {
500506
snapshotClassFile := strings.TrimSpace(rawSnapshotClassFile)
507+
if skipDiskImageSnapshots && strings.Contains(snapshotClassFile, "image-volumesnapshotclass") {
508+
continue
509+
}
501510
if len(snapshotClassFile) != 0 {
502511
applicableSnapshotClassFiles = append(applicableSnapshotClassFiles, snapshotClassFile)
503512
}

test/k8s-integration/version.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ import (
1212

1313
var (
1414
versionNum = `(0|[1-9][0-9]*)`
15-
internalPatchVersion = `(\-[a-zA-Z0-9_.+-]+)`
15+
internalPatchVersion = `(\-gke\.[0-9]+)`
1616

1717
versionRegex = regexp.MustCompile(`^` + versionNum + `\.` + versionNum + `\.` + versionNum + internalPatchVersion + "?$")
1818
minorVersionRegex = regexp.MustCompile(`^` + versionNum + `\.` + versionNum + `$`)
19+
alphaVersionRegex = regexp.MustCompile(`^` + versionNum + `\.` + versionNum + `\.` + versionNum + `-alpha.*`)
1920
gkeExtraVersionRegex = regexp.MustCompile(`^(?:gke)\.(0|[1-9][0-9]*)$`)
2021
)
2122

@@ -24,7 +25,9 @@ type version struct {
2425
}
2526

2627
func (v *version) String() string {
27-
if v.version[3] != -1 {
28+
if v.version[3] == -2 {
29+
return fmt.Sprintf("%d.%d.%d-alpha", v.version[0], v.version[1], v.version[2])
30+
} else if v.version[3] != -1 {
2831
return fmt.Sprintf("%d.%d.%d-gke.%d", v.version[0], v.version[1], v.version[2], v.version[3])
2932
}
3033

@@ -82,6 +85,10 @@ func parseVersion(vs string) (*version, error) {
8285
case versionRegex.MatchString(vs):
8386
submatches = versionRegex.FindStringSubmatch(vs)
8487
lastIndex = 4
88+
case alphaVersionRegex.MatchString(vs):
89+
submatches = alphaVersionRegex.FindStringSubmatch(vs)
90+
v.version[3] = -2
91+
lastIndex = 4
8592
case minorVersionRegex.MatchString(vs):
8693
submatches = minorVersionRegex.FindStringSubmatch(vs)
8794
v.version[2] = -1
@@ -99,7 +106,7 @@ func parseVersion(vs string) (*version, error) {
99106
}
100107
}
101108

102-
if minorVersionRegex.MatchString(vs) {
109+
if minorVersionRegex.MatchString(vs) || alphaVersionRegex.MatchString(vs) {
103110
return &v, nil
104111
}
105112

@@ -131,9 +138,10 @@ func mustParseVersion(version string) *version {
131138
}
132139

133140
// Helper function to compare versions.
134-
// -1 -- if left < right
135-
// 0 -- if left == right
136-
// 1 -- if left > right
141+
//
142+
// -1 -- if left < right
143+
// 0 -- if left == right
144+
// 1 -- if left > right
137145
func (v *version) compare(right *version) int {
138146
for i, b := range v.version {
139147
if b > right.version[i] {

test/k8s-integration/version_test.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ func TestParseVersion(t *testing.T) {
7272
version: [4]int{1, 20, -1, -1},
7373
},
7474
},
75+
{
76+
version: "v1.26.0-alpha.0.293+6e3d62ca1c9e11",
77+
expectedV: version{
78+
version: [4]int{1, 26, 0, -2},
79+
},
80+
},
7581
// Negative test cases
7682
{
7783
version: "1",
@@ -106,11 +112,11 @@ func TestParseVersion(t *testing.T) {
106112
expectErr: true,
107113
},
108114
{
109-
version: "1.18.0-alpha.x",
115+
version: "1.18.0-beta.x",
110116
expectErr: true,
111117
},
112118
{
113-
version: "1.18.0-alpha.beta.1",
119+
version: "1.18.0-beta.alpha.1",
114120
expectErr: true,
115121
},
116122
{
@@ -121,10 +127,6 @@ func TestParseVersion(t *testing.T) {
121127
version: "1.18-alpha.3.673+73326ef01d2d7c",
122128
expectErr: true,
123129
},
124-
{
125-
version: "1.18.3-alpha.3.673+73326ef01d2d7c",
126-
expectErr: true,
127-
},
128130
}
129131

130132
for i, tc := range tests {
@@ -138,7 +140,7 @@ func TestParseVersion(t *testing.T) {
138140
}
139141

140142
if err == nil && tc.expectErr {
141-
t.Fatal("Got no error but expected one")
143+
t.Fatalf("Got no error but expected one with version %s", tc.version)
142144
return
143145
}
144146

0 commit comments

Comments
 (0)