当前位置: 首页>>代码示例>>Golang>>正文


Golang e2e_node.CreateTestArchive函数代码示例

本文整理汇总了Golang中k8s/io/kubernetes/test/e2e_node.CreateTestArchive函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateTestArchive函数的具体用法?Golang CreateTestArchive怎么用?Golang CreateTestArchive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CreateTestArchive函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	// Setup coloring
	stat, _ := os.Stdout.Stat()
	useColor := (stat.Mode() & os.ModeCharDevice) != 0
	blue := ""
	noColour := ""
	if useColor {
		blue = "\033[0;34m"
		noColour = "\033[0m"
	}

	flag.Parse()
	if *hosts == "" {
		fmt.Printf("Must specific --hosts flag")
	}
	archive := e2e_node.CreateTestArchive()
	defer os.Remove(archive)

	results := make(chan *TestResult)
	hs := strings.Split(*hosts, ",")
	for _, h := range hs {
		fmt.Printf("Starting tests on host %s.", h)
		go func(host string) {
			output, err := e2e_node.RunRemote(archive, host)
			results <- &TestResult{
				output: output,
				err:    err,
				host:   host,
			}
		}(h)
	}

	// Wait for all tests to complete and emit the results
	errCount := 0
	for i := 0; i < len(hs); i++ {
		tr := <-results
		host := tr.host
		fmt.Printf("%s================================================================%s\n", blue, noColour)
		if tr.err != nil {
			errCount++
			fmt.Printf("Failure Finished Host %s Test Suite %s %v\n", host, tr.output, tr.err)
		} else {
			fmt.Printf("Success Finished Host %s Test Suite %s\n", host, tr.output)
		}
		fmt.Printf("%s================================================================%s\n", blue, noColour)
	}

	// Set the exit code if there were failures
	if errCount > 0 {
		fmt.Printf("Failure: %d errors encountered.", errCount)
		os.Exit(1)
	}
}
开发者ID:satnam6502,项目名称:kubernetes,代码行数:53,代码来源:run_e2e.go

示例2: main

func main() {
	flag.Parse()
	rand.Seed(time.Now().UTC().UnixNano())
	if *buildOnly {
		// Build the archive and exit
		e2e_node.CreateTestArchive()
		return
	}

	if *hosts == "" && *images == "" {
		glog.Fatalf("Must specify one of --images or --hosts flag.")
	}
	if *images != "" && *zone == "" {
		glog.Fatal("Must specify --zone flag")
	}
	if *images != "" && *project == "" {
		glog.Fatal("Must specify --project flag")
	}
	if *instanceNamePrefix == "" {
		*instanceNamePrefix = "tmp-node-e2e-" + uuid.NewUUID().String()[:8]
	}

	// Setup coloring
	stat, _ := os.Stdout.Stat()
	useColor := (stat.Mode() & os.ModeCharDevice) != 0
	blue := ""
	noColour := ""
	if useColor {
		blue = "\033[0;34m"
		noColour = "\033[0m"
	}

	archive := e2e_node.CreateTestArchive()
	defer os.Remove(archive)

	results := make(chan *TestResult)
	running := 0
	if *images != "" {
		// Setup the gce client for provisioning instances
		// Getting credentials on gce jenkins is flaky, so try a couple times
		var err error
		for i := 0; i < 10; i++ {
			var client *http.Client
			client, err = google.DefaultClient(oauth2.NoContext, compute.ComputeScope)
			if err != nil {
				continue
			}
			computeService, err = compute.New(client)
			if err != nil {
				continue
			}
			time.Sleep(time.Second * 6)
		}
		if err != nil {
			glog.Fatalf("Unable to create gcloud compute service using defaults.  Make sure you are authenticated. %v", err)
		}

		for _, image := range strings.Split(*images, ",") {
			running++
			fmt.Printf("Initializing e2e tests using image %s.\n", image)
			go func(image string) { results <- testImage(image, archive) }(image)
		}
	}
	if *hosts != "" {
		for _, host := range strings.Split(*hosts, ",") {
			fmt.Printf("Initializing e2e tests using host %s.\n", host)
			running++
			go func(host string) {
				results <- testHost(host, archive, *cleanup)
			}(host)
		}
	}

	// Wait for all tests to complete and emit the results
	errCount := 0
	for i := 0; i < running; i++ {
		tr := <-results
		host := tr.host
		fmt.Printf("%s================================================================%s\n", blue, noColour)
		if tr.err != nil {
			errCount++
			fmt.Printf("Failure Finished Host %s Test Suite\n%s\n%v\n", host, tr.output, tr.err)
		} else {
			fmt.Printf("Success Finished Host %s Test Suite\n%s\n", host, tr.output)
		}
		fmt.Printf("%s================================================================%s\n", blue, noColour)
	}

	// Set the exit code if there were failures
	if errCount > 0 {
		fmt.Printf("Failure: %d errors encountered.", errCount)
		os.Exit(1)
	}
}
开发者ID:odacremolbap,项目名称:kubernetes,代码行数:94,代码来源:run_e2e.go

