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

kubetest2 - Add support for specifying a kubernetes version marker file #10620

Merged
merged 1 commit into from
Jan 21, 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
4 changes: 2 additions & 2 deletions tests/e2e/e2e.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ test-e2e-aws-simple-1-20: test-e2e-install
--up --down \
--cloud-provider=aws \
--kops-version-marker=https://storage.googleapis.com/kops-ci/bin/latest-ci-updown-green.txt \
--kubernetes-version=v1.20.2 \
--kubernetes-version=https://storage.googleapis.com/kubernetes-release/release/stable-1.20.txt \
--template-path=tests/e2e/templates/simple.yaml.tmpl \
--test=kops \
-- \
--test-package-version=v1.20.2 \
--test-package-marker=stable-1.20.txt \
--parallel 25 \
--skip-regex="\[Slow\]|\[Serial\]|\[Disruptive\]|\[Flaky\]|\[Feature:.+\]|\[HPA\]|Dashboard|RuntimeClass|RuntimeHandler"
1 change: 1 addition & 0 deletions tests/e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module k8s.io/kops/tests/e2e
go 1.15

require (
github.com/blang/semver v3.5.1+incompatible
github.com/octago/sflags v0.2.0
github.com/spf13/pflag v1.0.5
gopkg.in/yaml.v2 v2.3.0
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngE
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/bombsimon/wsl/v2 v2.0.0/go.mod h1:mf25kr/SqFEPhhcxW1+7pxzGlW+hIl/hYTKY95VwV8U=
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/kubetest2-kops/deployer/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/kops/tests/e2e/kubetest2-kops/do"
"k8s.io/kops/tests/e2e/kubetest2-kops/gce"
"k8s.io/kops/tests/e2e/pkg/util"
"k8s.io/kops/tests/e2e/pkg/version"
"sigs.k8s.io/kubetest2/pkg/exec"
)

Expand Down Expand Up @@ -165,6 +166,13 @@ func (d *deployer) verifyUpFlags() error {
if d.KubernetesVersion == "" {
return errors.New("missing required --kubernetes-version flag")
}

v, err := version.ParseKubernetesVersion(d.KubernetesVersion)
if err != nil {
return err
}
d.KubernetesVersion = v

return nil
}

Expand Down
44 changes: 44 additions & 0 deletions tests/e2e/pkg/version/kubernetes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Copyright 2021 The Kubernetes Authors.

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 version

import (
"bytes"
"fmt"
"net/url"
"strings"

"github.com/blang/semver"
"k8s.io/kops/tests/e2e/pkg/util"
)

// ParseKubernetesVersion will parse the provided k8s version
// Either a semver or marker URL is accepted
func ParseKubernetesVersion(version string) (string, error) {
if _, err := url.Parse(version); err == nil {
var b bytes.Buffer
err = util.HTTPGETWithHeaders(version, nil, &b)
if err != nil {
return "", err
}
return strings.TrimSpace(b.String()), nil
}
if _, err := semver.ParseTolerant(version); err == nil {
return version, nil
}
return "", fmt.Errorf("unexpected kubernetes version: %v", version)
}