a_download_only_test.go 1.9 KB
Newer Older
M
Medya Gh 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// +build integration

/*
Copyright 2019 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

19
// a_download_only_test.go filename starts with a, for the purpose that it runs before all parallel tests and downloads the images and caches them.
M
Medya Gh 已提交
20
package integration
21

M
Medya Gh 已提交
22
import (
23
	"fmt"
M
Medya Gh 已提交
24
	"testing"
25 26

	"k8s.io/minikube/pkg/minikube/constants"
M
Medya Gh 已提交
27 28 29 30 31
)

// TestDownloadOnly downloads ISOs also tests the --download-only option
// Note this test runs before all tests (because of file name) and caches images for them
func TestDownloadOnly(t *testing.T) {
32
	p := profile(t)
M
Medya Gh 已提交
33 34 35 36 37
	if isTestNoneDriver() {
		t.Skip()

	}
	mk := NewMinikubeRunner(t, p)
M
Medya Gh 已提交
38
	if !isTestNoneDriver() { // none driver doesnt need to be deleted
39
		defer mk.TearDown(t)
M
Medya Gh 已提交
40
	}
M
Medya Gh 已提交
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
	t.Run("Oldest", func(t *testing.T) {
		stdout, stderr, err := mk.Start("--download-only", fmt.Sprintf("--kubernetes-version=%s", constants.OldestKubernetesVersion))
		if err != nil {
			t.Fatalf("%s minikube --download-only failed : %v\nstdout: %s\nstderr: %s", p, err, stdout, stderr)
		}
	})

	t.Run("Newest", func(t *testing.T) {
		stdout, stderr, err := mk.Start("--download-only", fmt.Sprintf("--kubernetes-version=%s", constants.NewestKubernetesVersion))
		if err != nil {
			t.Fatalf("%s minikube --download-only failed : %v\nstdout: %s\nstderr: %s", p, err, stdout, stderr)
		}
		// TODO: add test to check if files are downloaded
	})

	// TODO: download latest binary to test data here
M
Medya Gh 已提交
58 59

}