mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Fix merge problems
This commit is contained in:
parent
2812936d34
commit
89089900d7
@ -32,7 +32,7 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
context = &e2e.TestContextType{}
|
context = &e2e.TestContextType{}
|
||||||
gceConfig = &context.GCEConfig
|
cloudConfig = &context.CloudConfig
|
||||||
|
|
||||||
orderseed = flag.Int64("orderseed", 0, "If non-zero, seed of random test shuffle order. (Otherwise random.)")
|
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.")
|
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.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(&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")
|
// TODO: Flags per provider? Rename gce_project/gce_zone?
|
||||||
flag.StringVar(&gceConfig.ProjectID, "gce_project", "", "The GCE project being used, if applicable")
|
flag.StringVar(&cloudConfig.MasterName, "kube_master", "", "Name of the kubernetes master. Only required if provider is gce or gke")
|
||||||
flag.StringVar(&gceConfig.Zone, "gce_zone", "", "GCE zone being used, if applicable")
|
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() {
|
func main() {
|
||||||
@ -67,22 +68,17 @@ func main() {
|
|||||||
glog.Error("Invalid --times (negative or no testing requested)!")
|
glog.Error("Invalid --times (negative or no testing requested)!")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
cloudConfig := &e2e.CloudConfig{
|
|
||||||
ProjectID: *gceProject,
|
|
||||||
Zone: *gceZone,
|
|
||||||
MasterName: *masterName,
|
|
||||||
}
|
|
||||||
|
|
||||||
if *provider == "aws" {
|
if context.Provider == "aws" {
|
||||||
awsConfig := "[Global]\n"
|
awsConfig := "[Global]\n"
|
||||||
if *gceZone == "" {
|
if cloudConfig.Zone == "" {
|
||||||
glog.Error("gce_zone must be specified for AWS")
|
glog.Error("gce_zone must be specified for AWS")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
awsConfig += fmt.Sprintf("Zone=%s\n", *gceZone)
|
awsConfig += fmt.Sprintf("Zone=%s\n", cloudConfig.Zone)
|
||||||
|
|
||||||
var err error
|
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 {
|
if err != nil {
|
||||||
glog.Error("Error building AWS provider: %v", err)
|
glog.Error("Error building AWS provider: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -166,7 +166,7 @@ func (s *goamzEC2) DeleteVolume(volumeId string) (resp *ec2.SimpleResp, err erro
|
|||||||
func init() {
|
func init() {
|
||||||
cloudprovider.RegisterCloudProvider("aws", func(config io.Reader) (cloudprovider.Interface, error) {
|
cloudprovider.RegisterCloudProvider("aws", func(config io.Reader) (cloudprovider.Interface, error) {
|
||||||
metadata := &goamzMetadata{}
|
metadata := &goamzMetadata{}
|
||||||
return newAWSCloud(config, getAuth, metadata)
|
return newAWSCloud(config, getAuth, "", metadata)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ var _ = Describe("MasterCerts", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, certFile := range []string{"kubecfg.key", "kubecfg.crt", "ca.crt"} {
|
for _, certFile := range []string{"kubecfg.key", "kubecfg.crt", "ca.crt"} {
|
||||||
cmd := exec.Command("gcloud", "compute", "ssh", "--project", testContext.GCEConfig.ProjectID,
|
cmd := exec.Command("gcloud", "compute", "ssh", "--project", testContext.CloudConfig.ProjectID,
|
||||||
"--zone", testContext.GCEConfig.Zone, testContext.GCEConfig.MasterName,
|
"--zone", testContext.CloudConfig.Zone, testContext.CloudConfig.MasterName,
|
||||||
"--command", fmt.Sprintf("ls /srv/kubernetes/%s", certFile))
|
"--command", fmt.Sprintf("ls /srv/kubernetes/%s", certFile))
|
||||||
if _, err := cmd.CombinedOutput(); err != nil {
|
if _, err := cmd.CombinedOutput(); err != nil {
|
||||||
Fail(fmt.Sprintf("Error checking for cert file %s on master: %v", certFile, err))
|
Fail(fmt.Sprintf("Error checking for cert file %s on master: %v", certFile, err))
|
||||||
|
@ -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() {
|
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)",
|
By(fmt.Sprintf("Skipping PD test, which is only supported for providers gce & aws (not %s)",
|
||||||
testContext.provider))
|
testContext.Provider))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,10 +176,10 @@ var _ = Describe("PD", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
func createPD() (string, error) {
|
func createPD() (string, error) {
|
||||||
if testContext.provider == "gce" {
|
if testContext.Provider == "gce" {
|
||||||
pdName := fmt.Sprintf("e2e-%s", string(util.NewUUID()))
|
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.
|
// 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()
|
err := exec.Command("gcloud", "compute", "disks", "create", "--zone="+zone, "--size=10GB", pdName).Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -187,7 +187,7 @@ func createPD() (string, error) {
|
|||||||
}
|
}
|
||||||
return pdName, nil
|
return pdName, nil
|
||||||
} else {
|
} else {
|
||||||
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
|
volumes, ok := testContext.CloudConfig.Provider.(aws_cloud.Volumes)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("Provider does not support volumes")
|
return "", fmt.Errorf("Provider does not support volumes")
|
||||||
}
|
}
|
||||||
@ -198,36 +198,35 @@ func createPD() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func deletePD(pdName string) error {
|
func deletePD(pdName string) error {
|
||||||
if testContext.provider == "gce" {
|
if testContext.Provider == "gce" {
|
||||||
zone := testContext.cloudConfig.Zone
|
zone := testContext.CloudConfig.Zone
|
||||||
|
|
||||||
// TODO: make this hit the compute API directly.
|
// TODO: make this hit the compute API directly.
|
||||||
return exec.Command("gcloud", "compute", "disks", "delete", "--zone="+zone, pdName).Run()
|
return exec.Command("gcloud", "compute", "disks", "delete", "--zone="+zone, pdName).Run()
|
||||||
} else {
|
} else {
|
||||||
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
|
volumes, ok := testContext.CloudConfig.Provider.(aws_cloud.Volumes)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("Provider does not support volumes")
|
return fmt.Errorf("Provider does not support volumes")
|
||||||
}
|
}
|
||||||
return volumes.DeleteVolume(pdName)
|
return volumes.DeleteVolume(pdName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func detachPD(hostName, pdName string) error {
|
func detachPD(hostName, pdName string) error {
|
||||||
if testContext.provider == "gce" {
|
if testContext.Provider == "gce" {
|
||||||
instanceName := strings.Split(hostName, ".")[0]
|
instanceName := strings.Split(hostName, ".")[0]
|
||||||
|
|
||||||
zone := testContext.cloudConfig.Zone
|
zone := testContext.CloudConfig.Zone
|
||||||
|
|
||||||
// TODO: make this hit the compute API directly.
|
// TODO: make this hit the compute API directly.
|
||||||
return exec.Command("gcloud", "compute", "instances", "detach-disk", "--zone="+zone, "--disk="+pdName, instanceName).Run()
|
return exec.Command("gcloud", "compute", "instances", "detach-disk", "--zone="+zone, "--disk="+pdName, instanceName).Run()
|
||||||
} else {
|
} else {
|
||||||
volumes, ok := testContext.cloudConfig.Provider.(aws_cloud.Volumes)
|
volumes, ok := testContext.CloudConfig.Provider.(aws_cloud.Volumes)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", fmt.Errorf("Provider does not support volumes")
|
return fmt.Errorf("Provider does not support volumes")
|
||||||
}
|
}
|
||||||
return volumes.DetachDisk(hostName, pdName)
|
return volumes.DetachDisk(hostName, pdName)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
|
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{
|
pod.Spec.Volumes = []api.Volume{
|
||||||
{
|
{
|
||||||
Name: "testpd",
|
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{
|
pod.Spec.Volumes = []api.Volume{
|
||||||
{
|
{
|
||||||
Name: "testpd",
|
Name: "testpd",
|
||||||
@ -283,7 +282,7 @@ func testPDPod(diskName, targetHost string, readOnly bool) *api.Pod {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
panic("Unknown provider: " + testContext.provider)
|
panic("Unknown provider: " + testContext.Provider)
|
||||||
}
|
}
|
||||||
|
|
||||||
return pod
|
return pod
|
||||||
|
@ -49,7 +49,7 @@ type TestContextType struct {
|
|||||||
Host string
|
Host string
|
||||||
RepoRoot string
|
RepoRoot string
|
||||||
Provider string
|
Provider string
|
||||||
GCEConfig GCEConfig
|
CloudConfig CloudConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
var testContext TestContextType
|
var testContext TestContextType
|
||||||
|
Loading…
Reference in New Issue
Block a user