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

e2e - dump cluster manifests into artifacts and add --kubernetes-version #10522

Merged
merged 3 commits into from
Jan 4, 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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ test-e2e:
--build --up --down \
--cloud-provider=aws \
--kops-binary-path=/home/prow/go/src/k8s.io/kops/bazel-bin/cmd/kops/linux-amd64/kops \
--kubernetes-version=v1.19.4 \
--test=ginkgo \
-- \
--test-package-version=v1.19.4 \
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/kubetest2-kops/deployer/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (d *deployer) verifyBuildFlags() error {
if goPath := os.Getenv("GOPATH"); goPath != "" {
d.KopsRoot = path.Join(goPath, "src", "k8s.io", "kops")
} else {
return errors.New("required kops-root when building from source")
return errors.New("required --kops-root when building from source")
}
}
if d.StageLocation != "" {
Expand All @@ -63,7 +63,7 @@ func (d *deployer) verifyBuildFlags() error {
return err
}
if !fi.Mode().IsDir() {
return errors.New("kops-root must be a directory")
return errors.New("--kops-root must be a directory")
}

d.BuildOptions.KopsRoot = d.KopsRoot
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/kubetest2-kops/deployer/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func (d *deployer) initialize() error {
return fmt.Errorf("init failed to check up flags: %v", err)
}
}
if d.commonOptions.ShouldUp() || d.commonOptions.ShouldTest() {
if d.KubernetesVersion == "" {
return errors.New("missing required --kubernetes-version flag")
}
}
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/kubetest2-kops/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type deployer struct {
KopsBinaryPath string `flag:"kops-binary-path" desc:"The path to kops executable used for testing"`
StateStore string `flag:"-"`

KubernetesVersion string `flag:"kubernetes-version" desc:"The kubernetes version to use in the cluster"`

SSHPrivateKeyPath string `flag:"ssh-private-key" desc:"The path to the private key used for SSH access to instances"`
SSHPublicKeyPath string `flag:"ssh-public-key" desc:"The path to the public key passed to the cloud provider"`
SSHUser []string `flag:"ssh-user" desc:"The SSH users to use for SSH access to instances"`
Expand Down
33 changes: 33 additions & 0 deletions tests/e2e/kubetest2-kops/deployer/dumplogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ limitations under the License.
package deployer

import (
"fmt"
"os"
"path"
"strings"

"k8s.io/klog/v2"
Expand All @@ -38,6 +41,36 @@ func (d *deployer) DumpClusterLogs() error {
return err
}

if err := d.dumpClusterManifest(); err != nil {
return err
}

return nil
}

func (d *deployer) dumpClusterManifest() error {
resourceTypes := []string{"cluster", "instancegroups"}
for _, rt := range resourceTypes {
yamlFile, err := os.Create(path.Join(d.ArtifactsDir, fmt.Sprintf("%v.yaml", rt)))
if err != nil {
panic(err)
}
defer yamlFile.Close()

args := []string{
d.KopsBinaryPath, "get", rt,
"--name", d.ClusterName,
"-o", "yaml",
}
klog.Info(strings.Join(args, " "))

cmd := exec.Command(args[0], args[1:]...)
cmd.SetStdout(yamlFile)
cmd.SetEnv(d.env()...)
if err := cmd.Run(); err != nil {
return err
}
}
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/kubetest2-kops/deployer/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (d *deployer) Up() error {
"--name", d.ClusterName,
"--admin-access", publicIP,
"--cloud", d.CloudProvider,
"--kubernetes-version", d.KubernetesVersion,
"--master-count", "1",
"--master-size", "c5.large",
"--master-volume-size", "48",
Expand All @@ -57,6 +58,7 @@ func (d *deployer) Up() error {
"--zones", strings.Join(zones, ","),
"--yes",
}

klog.Info(strings.Join(args, " "))
cmd := exec.Command(args[0], args[1:]...)
cmd.SetEnv(d.env()...)
Expand Down