Skip to content

Commit f54b15e

Browse files
authored
Merge pull request #882 from mattcary/testversion
Update version download for current upstream capabilities
2 parents 744870c + 7d92d61 commit f54b15e

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

test/k8s-integration/cluster.go

+11-22
Original file line numberDiff line numberDiff line change
@@ -222,38 +222,27 @@ func downloadKubernetesSource(pkgDir, k8sIoDir, kubeVersion string) error {
222222
return err
223223
}
224224

225+
// We clone rather than download from release archives, because the file naming has not been
226+
// stable. For example, in late 2021 it appears that archives of minor versions (eg v1.21.tgz)
227+
// stopped and was replaced with just patch version.
225228
if kubeVersion == "master" {
226-
// Clone of master. We cannot download the master version from the archive, because the k8s
227-
// version is not set, which affects which APIs are removed in the running cluster. We cannot
228-
// use a shallow clone, because in order to find the revision git searches through the tags,
229-
// and tags are not fetched in a shallow clone. Not using a shallow clone adds about 700M to the
230-
// ~5G archive directory, after make quick-release, so this is not disastrous.
229+
// Clone of master. We cannot use a shallow clone, because the k8s version is not set, and
230+
// in order to find the revision git searches through the tags, and tags are not fetched in
231+
// a shallow clone. Not using a shallow clone adds about 700M to the ~5G archive directory,
232+
// after make quick-release, so this is not disastrous.
231233
klog.Info("cloning k8s master")
232234
out, err := exec.Command("git", "clone", "https://github.com/kubernetes/kubernetes", k8sDir).CombinedOutput()
233235
if err != nil {
234236
return fmt.Errorf("failed to clone kubernetes master: %s, err: %v", out, err)
235237
}
236238
} else {
237-
// Download from the release archives rather than cloning the repo.
239+
// Shallow clone of a release branch.
238240
vKubeVersion := "v" + kubeVersion
239-
kubeTarDir := filepath.Join(k8sIoDir, fmt.Sprintf("kubernetes-%s.tar.gz", kubeVersion))
240-
klog.Infof("Pulling archive for %s", vKubeVersion)
241-
out, err := exec.Command("curl", "-L", fmt.Sprintf("https://github.com/kubernetes/kubernetes/archive/%s.tar.gz", vKubeVersion), "-o", kubeTarDir).CombinedOutput()
241+
klog.Infof("shallow clone of k8s %s", vKubeVersion)
242+
out, err := exec.Command("git", "clone", "--depth", "1", "https://github.com/kubernetes/kubernetes", k8sDir).CombinedOutput()
242243
if err != nil {
243-
return fmt.Errorf("failed to curl kubernetes version %s: %s, err: %v", kubeVersion, out, err)
244+
return fmt.Errorf("failed to clone kubernetes %s: %s, err: %v", vKubeVersion, out, err)
244245
}
245-
246-
out, err = exec.Command("tar", "-C", k8sIoDir, "-xvf", kubeTarDir).CombinedOutput()
247-
if err != nil {
248-
return fmt.Errorf("failed to untar %s: %s, err: %v", kubeTarDir, out, err)
249-
}
250-
251-
err = os.Rename(filepath.Join(k8sIoDir, fmt.Sprintf("kubernetes-%s", kubeVersion)), k8sDir)
252-
if err != nil {
253-
return err
254-
}
255-
256-
klog.Infof("Successfully downloaded Kubernetes v%s to %s", kubeVersion, k8sDir)
257246
}
258247
return nil
259248
}

test/k8s-integration/main.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ func main() {
112112
flag.Set("logtostderr", "true")
113113
flag.Parse()
114114

115+
if *useGKEManagedDriver {
116+
*doDriverBuild = false
117+
*teardownDriver = false
118+
}
119+
115120
if !*inProw && *doDriverBuild {
116121
ensureVariable(stagingImage, true, "staging-image is a required flag, please specify the name of image to stage to")
117122
}
@@ -668,7 +673,7 @@ func runTestsWithConfig(testParams *testParameters, testConfigArg, reportPrefix
668673
}
669674
kubeTest2Args = append(kubeTest2Args, "--")
670675
if len(*testVersion) != 0 && *testVersion != "master" {
671-
kubeTest2Args = append(kubeTest2Args, fmt.Sprintf("--test-package-version=v%s", *testVersion))
676+
kubeTest2Args = append(kubeTest2Args, fmt.Sprintf("--test-package-marker=latest-%s.txt", *testVersion))
672677
}
673678
kubeTest2Args = append(kubeTest2Args, fmt.Sprintf("--focus-regex=%s", testParams.testFocus))
674679
kubeTest2Args = append(kubeTest2Args, fmt.Sprintf("--skip-regex=%s", testParams.testSkip))

0 commit comments

Comments
 (0)