diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index f04f074a697fbf88ddf46bd242f2e98c2edab42e..aa8e4fbf2b3996559c5fb881b594a72fd19daf25 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,8 +25,7 @@ jobs: run: go mod download - name: Build Binaries run: | - make cross - make e2e-cross + make cross e2e-cross debs cp -r test/integration/testdata ./out whoami echo github ref $GITHUB_REF diff --git a/Makefile b/Makefile index f6d00b7ca5f3e3eaf2ceb0aed1af76ea770e9878..9dd28a44c3c9f041bf25b21e6ab4b331be0b3a96 100644 --- a/Makefile +++ b/Makefile @@ -487,6 +487,13 @@ verify-iso: # Make sure the current ISO exists in the expected bucket out/docs/minikube.md: $(shell find "cmd") $(shell find "pkg/minikube/constants") $(SOURCE_GENERATED) go run -ldflags="$(MINIKUBE_LDFLAGS)" -tags gendocs hack/help_text/gen_help_text.go + +.PHONY: debs +debs: out/minikube_$(DEB_VERSION)-$(DEB_REVISION)_amd64.deb \ + out/minikube_$(DEB_VERSION)-$(DEB_REVISION)_arm64.deb \ + out/docker-machine-driver-kvm2_$(DEB_VERSION).deb + + .PHONY: deb_version deb_version: @echo $(DEB_VERSION)-$(DEB_REVISION) diff --git a/hack/jenkins/minikube_deb_install_test.sh b/hack/jenkins/minikube_deb_install_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..2bb2502916f42550e3ab28cf1ef35255c9861c92 --- /dev/null +++ b/hack/jenkins/minikube_deb_install_test.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Copyright 2016 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. + +# This script builds the minikube binary for all 3 platforms and uploads them. +# This is to done as part of the CI tests for Github PRs + +# The script expects the following env variables: +# bucket: The GCP bucket to get .deb files from +# debs: .deb packages to test + +set -eu -o pipefail + +trap exit SIGINT + +for pkg in ${debs[@]}; do + gsutil cp -r "gs://${bucket}/${pkg}.deb" . +done + +declare -ra distros=(\ + debian:sid\ + debian:latest\ + debian:buster\ + debian:stretch\ + ubuntu:latest\ + ubuntu:20.10 \ + ubuntu:20.04 \ + ubuntu:19.10 \ + ubuntu:19.04 \ + ubuntu:18.10 \ + ubuntu:18.04) + + +for distro in "${distros[@]}"; do + for pkg in ${debs[@]}; do + echo "==============================================================" + printf "Install %s on %s\n" "${pkg}" "${distro}" + echo "==============================================================" + docker run --rm -v "$PWD:/var/tmp" "${distro}" sh -c "apt-get update; \ + (dpkg -i /var/tmp/${pkg} || + (apt-get -fy install && dpkg -i /var/tmp/${pkg})) + || echo "Failed to install ${pkg}.deb on ${distro}" + done +done + diff --git a/test/integration/pkg_install_test.go b/test/integration/pkg_install_test.go new file mode 100644 index 0000000000000000000000000000000000000000..7cdcf5f66b468cf14991d480d964f25097a1ccda --- /dev/null +++ b/test/integration/pkg_install_test.go @@ -0,0 +1,107 @@ +// build integration + +/* +Copyright 2016 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. +*/ + +package integration + +import ( + "context" + "fmt" + "os/exec" + "path/filepath" + "runtime" + "testing" +) + +var distros = []string{ + "debian:sid", + "debian:latest", + "debian:10", + "debian:9", + // + "ubuntu:latest", + "ubuntu:20.10", + "ubuntu:20.04", + "ubuntu:19.10", + "ubuntu:19.04", +} + +var timeout = Minutes(10) + + +// TestPackageInstall tests installation of .deb packages with minikube itself and with kvm2 driver +// on debian/ubuntu docker images enumerated in "distros" +func TestDebPackageInstall(t *testing.T) { + + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + + pkgDir, err := filepath.Abs(filepath.Dir(Target())) + if err != nil { + t.Errorf("failed to get minikube path: %e", err) + } + mkDebs, err := filepath.Glob(fmt.Sprintf("%s/minikube_*_%s.deb", pkgDir, "amd64")) + if err != nil { + t.Errorf("failed to find minikube deb in %q: %e", pkgDir, err) + } + kvmDebs, err := filepath.Glob(fmt.Sprintf("%s/docker-machine-driver-kvm2_*_%s.deb", pkgDir, runtime.GOARCH)) + if err != nil { + t.Errorf("failed to find minikube deb in %q: %e", pkgDir, err) + } + + for _, distro := range distros { + distroImg := distro + t.Run("installMinikube_"+distroImg, func(t *testing.T) { + // apt-get update; dpkg -i minikube_${ver}_${arch}.deb + t.Run("minikube", func(t *testing.T) { + for _, mkDeb := range mkDebs { + rr, err := dpkgInstall(ctx, t, distro, mkDeb) + if err != nil || rr.ExitCode != 0 { + t.Errorf("failed to install %q on %q: err=%e, exit=%d", + mkDeb, distroImg, err, rr.ExitCode) + } + } + }) + // apt-get update; apt-get install -y libvirt0; dpkg -i docker-machine-driver-kvm2_${ver}_${arch}.deb + t.Run("kvm2-driver", func(t *testing.T) { + for _, kvmDeb := range kvmDebs { + rr, err := dpkgInstallDriver(ctx, t, distro, kvmDeb) + if err != nil || rr.ExitCode != 0 { + t.Errorf("failed to install %q on %q: err=%e, exit=%d", + kvmDeb, distroImg, err, rr.ExitCode) + } + } + }) + }) + } +} + + +func dpkgInstall(ctx context.Context, t *testing.T, image, deb string) (*RunResult, error) { + return Run(t, exec.CommandContext(ctx, + "docker", "run", "--rm", fmt.Sprintf("-v%s:/var/tmp", filepath.Dir(deb)), + image, + "sh", "-c", fmt.Sprintf("apt-get update; dpkg -i /var/tmp/%s", filepath.Base(deb)))) +} + + +func dpkgInstallDriver(ctx context.Context, t *testing.T, image, deb string) (*RunResult, error) { + return Run(t, exec.CommandContext(ctx, + "docker", "run", "--rm", fmt.Sprintf("-v%s:/var/tmp", filepath.Dir(deb)), + image, + "sh", "-c", fmt.Sprintf("apt-get update; apt-get install -y libvirt0; dpkg -i /var/tmp/%s", filepath.Base(deb)))) +}