示例3: main

func main() {
	flag.Parse()
	rand.Seed(time.Now().UTC().UnixNano())
	if *buildOnly {
		// Build the archive and exit
		e2e_node.CreateTestArchive()
		return
	}

	if *hosts == "" && *imageConfigFile == "" && *images == "" {
		glog.Fatalf("Must specify one of --image-config-file, --hosts, --images.")
	}
	gceImages := &ImageConfig{
		Images: make(map[string]GCEImage),
	}
	if *imageConfigFile != "" {
		// parse images
		imageConfigData, err := ioutil.ReadFile(*imageConfigFile)
		if err != nil {
			glog.Fatalf("Could not read image config file provided: %v", err)
		}
		err = yaml.Unmarshal(imageConfigData, gceImages)
		if err != nil {
			glog.Fatalf("Could not parse image config file: %v", err)
		}
	}

	// Allow users to specify additional images via cli flags for local testing
	// convenience; merge in with config file
	if *images != "" {
		if *imageProject == "" {
			glog.Fatal("Must specify --image-project if you specify --images")
		}
		cliImages := strings.Split(*images, ",")
		for _, img := range cliImages {
			gceImages.Images[img] = GCEImage{
				Image:   img,
				Project: *imageProject,
			}
		}
	}

	if len(gceImages.Images) != 0 && *zone == "" {
		glog.Fatal("Must specify --zone flag")
	}
	for shortName, image := range gceImages.Images {
		if image.Project == "" {
			glog.Fatalf("Invalid config for %v; must specify a project", shortName)
		}
	}
	if len(gceImages.Images) != 0 {
		if *project == "" {
			glog.Fatal("Must specify --project flag to launch images into")
		}
	}
	if *instanceNamePrefix == "" {
		*instanceNamePrefix = "tmp-node-e2e-" + uuid.NewUUID().String()[:8]
	}

	// Setup coloring
	stat, _ := os.Stdout.Stat()
	useColor := (stat.Mode() & os.ModeCharDevice) != 0
	blue := ""
	noColour := ""
	if useColor {
		blue = "\033[0;34m"
		noColour = "\033[0m"
	}

	go arc.getArchive()
	defer arc.deleteArchive()

	var err error
	computeService, err = getComputeClient()
	if err != nil {
		glog.Fatalf("Unable to create gcloud compute service using defaults.  Make sure you are authenticated. %v", err)
	}

	results := make(chan *TestResult)
	running := 0
	for shortName, image := range gceImages.Images {
		running++
		fmt.Printf("Initializing e2e tests using image %s.\n", shortName)
		go func(image, imageProject string, junitFileNum int) {
			results <- testImage(image, imageProject, junitFileNum)
		}(image.Image, image.Project, running)
	}
	if *hosts != "" {
		for _, host := range strings.Split(*hosts, ",") {
			fmt.Printf("Initializing e2e tests using host %s.\n", host)
			running++
			go func(host string, junitFileNum int) {
				results <- testHost(host, *cleanup, junitFileNum, *setupNode)
			}(host, running)
		}
	}

	// Wait for all tests to complete and emit the results
	errCount := 0
	exitOk := true
//.........这里部分代码省略.........
开发者ID:RyanBinfeng,项目名称:kubernetes,代码行数:101,代码来源:run_e2e.go

示例4: getArchive

func (a *Archive) getArchive() (string, error) {
	a.Do(func() { a.path, a.err = e2e_node.CreateTestArchive() })
	return a.path, a.err
}
开发者ID:RyanBinfeng,项目名称:kubernetes,代码行数:4,代码来源:run_e2e.go

示例5: main

func main() {
	flag.Parse()
	rand.Seed(time.Now().UTC().UnixNano())
	if *buildOnly {
		// Build the archive and exit
		e2e_node.CreateTestArchive()
		return
	}

	if *hosts == "" && *images == "" {
		glog.Fatalf("Must specify one of --images or --hosts flag.")
	}
	if *images != "" && *zone == "" {
		glog.Fatal("Must specify --zone flag")
	}
	if *images != "" {
		if *imageProject == "" {
			glog.Fatal("Must specify --image-project flag")
		}
		if *project == "" {
			glog.Fatal("Must specify --project flag")
		}
	}
	if *instanceNamePrefix == "" {
		*instanceNamePrefix = "tmp-node-e2e-" + uuid.NewUUID().String()[:8]
	}

	// Setup coloring
	stat, _ := os.Stdout.Stat()
	useColor := (stat.Mode() & os.ModeCharDevice) != 0
	blue := ""
	noColour := ""
	if useColor {
		blue = "\033[0;34m"
		noColour = "\033[0m"
	}

	go arc.getArchive()
	defer arc.deleteArchive()

	var err error
	computeService, err = getComputeClient()
	if err != nil {
		glog.Fatalf("Unable to create gcloud compute service using defaults.  Make sure you are authenticated. %v", err)
	}

	results := make(chan *TestResult)
	running := 0
	if *images != "" {
		for _, image := range strings.Split(*images, ",") {
			running++
			fmt.Printf("Initializing e2e tests using image %s.\n", image)
			go func(image string, junitFileNum int) { results <- testImage(image, junitFileNum) }(image, running)
		}
	}
	if *hosts != "" {
		for _, host := range strings.Split(*hosts, ",") {
			fmt.Printf("Initializing e2e tests using host %s.\n", host)
			running++
			go func(host string, junitFileNum int) {
				results <- testHost(host, *cleanup, junitFileNum, *setupNode)
			}(host, running)
		}
	}

	// Wait for all tests to complete and emit the results
	errCount := 0
	exitOk := true
	for i := 0; i < running; i++ {
		tr := <-results
		host := tr.host
		fmt.Printf("%s================================================================%s\n", blue, noColour)
		if tr.err != nil {
			errCount++
			fmt.Printf("Failure Finished Host %s Test Suite\n%s\n%v\n", host, tr.output, tr.err)
		} else {
			fmt.Printf("Success Finished Host %s Test Suite\n%s\n", host, tr.output)
		}
		exitOk = exitOk && tr.exitOk
		fmt.Printf("%s================================================================%s\n", blue, noColour)
	}

	// Set the exit code if there were failures
	if !exitOk {
		fmt.Printf("Failure: %d errors encountered.", errCount)
		os.Exit(1)
	}
}
开发者ID:CsatariGergely,项目名称:kubernetes,代码行数:88,代码来源:run_e2e.go


注:本文中的k8s/io/kubernetes/test/e2e_node.CreateTestArchive函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。