Support kubernetes-anywhere provider

pull/6/head
Jamie Hannaford 2017-09-14 10:43:51 +02:00
parent 1bdcfa59e8
commit 69f5feb295
2 changed files with 47 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import (
"fmt" "fmt"
"os" "os"
"path" "path"
"path/filepath"
"strings" "strings"
"time" "time"
@ -46,6 +47,8 @@ func MasterUpgrade(v string) error {
return masterUpgradeGCE(v, false) return masterUpgradeGCE(v, false)
case "gke": case "gke":
return masterUpgradeGKE(v) return masterUpgradeGKE(v)
case "kubernetes-anywhere":
return masterUpgradeKubernetesAnywhere(v)
default: default:
return fmt.Errorf("MasterUpgrade() is not implemented for provider %s", TestContext.Provider) return fmt.Errorf("MasterUpgrade() is not implemented for provider %s", TestContext.Provider)
} }
@ -103,6 +106,46 @@ func masterUpgradeGKE(v string) error {
return nil return nil
} }
func masterUpgradeKubernetesAnywhere(v string) error {
Logf("Upgrading master to %q", v)
kaPath := TestContext.KubernetesAnywherePath
originalConfigPath := filepath.Join(kaPath, ".config")
backupConfigPath := filepath.Join(kaPath, ".config.bak")
updatedConfigPath := filepath.Join(kaPath, fmt.Sprintf(".config-%s", v))
// backup .config to .config.bak
if err := os.Rename(originalConfigPath, backupConfigPath); err != nil {
return err
}
defer func() {
// revert .config.bak to .config
if err := os.Rename(backupConfigPath, originalConfigPath); err != nil {
Logf("Could not rename %s back to %s", backupConfigPath, originalConfigPath)
}
}()
// modify config with specified k8s version
if _, _, err := RunCmd("sed",
fmt.Sprintf(`s/kubernetes_version=.*$/kubernetes_version=%s/`, v),
backupConfigPath, ">", originalConfigPath); err != nil {
return err
}
// invoke ka upgrade
if _, _, err := RunCmd("make", "-C", TestContext.KubernetesAnywherePath,
"WAIT_FOR_KUBECONFIG=y", "upgrade-master"); err != nil {
return err
}
// move .config to .config.<version>
if err := os.Rename(originalConfigPath, updatedConfigPath); err != nil {
return err
}
return nil
}
func NodeUpgrade(f *Framework, v string, img string) error { func NodeUpgrade(f *Framework, v string, img string) error {
// Perform the upgrade. // Perform the upgrade.
var err error var err error

View File

@ -106,6 +106,9 @@ type TestContextType struct {
// Whether configuration for accessing federation member clusters should be sourced from the host cluster // Whether configuration for accessing federation member clusters should be sourced from the host cluster
FederationConfigFromCluster bool FederationConfigFromCluster bool
// Indicates what path the kubernetes-anywhere is installed on
KubernetesAnywherePath string
// Viper-only parameters. These will in time replace all flags. // Viper-only parameters. These will in time replace all flags.
// Example: Create a file 'e2e.json' with the following: // Example: Create a file 'e2e.json' with the following:
@ -201,6 +204,7 @@ func RegisterCommonFlags() {
flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "", "The container runtime endpoint of cluster VM instances.") flag.StringVar(&TestContext.ContainerRuntimeEndpoint, "container-runtime-endpoint", "", "The container runtime endpoint of cluster VM instances.")
flag.StringVar(&TestContext.ImageServiceEndpoint, "image-service-endpoint", "", "The image service endpoint of cluster VM instances.") flag.StringVar(&TestContext.ImageServiceEndpoint, "image-service-endpoint", "", "The image service endpoint of cluster VM instances.")
flag.StringVar(&TestContext.DockershimCheckpointDir, "dockershim-checkpoint-dir", "/var/lib/dockershim/sandbox", "The directory for dockershim to store sandbox checkpoints.") flag.StringVar(&TestContext.DockershimCheckpointDir, "dockershim-checkpoint-dir", "/var/lib/dockershim/sandbox", "The directory for dockershim to store sandbox checkpoints.")
flag.StringVar(&TestContext.KubernetesAnywherePath, "kubernetes-anywhere-path", "/workspace/kubernetes-anywhere", "Which directory kubernetes-anywhere is installed to.")
} }
// Register flags specific to the cluster e2e test suite. // Register flags specific to the cluster e2e test suite.