Fix merge problems

This commit is contained in:
Justin Santa Barbara 2015-04-02 07:26:21 -07:00
parent 2812936d34
commit 89089900d7
5 changed files with 30 additions and 35 deletions

View File

@ -31,8 +31,8 @@ import (
)
var (
context = &e2e.TestContextType{}
gceConfig = &context.GCEConfig
context = &e2e.TestContextType{}
cloudConfig = &context.CloudConfig
orderseed = flag.Int64("orderseed", 0, "If non-zero, seed of random test shuffle order. (Otherwise random.)")
reportDir = flag.String("report_dir", "", "Path to the directory where the JUnit XML reports should be saved. Default is empty, which doesn't generate these reports.")
@ -51,9 +51,10 @@ func init() {
flag.StringVar(&context.RepoRoot, "repo_root", "./", "Root directory of kubernetes repository, for finding test files. Default assumes working directory is repository root")
flag.StringVar(&context.Provider, "provider", "", "The name of the Kubernetes provider (gce, gke, local, vagrant, etc.)")
flag.StringVar(&gceConfig.MasterName, "kube_master", "", "Name of the kubernetes master. Only required if provider is gce or gke")
flag.StringVar(&gceConfig.ProjectID, "gce_project", "", "The GCE project being used, if applicable")
flag.StringVar(&gceConfig.Zone, "gce_zone", "", "GCE zone being used, if applicable")
// TODO: Flags per provider? Rename gce_project/gce_zone?
flag.StringVar(&cloudConfig.MasterName, "kube_master", "", "Name of the kubernetes master. Only required if provider is gce or gke")
flag.StringVar(&cloudConfig.ProjectID, "gce_project", "", "The GCE project being used, if applicable")
flag.StringVar(&cloudConfig.Zone, "gce_zone", "", "GCE zone being used, if applicable")
}
func main() {
@ -67,22 +68,17 @@ func main() {
glog.Error("Invalid --times (negative or no testing requested)!")
os.Exit(1)
}
cloudConfig := &e2e.CloudConfig{
ProjectID: *gceProject,
Zone: *gceZone,
MasterName: *masterName,
}
if *provider == "aws" {
if context.Provider == "aws" {
awsConfig := "[Global]\n"
if *gceZone == "" {
if cloudConfig.Zone == "" {
glog.Error("gce_zone must be specified for AWS")
os.Exit(1)
}
awsConfig += fmt.Sprintf("Zone=%s\n", *gceZone)
awsConfig += fmt.Sprintf("Zone=%s\n", cloudConfig.Zone)
var err error
cloudConfig.Provider, err = cloudprovider.GetCloudProvider(*provider, strings.NewReader(awsConfig))
cloudConfig.Provider, err = cloudprovider.GetCloudProvider(context.Provider, strings.NewReader(awsConfig))
if err != nil {
glog.Error("Error building AWS provider: %v", err)
os.Exit(1)

View File

@ -166,7 +166,7 @@ func (s *goamzEC2) DeleteVolume(volumeId string) (resp *ec2.SimpleResp, err erro
func init() {
cloudprovider.RegisterCloudProvider("aws", func(config io.Reader) (cloudprovider.Interface, error) {
metadata := &goamzMetadata{}
return newAWSCloud(config, getAuth, metadata)
return newAWSCloud(config, getAuth, "", metadata)
})
}

View File

@ -38,8 +38,8 @@ var _ = Describe("MasterCerts", func() {
}
for _, certFile := range []string{"kubecfg.key", "kubecfg.crt", "ca.crt"} {
cmd := exec.Command("gcloud", "compute", "ssh", "--project", testContext.GCEConfig.ProjectID,
"--zone", testContext.GCEConfig.Zone, testContext.GCEConfig.MasterName,
cmd := exec.Command("gcloud", "compute", "ssh", "--project", testContext.CloudConfig.ProjectID,
"--zone", testContext.CloudConfig.Zone, testContext.CloudConfig.MasterName,
"--command", fmt.Sprintf("ls /srv/kubernetes/%s", certFile))
if _, err := cmd.CombinedOutput(); err != nil {
Fail(fmt.Sprintf("Error checking for cert file %s on master: %v", certFile, err))

View File

@ -56,9 +56,9 @@ var _ = Describe("PD", func() {
})
It("should schedule a pod w/ a RW PD, remove it, then schedule it on another host", func() {
if testContext.provider != "gce" && testContext.provider != "aws" {
if testContext.Provider != "gce" && testContext.Provider != "aws" {
By(fmt.Sprintf("Skipping PD test, which is only supported for providers gce & aws (not %s)",
testContext.provider))
testContext.Provider))
return
}
@ -176,10 +176,10 @@ var _ = Describe("PD", func() {
})
func createPD() (string, error) {
if testContext.provider == "gce" {
if testContext.Provider == "gce" {
pdName := fmt.Sprintf("e2e-%s", string(util.NewUUID()))
zone := testContext.cloudConfig.Zone
zone := testContext.CloudConfig.Zone
// TODO: make this hit the compute API directly instread of shelling out to gcloud.
err := exec.Command("gcloud", "compute", "disks", "create", "--zone="+zone, "--size=10GB", pdName).Run()
if err != nil {
@ -187,7 +187,7 @@ func createPD() (string, error) {
}
return pdName, nil
} else {
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
volumes, ok := testContext.CloudConfig.Provider.(aws_cloud.Volumes)
if !ok {
return "", fmt.Errorf("Provider does not support volumes")
}
@ -198,36 +198,35 @@ func createPD() (string, error) {
}
func deletePD(pdName string) error {
if testContext.provider == "gce" {
zone := testContext.cloudConfig.Zone
if testContext.Provider == "gce" {
zone := testContext.CloudConfig.Zone
// TODO: make this hit the compute API directly.
return exec.Command("gcloud", "compute", "disks", "delete", "--zone="+zone, pdName).Run()
} else {
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
volumes, ok := testContext.CloudConfig.Provider.(aws_cloud.Volumes)
if !ok {
return "", fmt.Errorf("Provider does not support volumes")
return fmt.Errorf("Provider does not support volumes")
}
return volumes.DeleteVolume(pdName)
}
}
func detachPD(hostName, pdName string) error {
if testContext.provider == "gce" {
if testContext.Provider == "gce" {
instanceName := strings.Split(hostName, ".")[0]
zone := testContext.cloudConfig.Zone
zone := testContext.CloudConfig.Zone
// TODO: make this hit the compute API directly.
return exec.Command("gcloud", "compute", "instances", "detach-disk", "--zone="+zone, "--disk="+pdName, instanceName).Run()
} else {
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
volumes, ok := testContext.CloudConfig.Provider.(aws_cloud.Volumes)
if !ok {
return "", fmt.Errorf("Provider does not support volumes")
return fmt.Errorf("Provider does not support volumes")
}
return volumes.DetachDisk(hostName, pdName)
}
}
func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
@ -256,7 +255,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
},
}
if testContext.provider == "gce" {
if testContext.Provider == "gce" {
pod.Spec.Volumes = []api.Volume{
{
Name: "testpd",
@ -269,7 +268,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
},
},
}
} else if testContext.provider == "aws" {
} else if testContext.Provider == "aws" {
pod.Spec.Volumes = []api.Volume{
{
Name: "testpd",
@ -283,7 +282,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
},
}
} else {
panic("Unknown provider: " + testContext.provider)
panic("Unknown provider: " + testContext.Provider)
}
return pod

View File

@ -49,7 +49,7 @@ type TestContextType struct {
Host string
RepoRoot string
Provider string
GCEConfig GCEConfig
CloudConfig CloudConfig
}
var testContext TestContextType