minikube-pr-bot enhancements
parent
22099c8a14
commit
84f2c86a50
|
@ -62,7 +62,7 @@ function install_golang() {
|
|||
# using sudo because previously installed versions might have been installed by a different user.
|
||||
# as it was the case on jenkins VM.
|
||||
sudo curl -qL -O "https://storage.googleapis.com/golang/go${1}.${INSTALLOS}-${ARCH}.tar.gz" &&
|
||||
sudo tar -xf go${1}.${INSTALLOS}-amd64.tar.gz &&
|
||||
sudo tar -xzf go${1}.${INSTALLOS}-amd64.tar.gz &&
|
||||
sudo rm -rf "${2}/go" &&
|
||||
sudo mv go "${2}/" && sudo chown -R $(whoami): ${2}/go
|
||||
popd >/dev/null
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Copyright 2021 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.
|
||||
|
||||
set -x -o pipefail
|
||||
# Only run this on PRs
|
||||
if [[ "${MINIKUBE_LOCATION}" == "master" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Make sure docker is installed and configured
|
||||
./hack/jenkins/installers/check_install_docker.sh
|
||||
|
||||
# Make sure gh is installed and configured
|
||||
./hack/jenkins/installers/check_install_gh.sh
|
||||
|
||||
# Make sure go is installed and configured
|
||||
./hack/jenkins/installers/check_install_golang.sh
|
||||
|
||||
# Grab latest code
|
||||
git clone https://github.com/kubernetes/minikube.git
|
||||
cd minikube
|
||||
|
||||
# Build minikube binary and mkcmp binary
|
||||
make out/minikube out/mkcmp
|
||||
|
||||
# Run mkcmp
|
||||
out/mkcmp out/minikube pr://${MINIKUBE_LOCATION} | mkcmp.log
|
||||
if [ $? -gt 0 ]; then
|
||||
# Comment that mkcmp failed
|
||||
gh pr comment ${MINIKUBE_LOCATION} --body "timing minikube failed, please try again"
|
||||
exit 1
|
||||
fi
|
||||
output=$(cat mkcmp.log)
|
||||
gh pr comment ${MINIKUBE_LOCATION} --body ${output}
|
|
@ -66,8 +66,6 @@ func (rm *resultManager) averageTime(binary *Binary) float64 {
|
|||
|
||||
func (rm *resultManager) summarizeResults(binaries []*Binary, driver string) {
|
||||
// print total and average times
|
||||
fmt.Printf("**%s Driver**\n", driver)
|
||||
|
||||
for _, b := range binaries {
|
||||
fmt.Printf("Times for %s: ", b.Name())
|
||||
for _, tt := range rm.totalTimes(b) {
|
||||
|
|
|
@ -23,18 +23,22 @@ import (
|
|||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
// runs is the number of times each binary will be timed for 'minikube start'
|
||||
runs = 3
|
||||
runs = 5
|
||||
)
|
||||
|
||||
// CompareMinikubeStart compares the time to run `minikube start` between two minikube binaries
|
||||
func CompareMinikubeStart(ctx context.Context, out io.Writer, binaries []*Binary) error {
|
||||
drivers := []string{"kvm2", "docker"}
|
||||
if runtime.GOOS == "darwin" {
|
||||
drivers = []string{"hyperkit", "docker"}
|
||||
}
|
||||
for _, d := range drivers {
|
||||
fmt.Printf("**%s Driver**\n", d)
|
||||
if err := downloadArtifacts(ctx, binaries, d); err != nil {
|
||||
|
@ -62,11 +66,17 @@ func collectResults(ctx context.Context, binaries []*Binary, driver string) (*re
|
|||
return nil, errors.Wrapf(err, "timing run %d with %s", run, binary.Name())
|
||||
}
|
||||
rm.addResult(binary, r)
|
||||
r, err = timeEnableIngress(ctx, binary)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "timing run %d with %s", run, binary.Name())
|
||||
if runtime.GOOS != "darwin" {
|
||||
r, err = timeEnableIngress(ctx, binary)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "timing run %d with %s", run, binary.Name())
|
||||
}
|
||||
rm.addResult(binary, r)
|
||||
}
|
||||
deleteCmd := exec.CommandContext(ctx, binary.path, "delete")
|
||||
if err := deleteCmd.Run(); err != nil {
|
||||
log.Printf("error deleting minikube: %v", err)
|
||||
}
|
||||
rm.addResult(binary, r)
|
||||
}
|
||||
}
|
||||
return rm, nil
|
||||
|
@ -74,10 +84,19 @@ func collectResults(ctx context.Context, binaries []*Binary, driver string) (*re
|
|||
|
||||
func average(nums []float64) float64 {
|
||||
total := float64(0)
|
||||
max := float64(0)
|
||||
min := float64(0)
|
||||
for _, a := range nums {
|
||||
if a > max {
|
||||
max = a
|
||||
}
|
||||
if min > a {
|
||||
min = a
|
||||
}
|
||||
total += a
|
||||
}
|
||||
return total / float64(len(nums))
|
||||
total = total - min - max
|
||||
return total / float64(len(nums)-2)
|
||||
}
|
||||
|
||||
func downloadArtifacts(ctx context.Context, binaries []*Binary, driver string) error {
|
||||
|
@ -108,16 +127,9 @@ func timeMinikubeStart(ctx context.Context, binary *Binary, driver string) (*res
|
|||
// timeEnableIngress returns the time it takes to execute `minikube addons enable ingress`
|
||||
// It deletes the VM after `minikube addons enable ingress`.
|
||||
func timeEnableIngress(ctx context.Context, binary *Binary) (*result, error) {
|
||||
enableCmd := exec.CommandContext(ctx, binary.path, "addons enable ingress")
|
||||
enableCmd := exec.CommandContext(ctx, binary.path, "addons", "enable", "ingress")
|
||||
enableCmd.Stderr = os.Stderr
|
||||
|
||||
deleteCmd := exec.CommandContext(ctx, binary.path, "delete")
|
||||
defer func() {
|
||||
if err := deleteCmd.Run(); err != nil {
|
||||
log.Printf("error deleting minikube: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
log.Printf("Running: %v...", enableCmd.Args)
|
||||
r, err := timeCommandLogs(enableCmd)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue