Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubetest Version Addition #21276

Merged
merged 1 commit into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions images/kubekins-e2e/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- --ldflags="-X=main.gitTag=$_GIT_TAG"
- --tag=gcr.io/$PROJECT_ID/kubekins-e2e:$_GIT_TAG-$_CONFIG
- --build-arg=BAZEL_VERSION_ARG=$_BAZEL_VERSION
- --build-arg=CFSSL_VERSION=$_CFSSL_VERSION
Expand Down
20 changes: 15 additions & 5 deletions kubetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,18 @@ const defaultGinkgoParallel = 25

var (
artifacts = filepath.Join(os.Getenv("WORKSPACE"), "_artifacts")
boskos, _ = client.NewClient(os.Getenv("JOB_NAME"), "http://boskos.test-pods.svc.cluster.local.", "", "")
control = process.NewControl(timeout, interrupt, terminate, verbose)
gitTag = "" // initializing default zero value. ldflags will populate this during build time.
interrupt = time.NewTimer(time.Duration(0)) // interrupt testing at this time.
terminate = time.NewTimer(time.Duration(0)) // terminate testing at this time.
verbose = false
timeout = time.Duration(0)
boskos, _ = client.NewClient(os.Getenv("JOB_NAME"), "http://boskos.test-pods.svc.cluster.local.", "", "")
control = process.NewControl(timeout, interrupt, terminate, verbose)
verbose = false
)

type options struct {
build buildStrategy
boskosWaitDuration time.Duration
charts bool
checkLeaks bool
checkSkew bool
Expand Down Expand Up @@ -122,12 +124,13 @@ type options struct {
testCmdArgs []string
up bool
upgradeArgs string
boskosWaitDuration time.Duration
version bool
}

func defineFlags() *options {
o := options{}
flag.Var(&o.build, "build", "Rebuild k8s binaries, optionally forcing (release|quick|bazel) strategy")
flag.DurationVar(&o.boskosWaitDuration, "boskos-wait-duration", 5*time.Minute, "Defines how long it waits until quit getting Boskos resoure, default 5 minutes")
flag.BoolVar(&o.charts, "charts", false, "If true, run charts tests")
flag.BoolVar(&o.checkSkew, "check-version-skew", true, "Verify client and server versions match")
flag.BoolVar(&o.checkLeaks, "check-leaked-resources", false, "Ensure project ends with the same resources")
Expand Down Expand Up @@ -188,7 +191,7 @@ func defineFlags() *options {
flag.DurationVar(&timeout, "timeout", time.Duration(0), "Terminate testing after the timeout duration (s/m/h)")
flag.BoolVar(&o.up, "up", false, "If true, start the e2e cluster. If cluster is already up, recreate it.")
flag.StringVar(&o.upgradeArgs, "upgrade_args", "", "If set, run upgrade tests before other tests")
flag.DurationVar(&o.boskosWaitDuration, "boskos-wait-duration", 5*time.Minute, "Defines how long it waits until quit getting Boskos resoure, default 5 minutes")
flag.BoolVar(&o.version, "version", false, "Command to print version")

// The "-v" flag was also used by glog, which is used by k8s.io/client-go. Duplicate flags cause panics.
// 1. Even if we could convince glog to change, they have too many consumers to ever do so.
Expand Down Expand Up @@ -274,6 +277,7 @@ func validateFlags(o *options) error {

func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
log.Printf("Running kubetest version: %s\n", gitTag)

// Initialize global pseudo random generator. Initializing it to select random AWS Zones.
rand.Seed(time.Now().UnixNano())
Expand All @@ -289,6 +293,11 @@ func main() {
log.Fatalf("Flags validation failed. err: %v", err)
}

if o.version {
log.Printf("kubetest version: %s\n", gitTag)
return
}

control = process.NewControl(timeout, interrupt, terminate, verbose)

// do things when we know we are running in the kubetest image
Expand Down Expand Up @@ -513,6 +522,7 @@ func writeMetadata(path, metadataSources string) error {
ver := findVersion()
m["job-version"] = ver // TODO(krzyzacy): retire
m["revision"] = ver
m["kubetest-version"] = gitTag
re := regexp.MustCompile(`^BUILD_METADATA_(.+)$`)
for _, e := range os.Environ() {
p := strings.SplitN(e, "=", 2)
Expand Down