func TestOVirtCloudConfiguration(t *testing.T) { config1 := (io.Reader)(nil) _, err1 := cloudprovider.GetCloudProvider("ovirt", config1) if err1 == nil { t.Fatalf("An error is expected when the configuration is missing") } config2 := strings.NewReader("") _, err2 := cloudprovider.GetCloudProvider("ovirt", config2) if err2 == nil { t.Fatalf("An error is expected when the configuration is empty") } config3 := strings.NewReader(` [connection] `) _, err3 := cloudprovider.GetCloudProvider("ovirt", config3) if err3 == nil { t.Fatalf("An error is expected when the uri is missing") } config4 := strings.NewReader(` [connection] uri = https://localhost:8443/ovirt-engine/api `) _, err4 := cloudprovider.GetCloudProvider("ovirt", config4) if err4 != nil { t.Fatalf("Unexpected error creating the provider: %s", err4) } }
func TestE2E(t *testing.T) { util.ReallyCrash = true util.InitLogs() defer util.FlushLogs() if testContext.Provider == "" { glog.Info("The --provider flag is not set. Treating as a conformance test. Some tests may not be run.") } if testContext.Provider == "aws" { awsConfig := "[Global]\n" if cloudConfig.Zone == "" { glog.Fatal("gce-zone must be specified for AWS") } awsConfig += fmt.Sprintf("Zone=%s\n", cloudConfig.Zone) if cloudConfig.ClusterTag == "" { glog.Fatal("--cluster-tag must be specified for AWS") } awsConfig += fmt.Sprintf("QingYuanClusterTag=%s\n", cloudConfig.ClusterTag) var err error cloudConfig.Provider, err = cloudprovider.GetCloudProvider(testContext.Provider, strings.NewReader(awsConfig)) if err != nil { glog.Fatal("Error building AWS provider: ", err) } } // Disable density test unless it's explicitly requested. if config.GinkgoConfig.FocusString == "" && config.GinkgoConfig.SkipString == "" { config.GinkgoConfig.SkipString = "Skipped" } gomega.RegisterFailHandler(ginkgo.Fail) // Ensure all pods are running and ready before starting tests (otherwise, // cluster infrastructure pods that are being pulled or started can block // test pods from running, and tests that ensure all pods are running and // ready will fail). if err := waitForPodsRunningReady(api.NamespaceDefault, testContext.MinStartupPods, podStartupTimeout); err != nil { glog.Fatalf("Error waiting for all pods to be running and ready: %v", err) } // Run tests through the Ginkgo runner with output to console + JUnit for Jenkins var r []ginkgo.Reporter if *reportDir != "" { r = append(r, reporters.NewJUnitReporter(path.Join(*reportDir, fmt.Sprintf("junit_%02d.xml", config.GinkgoConfig.ParallelNode)))) failReport := &failReporter{} r = append(r, failReport) defer func() { if failReport.failed { coreDump(*reportDir) } }() } ginkgo.RunSpecsWithDefaultAndCustomReporters(t, "QingYuan e2e suite", r) }
// getVolumeProvider returns the AWS Volumes interface func (pd *awsElasticBlockStore) getVolumeProvider() (aws_cloud.Volumes, error) { name := "aws" cloud, err := cloudprovider.GetCloudProvider(name, nil) if err != nil { return nil, err } volumes, ok := cloud.(aws_cloud.Volumes) if !ok { return nil, fmt.Errorf("Cloud provider does not support volumes") } return volumes, nil }
// Unmounts the device and detaches the disk from the qinglet's host machine. func (util *GCEDiskUtil) DetachDisk(pd *gcePersistentDisk) error { // Unmount the global PD mount, which should be the only one. globalPDPath := makeGlobalPDName(pd.plugin.host, pd.pdName) if err := pd.mounter.Unmount(globalPDPath); err != nil { return err } if err := os.Remove(globalPDPath); err != nil { return err } // Detach the disk gce, err := cloudprovider.GetCloudProvider("gce", nil) if err != nil { return err } if err := gce.(*gce_cloud.GCECloud).DetachDisk(pd.pdName); err != nil { return err } return nil }
// Attaches a disk specified by a volume.GCEPersistentDisk to the current qinglet. // Mounts the disk to it's global path. func (util *GCEDiskUtil) AttachAndMountDisk(pd *gcePersistentDisk, globalPDPath string) error { gce, err := cloudprovider.GetCloudProvider("gce", nil) if err != nil { return err } if err := gce.(*gce_cloud.GCECloud).AttachDisk(pd.pdName, pd.readOnly); err != nil { return err } devicePaths := []string{ path.Join("/dev/disk/by-id/", "google-"+pd.pdName), path.Join("/dev/disk/by-id/", "scsi-0Google_PersistentDisk_"+pd.pdName), } if pd.partition != "" { for i, path := range devicePaths { devicePaths[i] = path + "-part" + pd.partition } } //TODO(jonesdl) There should probably be better method than busy-waiting here. numTries := 0 devicePath := "" // Wait for the disk device to be created for { for _, path := range devicePaths { _, err := os.Stat(path) if err == nil { devicePath = path break } if err != nil && !os.IsNotExist(err) { return err } } if devicePath != "" { break } numTries++ if numTries == 10 { return errors.New("Could not attach disk: Timeout after 10s") } time.Sleep(time.Second) } // Only mount the PD globally once. mountpoint, err := pd.mounter.IsMountPoint(globalPDPath) if err != nil { if os.IsNotExist(err) { if err := os.MkdirAll(globalPDPath, 0750); err != nil { return err } mountpoint = false } else { return err } } options := []string{} if pd.readOnly { options = append(options, "ro") } if !mountpoint { err = pd.diskMounter.Mount(devicePath, globalPDPath, pd.fsType, options) if err != nil { os.Remove(globalPDPath) return err } } return nil }