Exemplo n.º 1
0
// Run tests in archive against host
func testHost(host, archive string, deleteFiles bool) *TestResult {
	output, err := e2e_node.RunRemote(archive, host, deleteFiles)
	return &TestResult{
		output: output,
		err:    err,
		host:   host,
	}
}
Exemplo n.º 2
0
// Run tests in archive against host
func testHost(host, archive string) *TestResult {
	output, err := e2e_node.RunRemote(archive, host)
	return &TestResult{
		output: output,
		err:    err,
		host:   host,
	}
}
Exemplo n.º 3
0
// Run tests in archive against host
func testHost(host, archive string, deleteFiles bool, junitFileNum int) *TestResult {
	output, exitOk, err := e2e_node.RunRemote(archive, host, deleteFiles, junitFileNum)
	return &TestResult{
		output: output,
		err:    err,
		host:   host,
		exitOk: exitOk,
	}
}
Exemplo n.º 4
0
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)
	}
}
Exemplo n.º 5
0
// Run tests in archive against host
func testHost(host string, deleteFiles bool, junitFileNum int, setupNode bool) *TestResult {
	instance, err := computeService.Instances.Get(*project, *zone, host).Do()
	if err != nil {
		return &TestResult{
			err:    err,
			host:   host,
			exitOk: false,
		}
	}
	if strings.ToUpper(instance.Status) != "RUNNING" {
		err = fmt.Errorf("instance %s not in state RUNNING, was %s.", host, instance.Status)
		return &TestResult{
			err:    err,
			host:   host,
			exitOk: false,
		}
	}
	externalIp := getExternalIp(instance)
	if len(externalIp) > 0 {
		e2e_node.AddHostnameIp(host, externalIp)
	}

	path, err := arc.getArchive()
	if err != nil {
		// Don't log fatal because we need to do any needed cleanup contained in "defer" statements
		return &TestResult{
			err: fmt.Errorf("unable to create test archive %v.", err),
		}
	}

	output, exitOk, err := e2e_node.RunRemote(path, host, deleteFiles, junitFileNum, setupNode, *testArgs)
	return &TestResult{
		output: output,
		err:    err,
		host:   host,
		exitOk: exitOk,
	}
}