Add integration test for docker download only
parent
05a46f6526
commit
26de14676d
|
|
@ -52,8 +52,8 @@ func targetDir() string {
|
|||
return localpath.MakeMiniPath("cache", "preloaded-tarball")
|
||||
}
|
||||
|
||||
// returns path to checksum file
|
||||
func checksumFilepath(k8sVersion string) string {
|
||||
// ChecksumFilepath returns path to checksum file
|
||||
func ChecksumFilepath(k8sVersion string) string {
|
||||
return path.Join(targetDir(), checksumName(k8sVersion))
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ func saveChecksumFile(k8sVersion string) error {
|
|||
return errors.Wrap(err, "getting storage object")
|
||||
}
|
||||
checksum := attrs.MD5
|
||||
return ioutil.WriteFile(checksumFilepath(k8sVersion), checksum, 0644)
|
||||
return ioutil.WriteFile(ChecksumFilepath(k8sVersion), checksum, 0644)
|
||||
}
|
||||
|
||||
// verifyChecksum returns true if the checksum of the local binary matches
|
||||
|
|
@ -136,7 +136,7 @@ func verifyChecksum(k8sVersion string) error {
|
|||
}
|
||||
checksum := md5.Sum(contents)
|
||||
|
||||
remoteChecksum, err := ioutil.ReadFile(checksumFilepath(k8sVersion))
|
||||
remoteChecksum, err := ioutil.ReadFile(ChecksumFilepath(k8sVersion))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "reading checksum file")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,19 +20,26 @@ package integration
|
|||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-containerregistry/pkg/name"
|
||||
"github.com/google/go-containerregistry/pkg/v1/daemon"
|
||||
"k8s.io/minikube/pkg/drivers/kic"
|
||||
"k8s.io/minikube/pkg/minikube/bootstrapper/images"
|
||||
"k8s.io/minikube/pkg/minikube/config"
|
||||
"k8s.io/minikube/pkg/minikube/constants"
|
||||
"k8s.io/minikube/pkg/minikube/localpath"
|
||||
"k8s.io/minikube/pkg/minikube/preload"
|
||||
)
|
||||
|
||||
func TestDownloadOnly(t *testing.T) {
|
||||
|
|
@ -160,3 +167,52 @@ func TestDownloadOnly(t *testing.T) {
|
|||
})
|
||||
|
||||
}
|
||||
func TestDownloadOnlyDocker(t *testing.T) {
|
||||
if !runningDockerDriver(StartArgs()) {
|
||||
t.Skip("this test only runs with the docker driver")
|
||||
}
|
||||
|
||||
profile := UniqueProfileName("download-docker")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute)
|
||||
defer Cleanup(t, profile, cancel)
|
||||
|
||||
args := []string{"start", "--download-only", "-p", profile, "--force", "--alsologtostderr", "--vm-driver=docker"}
|
||||
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
|
||||
if err != nil {
|
||||
t.Errorf("%s failed: %v:\n%s", args, err, rr.Output())
|
||||
}
|
||||
|
||||
// Make sure the preloaded image tarball exists
|
||||
tarball := preload.TarballFilepath(constants.DefaultKubernetesVersion)
|
||||
contents, err := ioutil.ReadFile(tarball)
|
||||
if err != nil {
|
||||
t.Errorf("reading tarball: %v", err)
|
||||
}
|
||||
// Make sure it has the correct checksum
|
||||
checksum := md5.Sum(contents)
|
||||
remoteChecksum, err := ioutil.ReadFile(preload.ChecksumFilepath(constants.DefaultKubernetesVersion))
|
||||
if err != nil {
|
||||
t.Errorf("reading checksum file: %v", err)
|
||||
}
|
||||
if string(remoteChecksum) != string(checksum[:]) {
|
||||
t.Errorf("checksum of %s does not match remote checksum (%s != %s)", tarball, string(remoteChecksum), string(checksum[:]))
|
||||
}
|
||||
|
||||
// Make sure this image exists in the docker daemon
|
||||
ref, err := name.ParseReference(kic.BaseImage)
|
||||
if err != nil {
|
||||
t.Errorf("parsing reference failed: %v", err)
|
||||
}
|
||||
if _, err := daemon.Image(ref); err != nil {
|
||||
t.Errorf("expected image does not exist in local daemon: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func runningDockerDriver(startArgs []string) bool {
|
||||
for _, s := range startArgs {
|
||||
if s == "--vm-driver=docker" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue